diff --git a/include/boost/operators.hpp b/include/boost/operators.hpp index d8a1038..3fc08d5 100644 --- a/include/boost/operators.hpp +++ b/include/boost/operators.hpp @@ -73,7 +73,7 @@ // issue at the cost of some simplicity. // // One of the complications is an existence of special auxiliary class template -// 'is_chained_base<>' (see 'detail' namespace below), which is used +// 'is_chained_base<>' (see 'operators_detail' namespace below), which is used // to determine whether its template parameter is a library's operator template // or not. You have to specialize 'is_chained_base<>' for each new // operator template you add to the library. @@ -113,19 +113,19 @@ namespace boost { namespace operators_impl { -namespace detail +namespace operators_detail { template class empty_base {}; -} // namespace detail +} // namespace operators_detail // Basic operator classes (contributed by Dave Abrahams) ------------------// // Note that friend functions defined in a class are implicitly inline. // See the C++ std, 11.4 [class.friend] paragraph 5 -template > +template > struct less_than_comparable2 : B { friend bool operator<=(const T& x, const U& y) { return !static_cast(x > y); } @@ -136,7 +136,7 @@ struct less_than_comparable2 : B friend bool operator>=(const U& x, const T& y) { return !static_cast(y > x); } }; -template > +template > struct less_than_comparable1 : B { friend bool operator>(const T& x, const T& y) { return y < x; } @@ -144,7 +144,7 @@ struct less_than_comparable1 : B friend bool operator>=(const T& x, const T& y) { return !static_cast(x < y); } }; -template > +template > struct equality_comparable2 : B { friend bool operator==(const U& y, const T& x) { return x == y; } @@ -152,7 +152,7 @@ struct equality_comparable2 : B friend bool operator!=(const T& y, const U& x) { return !static_cast(y == x); } }; -template > +template > struct equality_comparable1 : B { friend bool operator!=(const T& x, const T& y) { return !static_cast(x == y); } @@ -170,43 +170,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 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_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 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; } \ +#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) @@ -217,34 +217,34 @@ struct NAME##1 : B \ // optimization opportunities to the compiler :) #define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \ -template > \ +template > \ struct NAME##2 : B \ { \ friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \ friend T operator OP( const U& lhs, T rhs ) { return rhs OP##= lhs; } \ }; \ \ -template > \ +template > \ struct NAME##1 : B \ { \ friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \ }; #define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \ -template > \ +template > \ struct NAME##2 : B \ { \ friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \ }; \ \ -template > \ +template > \ struct BOOST_OPERATOR2_LEFT(NAME) : B \ { \ friend T operator OP( const U& lhs, const T& rhs ) \ { return T( lhs ) OP##= rhs; } \ }; \ \ -template > \ +template > \ struct NAME##1 : B \ { \ friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \ @@ -267,7 +267,7 @@ BOOST_BINARY_OPERATOR_COMMUTATIVE( orable, | ) // incrementable and decrementable contributed by Jeremy Siek -template > +template > struct incrementable : B { friend T operator++(T& x, int) @@ -280,7 +280,7 @@ private: // The use of this typedef works around a Borland bug typedef T incrementable_type; }; -template > +template > struct decrementable : B { friend T operator--(T& x, int) @@ -295,7 +295,7 @@ private: // The use of this typedef works around a Borland bug // Iterator operator classes (contributed by Jeremy Siek) ------------------// -template > +template > struct dereferenceable : B { P operator->() const @@ -304,7 +304,7 @@ struct dereferenceable : B } }; -template > +template > struct indexable : B { R operator[](I n) const @@ -318,31 +318,31 @@ 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 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; } \ +#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) #define BOOST_BINARY_OPERATOR( NAME, OP ) \ -template > \ +template > \ struct NAME##2 : B \ { \ friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \ }; \ \ -template > \ +template > \ struct NAME##1 : B \ { \ friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \ @@ -355,7 +355,7 @@ BOOST_BINARY_OPERATOR( right_shiftable, >> ) #undef BOOST_BINARY_OPERATOR -template > +template > struct equivalent2 : B { friend bool operator==(const T& x, const U& y) @@ -364,7 +364,7 @@ struct equivalent2 : B } }; -template > +template > struct equivalent1 : B { friend bool operator==(const T&x, const T&y) @@ -373,7 +373,7 @@ struct equivalent1 : B } }; -template > +template > struct partially_ordered2 : B { friend bool operator<=(const T& x, const U& y) @@ -390,7 +390,7 @@ struct partially_ordered2 : B { return static_cast(y < x) || static_cast(y == x); } }; -template > +template > struct partially_ordered1 : B { friend bool operator>(const T& x, const T& y) @@ -403,161 +403,161 @@ struct partially_ordered1 : B // Combined operator classes (contributed by Daryle Walker) ----------------// -template > +template > struct totally_ordered2 : less_than_comparable2 > {}; -template > +template > struct totally_ordered1 : less_than_comparable1 > {}; -template > +template > struct additive2 : addable2 > {}; -template > +template > struct additive1 : addable1 > {}; -template > +template > struct multiplicative2 : multipliable2 > {}; -template > +template > struct multiplicative1 : multipliable1 > {}; -template > +template > struct integer_multiplicative2 : multiplicative2 > {}; -template > +template > struct integer_multiplicative1 : multiplicative1 > {}; -template > +template > struct arithmetic2 : additive2 > {}; -template > +template > struct arithmetic1 : additive1 > {}; -template > +template > struct integer_arithmetic2 : additive2 > {}; -template > +template > struct integer_arithmetic1 : additive1 > {}; -template > +template > struct bitwise2 : xorable2 > > {}; -template > +template > struct bitwise1 : xorable1 > > {}; -template > +template > struct unit_steppable : incrementable > {}; -template > +template > struct shiftable2 : left_shiftable2 > {}; -template > +template > struct shiftable1 : left_shiftable1 > {}; -template > +template > struct ring_operators2 : additive2 > > {}; -template > +template > struct ring_operators1 : additive1 > {}; -template > +template > struct ordered_ring_operators2 : ring_operators2 > {}; -template > +template > struct ordered_ring_operators1 : ring_operators1 > {}; -template > +template > struct field_operators2 : ring_operators2 > > {}; -template > +template > struct field_operators1 : ring_operators1 > {}; -template > +template > struct ordered_field_operators2 : field_operators2 > {}; -template > +template > struct ordered_field_operators1 : field_operators1 > {}; -template > +template > struct euclidian_ring_operators2 : ring_operators2 > > > > {}; -template > +template > struct euclidian_ring_operators1 : ring_operators1 > > {}; -template > +template > struct ordered_euclidian_ring_operators2 : totally_ordered2 > {}; -template > +template > struct ordered_euclidian_ring_operators1 : totally_ordered1 > {}; -template > +template > struct euclidean_ring_operators2 : ring_operators2 > > > > {}; -template > +template > struct euclidean_ring_operators1 : ring_operators1 > > {}; -template > +template > struct ordered_euclidean_ring_operators2 : totally_ordered2 > {}; -template > +template > struct ordered_euclidean_ring_operators1 : totally_ordered1 > {}; -template > +template > struct input_iteratable : equality_comparable1 > > {}; -template > +template > struct output_iteratable : incrementable {}; -template > +template > struct forward_iteratable : input_iteratable {}; -template > +template > struct bidirectional_iteratable : forward_iteratable > +template > struct random_access_iteratable : bidirectional_iteratable - a traits class used to distinguish whether an operator // template argument is being used for base class chaining, or is specifying a @@ -673,7 +673,7 @@ struct false_t {}; // class chaining. We specialize for the operator templates defined in this // library. template struct is_chained_base { - typedef detail::false_t value; + typedef operators_detail::false_t value; }; // Provide a specialization of 'is_chained_base<>' @@ -681,7 +681,7 @@ template struct is_chained_base { # define BOOST_OPERATOR_TEMPLATE4(template_name4) \ template \ struct is_chained_base< template_name4 > { \ - typedef detail::true_t value; \ + typedef operators_detail::true_t value; \ }; // Provide a specialization of 'is_chained_base<>' @@ -689,7 +689,7 @@ template struct is_chained_base { # define BOOST_OPERATOR_TEMPLATE3(template_name3) \ template \ struct is_chained_base< template_name3 > { \ - typedef detail::true_t value; \ + typedef operators_detail::true_t value; \ }; // Provide a specialization of 'is_chained_base<>' @@ -697,7 +697,7 @@ template struct is_chained_base { # define BOOST_OPERATOR_TEMPLATE2(template_name2) \ template \ struct is_chained_base< template_name2 > { \ - typedef detail::true_t value; \ + typedef operators_detail::true_t value; \ }; // Provide a specialization of 'is_chained_base<>' @@ -705,7 +705,7 @@ template struct is_chained_base { # define BOOST_OPERATOR_TEMPLATE1(template_name1) \ template \ struct is_chained_base< template_name1 > { \ - typedef detail::true_t value; \ + typedef operators_detail::true_t value; \ }; // BOOST_OPERATOR_TEMPLATE(template_name) defines template_name<> such that it @@ -722,32 +722,32 @@ template struct is_chained_base { // implementation in terms of either '1' or '2'. // -# define BOOST_OPERATOR_TEMPLATE(template_name) \ -template \ - ,class O = typename is_chained_base::value \ - > \ -struct template_name; \ - \ -template \ -struct template_name \ - : template_name##2 {}; \ - \ -template \ -struct template_name, detail::true_t> \ - : template_name##1 {}; \ - \ -template \ -struct template_name \ - : template_name##1 {}; \ - \ -template \ -struct is_chained_base< template_name > { \ - typedef detail::true_t value; \ -}; \ - \ -BOOST_OPERATOR_TEMPLATE2(template_name##2) \ +# define BOOST_OPERATOR_TEMPLATE(template_name) \ +template \ + ,class O = typename is_chained_base::value \ + > \ +struct template_name; \ + \ +template \ +struct template_name \ + : template_name##2 {}; \ + \ +template \ +struct template_name, operators_detail::true_t> \ + : template_name##1 {}; \ + \ +template \ +struct template_name \ + : template_name##1 {}; \ + \ +template \ +struct is_chained_base< template_name > { \ + typedef operators_detail::true_t value; \ +}; \ + \ +BOOST_OPERATOR_TEMPLATE2(template_name##2) \ BOOST_OPERATOR_TEMPLATE1(template_name##1) BOOST_OPERATOR_TEMPLATE(less_than_comparable)