diff --git a/include/boost/operators.hpp b/include/boost/operators.hpp index 0f4bca0..3ef19cc 100644 --- a/include/boost/operators.hpp +++ b/include/boost/operators.hpp @@ -174,43 +174,43 @@ struct equality_comparable1 : B // If the compiler has no NRVO, this is the best symmetric // implementation available. -#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \ -template > \ -struct NAME##2 : B \ -{ \ - friend BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const U& rhs ) \ - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ - friend BOOST_CXX14_CONSTEXPR T operator OP( const U& lhs, const T& rhs ) \ - { T nrv( rhs ); nrv OP##= lhs; return nrv; } \ -}; \ - \ -template > \ -struct NAME##1 : B \ -{ \ - friend BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const T& rhs ) \ - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ +#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \ +template > \ +struct NAME##2 : B \ +{ \ + friend T operator OP( const T& lhs, const U& rhs ) \ + { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ + friend T operator OP( const U& lhs, const T& rhs ) \ + { T nrv( rhs ); nrv OP##= lhs; return nrv; } \ +}; \ + \ +template > \ +struct NAME##1 : B \ +{ \ + friend T operator OP( const T& lhs, const T& rhs ) \ + { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ }; -#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \ -template > \ -struct NAME##2 : B \ -{ \ - friend BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const U& rhs ) \ - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ -}; \ - \ -template > \ -struct BOOST_OPERATOR2_LEFT(NAME) : B \ -{ \ - friend BOOST_CXX14_CONSTEXPR T operator OP( const U& lhs, const T& rhs ) \ - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ -}; \ - \ -template > \ -struct NAME##1 : B \ -{ \ - friend BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const T& rhs ) \ - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ +#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \ +template > \ +struct NAME##2 : B \ +{ \ + friend T operator OP( const T& lhs, const U& rhs ) \ + { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ +}; \ + \ +template > \ +struct BOOST_OPERATOR2_LEFT(NAME) : B \ +{ \ + friend T operator OP( const U& lhs, const T& rhs ) \ + { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ +}; \ + \ +template > \ +struct NAME##1 : B \ +{ \ + friend T operator OP( const T& lhs, const T& rhs ) \ + { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ }; #else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS) @@ -274,7 +274,7 @@ BOOST_BINARY_OPERATOR_COMMUTATIVE( orable, | ) template > struct incrementable : B { - friend BOOST_CXX14_CONSTEXPR T operator++(T& x, int) + friend T operator++(T& x, int) { incrementable_type nrv(x); ++x; @@ -287,7 +287,7 @@ private: // The use of this typedef works around a Borland bug template > struct decrementable : B { - friend BOOST_CXX14_CONSTEXPR T operator--(T& x, int) + friend T operator--(T& x, int) { decrementable_type nrv(x); --x; @@ -322,19 +322,19 @@ struct indexable : B #if defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS) -#define BOOST_BINARY_OPERATOR( NAME, OP ) \ -template > \ -struct NAME##2 : B \ -{ \ - friend BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const U& rhs ) \ - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ -}; \ - \ -template > \ -struct NAME##1 : B \ -{ \ - friend BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const T& rhs ) \ - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ +#define BOOST_BINARY_OPERATOR( NAME, OP ) \ +template > \ +struct NAME##2 : B \ +{ \ + friend T operator OP( const T& lhs, const U& rhs ) \ + { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ +}; \ + \ +template > \ +struct NAME##1 : B \ +{ \ + friend T operator OP( const T& lhs, const T& rhs ) \ + { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ }; #else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS) diff --git a/operators.htm b/operators.htm index f1613c5..b985e91 100644 --- a/operators.htm +++ b/operators.htm @@ -559,7 +559,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -573,7 +573,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -587,7 +587,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -601,7 +601,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -613,7 +613,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); T temp(u); temp -= t.
Return convertible to T. - Since C++14 + No @@ -627,7 +627,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -642,7 +642,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -655,7 +655,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -668,7 +668,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -680,7 +680,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); T temp(u); temp /= t.
Return convertible to T. - Since C++14 + No @@ -693,7 +693,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -706,7 +706,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -718,7 +718,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); T temp(u); temp %= t.
Return convertible to T. - Since C++14 + No @@ -731,7 +731,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -745,7 +745,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -758,7 +758,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -772,7 +772,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -785,7 +785,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -799,7 +799,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -811,7 +811,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); T temp(t); ++t
Return convertible to T. - Since C++14 + No @@ -823,7 +823,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); T temp(t); --t;
Return convertible to T. - Since C++14 + No @@ -837,7 +837,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -851,7 +851,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -865,7 +865,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No @@ -879,7 +879,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); Return convertible to T. See the Symmetry Note. - Since C++14 + No diff --git a/test/operators_test.cpp b/test/operators_test.cpp index 786ba3b..fdc0cc4 100644 --- a/test/operators_test.cpp +++ b/test/operators_test.cpp @@ -72,28 +72,28 @@ namespace BOOST_CONSTEXPR convertible_to_bool operator==(const Wrapped1& x) const { return _value == x._value; } - BOOST_CXX14_CONSTEXPR Wrapped1& operator+=(const Wrapped1& x) + Wrapped1& operator+=(const Wrapped1& x) { _value += x._value; return *this; } - BOOST_CXX14_CONSTEXPR Wrapped1& operator-=(const Wrapped1& x) + Wrapped1& operator-=(const Wrapped1& x) { _value -= x._value; return *this; } - BOOST_CXX14_CONSTEXPR Wrapped1& operator*=(const Wrapped1& x) + Wrapped1& operator*=(const Wrapped1& x) { _value *= x._value; return *this; } - BOOST_CXX14_CONSTEXPR Wrapped1& operator/=(const Wrapped1& x) + Wrapped1& operator/=(const Wrapped1& x) { _value /= x._value; return *this; } - BOOST_CXX14_CONSTEXPR Wrapped1& operator%=(const Wrapped1& x) + Wrapped1& operator%=(const Wrapped1& x) { _value %= x._value; return *this; } - BOOST_CXX14_CONSTEXPR Wrapped1& operator|=(const Wrapped1& x) + Wrapped1& operator|=(const Wrapped1& x) { _value |= x._value; return *this; } - BOOST_CXX14_CONSTEXPR Wrapped1& operator&=(const Wrapped1& x) + Wrapped1& operator&=(const Wrapped1& x) { _value &= x._value; return *this; } - BOOST_CXX14_CONSTEXPR Wrapped1& operator^=(const Wrapped1& x) + Wrapped1& operator^=(const Wrapped1& x) { _value ^= x._value; return *this; } - BOOST_CXX14_CONSTEXPR Wrapped1& operator<<=(const Wrapped1& x) + Wrapped1& operator<<=(const Wrapped1& x) { _value <<= x._value; return *this; } - BOOST_CXX14_CONSTEXPR Wrapped1& operator>>=(const Wrapped1& x) + Wrapped1& operator>>=(const Wrapped1& x) { _value >>= x._value; return *this; } - BOOST_CXX14_CONSTEXPR Wrapped1& operator++() { ++_value; return *this; } - BOOST_CXX14_CONSTEXPR Wrapped1& operator--() { --_value; return *this; } + Wrapped1& operator++() { ++_value; return *this; } + Wrapped1& operator--() { --_value; return *this; } private: T _value; @@ -956,40 +956,5 @@ main() static_assert( MyInt{ 1 } >= MyInt{ 1 }, "" ); #endif -// Where C++14 constexpr is available, compile-time test some of the operators that are able to use it to propagate constexpr -#ifndef BOOST_NO_CXX14_CONSTEXPR - static_assert( ( MyInt{ 1 } + MyInt{ 2 } ) == MyInt{ 3 }, "" ); - static_assert( ( MyInt{ 2 } + MyInt{ 1 } ) == MyInt{ 3 }, "" ); - static_assert( ( MyInt{ 2 } + MyInt{ 1 } ) == MyInt{ 3 }, "" ); - static_assert( ( MyInt{ 2 } + MyInt{ 2 } ) == MyInt{ 4 }, "" ); - static_assert( ( MyInt{ 3 } + MyInt{ 2 } ) == MyInt{ 5 }, "" ); - - static_assert( ( MyInt{ 5 } - MyInt{ 1 } ) == MyInt{ 4 }, "" ); - - static_assert( ( MyInt{ 3 } * MyInt{ 3 } ) == MyInt{ 9 }, "" ); - static_assert( ( MyInt{ 4 } * MyInt{ 2 } ) == MyInt{ 8 }, "" ); - - static_assert( ( MyInt{ 8 } / MyInt{ 2 } ) == MyInt{ 4 }, "" ); - - static_assert( ( MyInt{ 4 } % MyInt{ 3 } ) == MyInt{ 1 }, "" ); - - - static_assert( ( MyInt{ 7 } & MyInt{ 2 } ) == MyInt{ 2 }, "" ); - - static_assert( ( MyInt{ 1 } | MyInt{ 2 } ) == MyInt{ 3 }, "" ); - static_assert( ( MyInt{ 1 } | MyInt{ 4 } ) == MyInt{ 5 }, "" ); - static_assert( ( MyInt{ 2 } | MyInt{ 1 } ) == MyInt{ 3 }, "" ); - static_assert( ( MyInt{ 2 } | MyInt{ 4 } ) == MyInt{ 6 }, "" ); - static_assert( ( MyInt{ 3 } | MyInt{ 4 } ) == MyInt{ 7 }, "" ); - static_assert( ( MyInt{ 5 } | MyInt{ 2 } ) == MyInt{ 7 }, "" ); - static_assert( ( MyInt{ 6 } | MyInt{ 1 } ) == MyInt{ 7 }, "" ); - - static_assert( ( MyInt{ 3 } ^ MyInt{ 1 } ) == MyInt{ 2 }, "" ); - - - static_assert( ( MyInt{ 1 } << MyInt{ 2 } ) == MyInt{ 4 }, "" ); - static_assert( ( MyInt{ 2 } >> MyInt{ 1 } ) == MyInt{ 1 }, "" ); -#endif - return boost::report_errors(); }