diff --git a/include/boost/endian/arithmetic.hpp b/include/boost/endian/arithmetic.hpp index 7dd22c6..1f231b0 100644 --- a/include/boost/endian/arithmetic.hpp +++ b/include/boost/endian/arithmetic.hpp @@ -28,9 +28,6 @@ #endif #include -#define BOOST_ENDIAN_MINIMAL_COVER_OPERATORS -#include -#undef BOOST_ENDIAN_MINIMAL_COVER_OPERATORS #include #include #include @@ -281,8 +278,7 @@ namespace endian template class endian_arithmetic: - public endian_buffer, - private cover_operators, T> + public endian_buffer { private: @@ -312,6 +308,120 @@ public: { return this->value(); } + + // operators + + T operator+() const BOOST_NOEXCEPT + { + return this->value(); + } + + endian_arithmetic& operator+=( T y ) BOOST_NOEXCEPT + { + *this = static_cast( this->value() + y ); + return *this; + } + + endian_arithmetic& operator-=( T y ) BOOST_NOEXCEPT + { + *this = static_cast( this->value() - y ); + return *this; + } + + endian_arithmetic& operator*=( T y ) BOOST_NOEXCEPT + { + *this = static_cast( this->value() * y ); + return *this; + } + + endian_arithmetic& operator/=( T y ) BOOST_NOEXCEPT + { + *this = static_cast( this->value() / y ); + return *this; + } + + endian_arithmetic& operator%=( T y ) BOOST_NOEXCEPT + { + *this = static_cast( this->value() % y ); + return *this; + } + + endian_arithmetic& operator&=( T y ) BOOST_NOEXCEPT + { + *this = static_cast( this->value() & y ); + return *this; + } + + endian_arithmetic& operator|=( T y ) BOOST_NOEXCEPT + { + *this = static_cast( this->value() | y ); + return *this; + } + + endian_arithmetic& operator^=( T y ) BOOST_NOEXCEPT + { + *this = static_cast( this->value() ^ y ); + return *this; + } + + endian_arithmetic& operator<<=( T y ) BOOST_NOEXCEPT + { + *this = static_cast( this->value() << y ); + return *this; + } + + endian_arithmetic& operator>>=( T y ) BOOST_NOEXCEPT + { + *this = static_cast( this->value() >> y ); + return *this; + } + + endian_arithmetic& operator++() BOOST_NOEXCEPT + { + *this += 1; + return *this; + } + + endian_arithmetic& operator--() BOOST_NOEXCEPT + { + *this -= 1; + return *this; + } + + endian_arithmetic operator++(int) BOOST_NOEXCEPT + { + endian_arithmetic tmp( *this ); + *this += 1; + return tmp; + } + + endian_arithmetic operator--(int) BOOST_NOEXCEPT + { + endian_arithmetic tmp( *this ); + *this -= 1; + return tmp; + } + + template + friend std::basic_ostream& + operator<<( std::basic_ostream& os, endian_arithmetic const& x ) + { + return os << x.value(); + } + + template + friend std::basic_istream& + operator>>( std::basic_istream& is, endian_arithmetic& x ) + { + T i; + + if( is >> i ) + { + x = i; + } + + return is; + } }; } // namespace endian