1.1 --- a/epoc32/include/stdapis/boost/operators.hpp Tue Mar 16 16:12:26 2010 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,941 +0,0 @@
1.4 -// Boost operators.hpp header file ----------------------------------------//
1.5 -
1.6 -// (C) Copyright David Abrahams, Jeremy Siek, Daryle Walker 1999-2001.
1.7 -// Distributed under the Boost Software License, Version 1.0. (See
1.8 -// accompanying file LICENSE_1_0.txt or copy at
1.9 -// http://www.boost.org/LICENSE_1_0.txt)
1.10 -
1.11 -// See http://www.boost.org/libs/utility/operators.htm for documentation.
1.12 -
1.13 -// Revision History
1.14 -// 21 Oct 02 Modified implementation of operators to allow compilers with a
1.15 -// correct named return value optimization (NRVO) to produce optimal
1.16 -// code. (Daniel Frey)
1.17 -// 02 Dec 01 Bug fixed in random_access_iteratable. (Helmut Zeisel)
1.18 -// 28 Sep 01 Factored out iterator operator groups. (Daryle Walker)
1.19 -// 27 Aug 01 'left' form for non commutative operators added;
1.20 -// additional classes for groups of related operators added;
1.21 -// workaround for empty base class optimization
1.22 -// bug of GCC 3.0 (Helmut Zeisel)
1.23 -// 25 Jun 01 output_iterator_helper changes: removed default template
1.24 -// parameters, added support for self-proxying, additional
1.25 -// documentation and tests (Aleksey Gurtovoy)
1.26 -// 29 May 01 Added operator classes for << and >>. Added input and output
1.27 -// iterator helper classes. Added classes to connect equality and
1.28 -// relational operators. Added classes for groups of related
1.29 -// operators. Reimplemented example operator and iterator helper
1.30 -// classes in terms of the new groups. (Daryle Walker, with help
1.31 -// from Alexy Gurtovoy)
1.32 -// 11 Feb 01 Fixed bugs in the iterator helpers which prevented explicitly
1.33 -// supplied arguments from actually being used (Dave Abrahams)
1.34 -// 04 Jul 00 Fixed NO_OPERATORS_IN_NAMESPACE bugs, major cleanup and
1.35 -// refactoring of compiler workarounds, additional documentation
1.36 -// (Alexy Gurtovoy and Mark Rodgers with some help and prompting from
1.37 -// Dave Abrahams)
1.38 -// 28 Jun 00 General cleanup and integration of bugfixes from Mark Rodgers and
1.39 -// Jeremy Siek (Dave Abrahams)
1.40 -// 20 Jun 00 Changes to accommodate Borland C++Builder 4 and Borland C++ 5.5
1.41 -// (Mark Rodgers)
1.42 -// 20 Jun 00 Minor fixes to the prior revision (Aleksey Gurtovoy)
1.43 -// 10 Jun 00 Support for the base class chaining technique was added
1.44 -// (Aleksey Gurtovoy). See documentation and the comments below
1.45 -// for the details.
1.46 -// 12 Dec 99 Initial version with iterator operators (Jeremy Siek)
1.47 -// 18 Nov 99 Change name "divideable" to "dividable", remove unnecessary
1.48 -// specializations of dividable, subtractable, modable (Ed Brey)
1.49 -// 17 Nov 99 Add comments (Beman Dawes)
1.50 -// Remove unnecessary specialization of operators<> (Ed Brey)
1.51 -// 15 Nov 99 Fix less_than_comparable<T,U> second operand type for first two
1.52 -// operators.(Beman Dawes)
1.53 -// 12 Nov 99 Add operators templates (Ed Brey)
1.54 -// 11 Nov 99 Add single template parameter version for compilers without
1.55 -// partial specialization (Beman Dawes)
1.56 -// 10 Nov 99 Initial version
1.57 -
1.58 -// 10 Jun 00:
1.59 -// An additional optional template parameter was added to most of
1.60 -// operator templates to support the base class chaining technique (see
1.61 -// documentation for the details). Unfortunately, a straightforward
1.62 -// implementation of this change would have broken compatibility with the
1.63 -// previous version of the library by making it impossible to use the same
1.64 -// template name (e.g. 'addable') for both the 1- and 2-argument versions of
1.65 -// an operator template. This implementation solves the backward-compatibility
1.66 -// issue at the cost of some simplicity.
1.67 -//
1.68 -// One of the complications is an existence of special auxiliary class template
1.69 -// 'is_chained_base<>' (see 'detail' namespace below), which is used
1.70 -// to determine whether its template parameter is a library's operator template
1.71 -// or not. You have to specialize 'is_chained_base<>' for each new
1.72 -// operator template you add to the library.
1.73 -//
1.74 -// However, most of the non-trivial implementation details are hidden behind
1.75 -// several local macros defined below, and as soon as you understand them,
1.76 -// you understand the whole library implementation.
1.77 -
1.78 -#ifndef BOOST_OPERATORS_HPP
1.79 -#define BOOST_OPERATORS_HPP
1.80 -
1.81 -#include <boost/config.hpp>
1.82 -#include <boost/iterator.hpp>
1.83 -#include <boost/detail/workaround.hpp>
1.84 -
1.85 -#if defined(__sgi) && !defined(__GNUC__)
1.86 -# pragma set woff 1234
1.87 -#endif
1.88 -
1.89 -#if defined(BOOST_MSVC)
1.90 -# pragma warning( disable : 4284 ) // complaint about return type of
1.91 -#endif // operator-> not begin a UDT
1.92 -
1.93 -namespace boost {
1.94 -namespace detail {
1.95 -
1.96 -// Helmut Zeisel, empty base class optimization bug with GCC 3.0.0
1.97 -#if defined(__GNUC__) && __GNUC__==3 && __GNUC_MINOR__==0 && __GNU_PATCHLEVEL__==0
1.98 -class empty_base {
1.99 - bool dummy;
1.100 -};
1.101 -#else
1.102 -class empty_base {};
1.103 -#endif
1.104 -
1.105 -} // namespace detail
1.106 -} // namespace boost
1.107 -
1.108 -// In this section we supply the xxxx1 and xxxx2 forms of the operator
1.109 -// templates, which are explicitly targeted at the 1-type-argument and
1.110 -// 2-type-argument operator forms, respectively. Some compilers get confused
1.111 -// when inline friend functions are overloaded in namespaces other than the
1.112 -// global namespace. When BOOST_NO_OPERATORS_IN_NAMESPACE is defined, all of
1.113 -// these templates must go in the global namespace.
1.114 -
1.115 -#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
1.116 -namespace boost
1.117 -{
1.118 -#endif
1.119 -
1.120 -// Basic operator classes (contributed by Dave Abrahams) ------------------//
1.121 -
1.122 -// Note that friend functions defined in a class are implicitly inline.
1.123 -// See the C++ std, 11.4 [class.friend] paragraph 5
1.124 -
1.125 -template <class T, class U, class B = ::boost::detail::empty_base>
1.126 -struct less_than_comparable2 : B
1.127 -{
1.128 - friend bool operator<=(const T& x, const U& y) { return !(x > y); }
1.129 - friend bool operator>=(const T& x, const U& y) { return !(x < y); }
1.130 - friend bool operator>(const U& x, const T& y) { return y < x; }
1.131 - friend bool operator<(const U& x, const T& y) { return y > x; }
1.132 - friend bool operator<=(const U& x, const T& y) { return !(y < x); }
1.133 - friend bool operator>=(const U& x, const T& y) { return !(y > x); }
1.134 -};
1.135 -
1.136 -template <class T, class B = ::boost::detail::empty_base>
1.137 -struct less_than_comparable1 : B
1.138 -{
1.139 - friend bool operator>(const T& x, const T& y) { return y < x; }
1.140 - friend bool operator<=(const T& x, const T& y) { return !(y < x); }
1.141 - friend bool operator>=(const T& x, const T& y) { return !(x < y); }
1.142 -};
1.143 -
1.144 -template <class T, class U, class B = ::boost::detail::empty_base>
1.145 -struct equality_comparable2 : B
1.146 -{
1.147 - friend bool operator==(const U& y, const T& x) { return x == y; }
1.148 - friend bool operator!=(const U& y, const T& x) { return !(x == y); }
1.149 - friend bool operator!=(const T& y, const U& x) { return !(y == x); }
1.150 -};
1.151 -
1.152 -template <class T, class B = ::boost::detail::empty_base>
1.153 -struct equality_comparable1 : B
1.154 -{
1.155 - friend bool operator!=(const T& x, const T& y) { return !(x == y); }
1.156 -};
1.157 -
1.158 -// A macro which produces "name_2left" from "name".
1.159 -#define BOOST_OPERATOR2_LEFT(name) name##2##_##left
1.160 -
1.161 -// NRVO-friendly implementation (contributed by Daniel Frey) ---------------//
1.162 -
1.163 -#if defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
1.164 -
1.165 -// This is the optimal implementation for ISO/ANSI C++,
1.166 -// but it requires the compiler to implement the NRVO.
1.167 -// If the compiler has no NRVO, this is the best symmetric
1.168 -// implementation available.
1.169 -
1.170 -#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \
1.171 -template <class T, class U, class B = ::boost::detail::empty_base> \
1.172 -struct NAME##2 : B \
1.173 -{ \
1.174 - friend T operator OP( const T& lhs, const U& rhs ) \
1.175 - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \
1.176 - friend T operator OP( const U& lhs, const T& rhs ) \
1.177 - { T nrv( rhs ); nrv OP##= lhs; return nrv; } \
1.178 -}; \
1.179 - \
1.180 -template <class T, class B = ::boost::detail::empty_base> \
1.181 -struct NAME##1 : B \
1.182 -{ \
1.183 - friend T operator OP( const T& lhs, const T& rhs ) \
1.184 - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \
1.185 -};
1.186 -
1.187 -#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \
1.188 -template <class T, class U, class B = ::boost::detail::empty_base> \
1.189 -struct NAME##2 : B \
1.190 -{ \
1.191 - friend T operator OP( const T& lhs, const U& rhs ) \
1.192 - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \
1.193 -}; \
1.194 - \
1.195 -template <class T, class U, class B = ::boost::detail::empty_base> \
1.196 -struct BOOST_OPERATOR2_LEFT(NAME) : B \
1.197 -{ \
1.198 - friend T operator OP( const U& lhs, const T& rhs ) \
1.199 - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \
1.200 -}; \
1.201 - \
1.202 -template <class T, class B = ::boost::detail::empty_base> \
1.203 -struct NAME##1 : B \
1.204 -{ \
1.205 - friend T operator OP( const T& lhs, const T& rhs ) \
1.206 - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \
1.207 -};
1.208 -
1.209 -#else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
1.210 -
1.211 -// For compilers without NRVO the following code is optimal, but not
1.212 -// symmetric! Note that the implementation of
1.213 -// BOOST_OPERATOR2_LEFT(NAME) only looks cool, but doesn't provide
1.214 -// optimization opportunities to the compiler :)
1.215 -
1.216 -#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \
1.217 -template <class T, class U, class B = ::boost::detail::empty_base> \
1.218 -struct NAME##2 : B \
1.219 -{ \
1.220 - friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
1.221 - friend T operator OP( const U& lhs, T rhs ) { return rhs OP##= lhs; } \
1.222 -}; \
1.223 - \
1.224 -template <class T, class B = ::boost::detail::empty_base> \
1.225 -struct NAME##1 : B \
1.226 -{ \
1.227 - friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
1.228 -};
1.229 -
1.230 -#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \
1.231 -template <class T, class U, class B = ::boost::detail::empty_base> \
1.232 -struct NAME##2 : B \
1.233 -{ \
1.234 - friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
1.235 -}; \
1.236 - \
1.237 -template <class T, class U, class B = ::boost::detail::empty_base> \
1.238 -struct BOOST_OPERATOR2_LEFT(NAME) : B \
1.239 -{ \
1.240 - friend T operator OP( const U& lhs, const T& rhs ) \
1.241 - { return T( lhs ) OP##= rhs; } \
1.242 -}; \
1.243 - \
1.244 -template <class T, class B = ::boost::detail::empty_base> \
1.245 -struct NAME##1 : B \
1.246 -{ \
1.247 - friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
1.248 -};
1.249 -
1.250 -#endif // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
1.251 -
1.252 -BOOST_BINARY_OPERATOR_COMMUTATIVE( multipliable, * )
1.253 -BOOST_BINARY_OPERATOR_COMMUTATIVE( addable, + )
1.254 -BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( subtractable, - )
1.255 -BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( dividable, / )
1.256 -BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( modable, % )
1.257 -BOOST_BINARY_OPERATOR_COMMUTATIVE( xorable, ^ )
1.258 -BOOST_BINARY_OPERATOR_COMMUTATIVE( andable, & )
1.259 -BOOST_BINARY_OPERATOR_COMMUTATIVE( orable, | )
1.260 -
1.261 -#undef BOOST_BINARY_OPERATOR_COMMUTATIVE
1.262 -#undef BOOST_BINARY_OPERATOR_NON_COMMUTATIVE
1.263 -#undef BOOST_OPERATOR2_LEFT
1.264 -
1.265 -// incrementable and decrementable contributed by Jeremy Siek
1.266 -
1.267 -template <class T, class B = ::boost::detail::empty_base>
1.268 -struct incrementable : B
1.269 -{
1.270 - friend T operator++(T& x, int)
1.271 - {
1.272 - incrementable_type nrv(x);
1.273 - ++x;
1.274 - return nrv;
1.275 - }
1.276 -private: // The use of this typedef works around a Borland bug
1.277 - typedef T incrementable_type;
1.278 -};
1.279 -
1.280 -template <class T, class B = ::boost::detail::empty_base>
1.281 -struct decrementable : B
1.282 -{
1.283 - friend T operator--(T& x, int)
1.284 - {
1.285 - decrementable_type nrv(x);
1.286 - --x;
1.287 - return nrv;
1.288 - }
1.289 -private: // The use of this typedef works around a Borland bug
1.290 - typedef T decrementable_type;
1.291 -};
1.292 -
1.293 -// Iterator operator classes (contributed by Jeremy Siek) ------------------//
1.294 -
1.295 -template <class T, class P, class B = ::boost::detail::empty_base>
1.296 -struct dereferenceable : B
1.297 -{
1.298 - P operator->() const
1.299 - {
1.300 - return &*static_cast<const T&>(*this);
1.301 - }
1.302 -};
1.303 -
1.304 -template <class T, class I, class R, class B = ::boost::detail::empty_base>
1.305 -struct indexable : B
1.306 -{
1.307 - R operator[](I n) const
1.308 - {
1.309 - return *(static_cast<const T&>(*this) + n);
1.310 - }
1.311 -};
1.312 -
1.313 -// More operator classes (contributed by Daryle Walker) --------------------//
1.314 -// (NRVO-friendly implementation contributed by Daniel Frey) ---------------//
1.315 -
1.316 -#if defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
1.317 -
1.318 -#define BOOST_BINARY_OPERATOR( NAME, OP ) \
1.319 -template <class T, class U, class B = ::boost::detail::empty_base> \
1.320 -struct NAME##2 : B \
1.321 -{ \
1.322 - friend T operator OP( const T& lhs, const U& rhs ) \
1.323 - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \
1.324 -}; \
1.325 - \
1.326 -template <class T, class B = ::boost::detail::empty_base> \
1.327 -struct NAME##1 : B \
1.328 -{ \
1.329 - friend T operator OP( const T& lhs, const T& rhs ) \
1.330 - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \
1.331 -};
1.332 -
1.333 -#else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
1.334 -
1.335 -#define BOOST_BINARY_OPERATOR( NAME, OP ) \
1.336 -template <class T, class U, class B = ::boost::detail::empty_base> \
1.337 -struct NAME##2 : B \
1.338 -{ \
1.339 - friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
1.340 -}; \
1.341 - \
1.342 -template <class T, class B = ::boost::detail::empty_base> \
1.343 -struct NAME##1 : B \
1.344 -{ \
1.345 - friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
1.346 -};
1.347 -
1.348 -#endif // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
1.349 -
1.350 -BOOST_BINARY_OPERATOR( left_shiftable, << )
1.351 -BOOST_BINARY_OPERATOR( right_shiftable, >> )
1.352 -
1.353 -#undef BOOST_BINARY_OPERATOR
1.354 -
1.355 -template <class T, class U, class B = ::boost::detail::empty_base>
1.356 -struct equivalent2 : B
1.357 -{
1.358 - friend bool operator==(const T& x, const U& y)
1.359 - {
1.360 - return !(x < y) && !(x > y);
1.361 - }
1.362 -};
1.363 -
1.364 -template <class T, class B = ::boost::detail::empty_base>
1.365 -struct equivalent1 : B
1.366 -{
1.367 - friend bool operator==(const T&x, const T&y)
1.368 - {
1.369 - return !(x < y) && !(y < x);
1.370 - }
1.371 -};
1.372 -
1.373 -template <class T, class U, class B = ::boost::detail::empty_base>
1.374 -struct partially_ordered2 : B
1.375 -{
1.376 - friend bool operator<=(const T& x, const U& y)
1.377 - { return (x < y) || (x == y); }
1.378 - friend bool operator>=(const T& x, const U& y)
1.379 - { return (x > y) || (x == y); }
1.380 - friend bool operator>(const U& x, const T& y)
1.381 - { return y < x; }
1.382 - friend bool operator<(const U& x, const T& y)
1.383 - { return y > x; }
1.384 - friend bool operator<=(const U& x, const T& y)
1.385 - { return (y > x) || (y == x); }
1.386 - friend bool operator>=(const U& x, const T& y)
1.387 - { return (y < x) || (y == x); }
1.388 -};
1.389 -
1.390 -template <class T, class B = ::boost::detail::empty_base>
1.391 -struct partially_ordered1 : B
1.392 -{
1.393 - friend bool operator>(const T& x, const T& y)
1.394 - { return y < x; }
1.395 - friend bool operator<=(const T& x, const T& y)
1.396 - { return (x < y) || (x == y); }
1.397 - friend bool operator>=(const T& x, const T& y)
1.398 - { return (y < x) || (x == y); }
1.399 -};
1.400 -
1.401 -// Combined operator classes (contributed by Daryle Walker) ----------------//
1.402 -
1.403 -template <class T, class U, class B = ::boost::detail::empty_base>
1.404 -struct totally_ordered2
1.405 - : less_than_comparable2<T, U
1.406 - , equality_comparable2<T, U, B
1.407 - > > {};
1.408 -
1.409 -template <class T, class B = ::boost::detail::empty_base>
1.410 -struct totally_ordered1
1.411 - : less_than_comparable1<T
1.412 - , equality_comparable1<T, B
1.413 - > > {};
1.414 -
1.415 -template <class T, class U, class B = ::boost::detail::empty_base>
1.416 -struct additive2
1.417 - : addable2<T, U
1.418 - , subtractable2<T, U, B
1.419 - > > {};
1.420 -
1.421 -template <class T, class B = ::boost::detail::empty_base>
1.422 -struct additive1
1.423 - : addable1<T
1.424 - , subtractable1<T, B
1.425 - > > {};
1.426 -
1.427 -template <class T, class U, class B = ::boost::detail::empty_base>
1.428 -struct multiplicative2
1.429 - : multipliable2<T, U
1.430 - , dividable2<T, U, B
1.431 - > > {};
1.432 -
1.433 -template <class T, class B = ::boost::detail::empty_base>
1.434 -struct multiplicative1
1.435 - : multipliable1<T
1.436 - , dividable1<T, B
1.437 - > > {};
1.438 -
1.439 -template <class T, class U, class B = ::boost::detail::empty_base>
1.440 -struct integer_multiplicative2
1.441 - : multiplicative2<T, U
1.442 - , modable2<T, U, B
1.443 - > > {};
1.444 -
1.445 -template <class T, class B = ::boost::detail::empty_base>
1.446 -struct integer_multiplicative1
1.447 - : multiplicative1<T
1.448 - , modable1<T, B
1.449 - > > {};
1.450 -
1.451 -template <class T, class U, class B = ::boost::detail::empty_base>
1.452 -struct arithmetic2
1.453 - : additive2<T, U
1.454 - , multiplicative2<T, U, B
1.455 - > > {};
1.456 -
1.457 -template <class T, class B = ::boost::detail::empty_base>
1.458 -struct arithmetic1
1.459 - : additive1<T
1.460 - , multiplicative1<T, B
1.461 - > > {};
1.462 -
1.463 -template <class T, class U, class B = ::boost::detail::empty_base>
1.464 -struct integer_arithmetic2
1.465 - : additive2<T, U
1.466 - , integer_multiplicative2<T, U, B
1.467 - > > {};
1.468 -
1.469 -template <class T, class B = ::boost::detail::empty_base>
1.470 -struct integer_arithmetic1
1.471 - : additive1<T
1.472 - , integer_multiplicative1<T, B
1.473 - > > {};
1.474 -
1.475 -template <class T, class U, class B = ::boost::detail::empty_base>
1.476 -struct bitwise2
1.477 - : xorable2<T, U
1.478 - , andable2<T, U
1.479 - , orable2<T, U, B
1.480 - > > > {};
1.481 -
1.482 -template <class T, class B = ::boost::detail::empty_base>
1.483 -struct bitwise1
1.484 - : xorable1<T
1.485 - , andable1<T
1.486 - , orable1<T, B
1.487 - > > > {};
1.488 -
1.489 -template <class T, class B = ::boost::detail::empty_base>
1.490 -struct unit_steppable
1.491 - : incrementable<T
1.492 - , decrementable<T, B
1.493 - > > {};
1.494 -
1.495 -template <class T, class U, class B = ::boost::detail::empty_base>
1.496 -struct shiftable2
1.497 - : left_shiftable2<T, U
1.498 - , right_shiftable2<T, U, B
1.499 - > > {};
1.500 -
1.501 -template <class T, class B = ::boost::detail::empty_base>
1.502 -struct shiftable1
1.503 - : left_shiftable1<T
1.504 - , right_shiftable1<T, B
1.505 - > > {};
1.506 -
1.507 -template <class T, class U, class B = ::boost::detail::empty_base>
1.508 -struct ring_operators2
1.509 - : additive2<T, U
1.510 - , subtractable2_left<T, U
1.511 - , multipliable2<T, U, B
1.512 - > > > {};
1.513 -
1.514 -template <class T, class B = ::boost::detail::empty_base>
1.515 -struct ring_operators1
1.516 - : additive1<T
1.517 - , multipliable1<T, B
1.518 - > > {};
1.519 -
1.520 -template <class T, class U, class B = ::boost::detail::empty_base>
1.521 -struct ordered_ring_operators2
1.522 - : ring_operators2<T, U
1.523 - , totally_ordered2<T, U, B
1.524 - > > {};
1.525 -
1.526 -template <class T, class B = ::boost::detail::empty_base>
1.527 -struct ordered_ring_operators1
1.528 - : ring_operators1<T
1.529 - , totally_ordered1<T, B
1.530 - > > {};
1.531 -
1.532 -template <class T, class U, class B = ::boost::detail::empty_base>
1.533 -struct field_operators2
1.534 - : ring_operators2<T, U
1.535 - , dividable2<T, U
1.536 - , dividable2_left<T, U, B
1.537 - > > > {};
1.538 -
1.539 -template <class T, class B = ::boost::detail::empty_base>
1.540 -struct field_operators1
1.541 - : ring_operators1<T
1.542 - , dividable1<T, B
1.543 - > > {};
1.544 -
1.545 -template <class T, class U, class B = ::boost::detail::empty_base>
1.546 -struct ordered_field_operators2
1.547 - : field_operators2<T, U
1.548 - , totally_ordered2<T, U, B
1.549 - > > {};
1.550 -
1.551 -template <class T, class B = ::boost::detail::empty_base>
1.552 -struct ordered_field_operators1
1.553 - : field_operators1<T
1.554 - , totally_ordered1<T, B
1.555 - > > {};
1.556 -
1.557 -template <class T, class U, class B = ::boost::detail::empty_base>
1.558 -struct euclidian_ring_operators2
1.559 - : ring_operators2<T, U
1.560 - , dividable2<T, U
1.561 - , dividable2_left<T, U
1.562 - , modable2<T, U
1.563 - , modable2_left<T, U, B
1.564 - > > > > > {};
1.565 -
1.566 -template <class T, class B = ::boost::detail::empty_base>
1.567 -struct euclidian_ring_operators1
1.568 - : ring_operators1<T
1.569 - , dividable1<T
1.570 - , modable1<T, B
1.571 - > > > {};
1.572 -
1.573 -template <class T, class U, class B = ::boost::detail::empty_base>
1.574 -struct ordered_euclidian_ring_operators2
1.575 - : totally_ordered2<T, U
1.576 - , euclidian_ring_operators2<T, U, B
1.577 - > > {};
1.578 -
1.579 -template <class T, class B = ::boost::detail::empty_base>
1.580 -struct ordered_euclidian_ring_operators1
1.581 - : totally_ordered1<T
1.582 - , euclidian_ring_operators1<T, B
1.583 - > > {};
1.584 -
1.585 -template <class T, class P, class B = ::boost::detail::empty_base>
1.586 -struct input_iteratable
1.587 - : equality_comparable1<T
1.588 - , incrementable<T
1.589 - , dereferenceable<T, P, B
1.590 - > > > {};
1.591 -
1.592 -template <class T, class B = ::boost::detail::empty_base>
1.593 -struct output_iteratable
1.594 - : incrementable<T, B
1.595 - > {};
1.596 -
1.597 -template <class T, class P, class B = ::boost::detail::empty_base>
1.598 -struct forward_iteratable
1.599 - : input_iteratable<T, P, B
1.600 - > {};
1.601 -
1.602 -template <class T, class P, class B = ::boost::detail::empty_base>
1.603 -struct bidirectional_iteratable
1.604 - : forward_iteratable<T, P
1.605 - , decrementable<T, B
1.606 - > > {};
1.607 -
1.608 -// To avoid repeated derivation from equality_comparable,
1.609 -// which is an indirect base class of bidirectional_iterable,
1.610 -// random_access_iteratable must not be derived from totally_ordered1
1.611 -// but from less_than_comparable1 only. (Helmut Zeisel, 02-Dec-2001)
1.612 -template <class T, class P, class D, class R, class B = ::boost::detail::empty_base>
1.613 -struct random_access_iteratable
1.614 - : bidirectional_iteratable<T, P
1.615 - , less_than_comparable1<T
1.616 - , additive2<T, D
1.617 - , indexable<T, D, R, B
1.618 - > > > > {};
1.619 -
1.620 -#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
1.621 -} // namespace boost
1.622 -#endif // BOOST_NO_OPERATORS_IN_NAMESPACE
1.623 -
1.624 -
1.625 -// BOOST_IMPORT_TEMPLATE1 .. BOOST_IMPORT_TEMPLATE4 -
1.626 -//
1.627 -// When BOOST_NO_OPERATORS_IN_NAMESPACE is defined we need a way to import an
1.628 -// operator template into the boost namespace. BOOST_IMPORT_TEMPLATE1 is used
1.629 -// for one-argument forms of operator templates; BOOST_IMPORT_TEMPLATE2 for
1.630 -// two-argument forms. Note that these macros expect to be invoked from within
1.631 -// boost.
1.632 -
1.633 -#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
1.634 -
1.635 - // The template is already in boost so we have nothing to do.
1.636 -# define BOOST_IMPORT_TEMPLATE4(template_name)
1.637 -# define BOOST_IMPORT_TEMPLATE3(template_name)
1.638 -# define BOOST_IMPORT_TEMPLATE2(template_name)
1.639 -# define BOOST_IMPORT_TEMPLATE1(template_name)
1.640 -
1.641 -#else // BOOST_NO_OPERATORS_IN_NAMESPACE
1.642 -
1.643 -# ifndef BOOST_NO_USING_TEMPLATE
1.644 -
1.645 - // Bring the names in with a using-declaration
1.646 - // to avoid stressing the compiler.
1.647 -# define BOOST_IMPORT_TEMPLATE4(template_name) using ::template_name;
1.648 -# define BOOST_IMPORT_TEMPLATE3(template_name) using ::template_name;
1.649 -# define BOOST_IMPORT_TEMPLATE2(template_name) using ::template_name;
1.650 -# define BOOST_IMPORT_TEMPLATE1(template_name) using ::template_name;
1.651 -
1.652 -# else
1.653 -
1.654 - // Otherwise, because a Borland C++ 5.5 bug prevents a using declaration
1.655 - // from working, we are forced to use inheritance for that compiler.
1.656 -# define BOOST_IMPORT_TEMPLATE4(template_name) \
1.657 - template <class T, class U, class V, class W, class B = ::boost::detail::empty_base> \
1.658 - struct template_name : ::template_name<T, U, V, W, B> {};
1.659 -
1.660 -# define BOOST_IMPORT_TEMPLATE3(template_name) \
1.661 - template <class T, class U, class V, class B = ::boost::detail::empty_base> \
1.662 - struct template_name : ::template_name<T, U, V, B> {};
1.663 -
1.664 -# define BOOST_IMPORT_TEMPLATE2(template_name) \
1.665 - template <class T, class U, class B = ::boost::detail::empty_base> \
1.666 - struct template_name : ::template_name<T, U, B> {};
1.667 -
1.668 -# define BOOST_IMPORT_TEMPLATE1(template_name) \
1.669 - template <class T, class B = ::boost::detail::empty_base> \
1.670 - struct template_name : ::template_name<T, B> {};
1.671 -
1.672 -# endif // BOOST_NO_USING_TEMPLATE
1.673 -
1.674 -#endif // BOOST_NO_OPERATORS_IN_NAMESPACE
1.675 -
1.676 -//
1.677 -// Here's where we put it all together, defining the xxxx forms of the templates
1.678 -// in namespace boost. We also define specializations of is_chained_base<> for
1.679 -// the xxxx, xxxx1, and xxxx2 templates, importing them into boost:: as
1.680 -// necessary.
1.681 -//
1.682 -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
1.683 -
1.684 -// is_chained_base<> - a traits class used to distinguish whether an operator
1.685 -// template argument is being used for base class chaining, or is specifying a
1.686 -// 2nd argument type.
1.687 -
1.688 -namespace boost {
1.689 -// A type parameter is used instead of a plain bool because Borland's compiler
1.690 -// didn't cope well with the more obvious non-type template parameter.
1.691 -namespace detail {
1.692 - struct true_t {};
1.693 - struct false_t {};
1.694 -} // namespace detail
1.695 -
1.696 -// Unspecialized version assumes that most types are not being used for base
1.697 -// class chaining. We specialize for the operator templates defined in this
1.698 -// library.
1.699 -template<class T> struct is_chained_base {
1.700 - typedef ::boost::detail::false_t value;
1.701 -};
1.702 -
1.703 -} // namespace boost
1.704 -
1.705 -// Import a 4-type-argument operator template into boost (if necessary) and
1.706 -// provide a specialization of 'is_chained_base<>' for it.
1.707 -# define BOOST_OPERATOR_TEMPLATE4(template_name4) \
1.708 - BOOST_IMPORT_TEMPLATE4(template_name4) \
1.709 - template<class T, class U, class V, class W, class B> \
1.710 - struct is_chained_base< ::boost::template_name4<T, U, V, W, B> > { \
1.711 - typedef ::boost::detail::true_t value; \
1.712 - };
1.713 -
1.714 -// Import a 3-type-argument operator template into boost (if necessary) and
1.715 -// provide a specialization of 'is_chained_base<>' for it.
1.716 -# define BOOST_OPERATOR_TEMPLATE3(template_name3) \
1.717 - BOOST_IMPORT_TEMPLATE3(template_name3) \
1.718 - template<class T, class U, class V, class B> \
1.719 - struct is_chained_base< ::boost::template_name3<T, U, V, B> > { \
1.720 - typedef ::boost::detail::true_t value; \
1.721 - };
1.722 -
1.723 -// Import a 2-type-argument operator template into boost (if necessary) and
1.724 -// provide a specialization of 'is_chained_base<>' for it.
1.725 -# define BOOST_OPERATOR_TEMPLATE2(template_name2) \
1.726 - BOOST_IMPORT_TEMPLATE2(template_name2) \
1.727 - template<class T, class U, class B> \
1.728 - struct is_chained_base< ::boost::template_name2<T, U, B> > { \
1.729 - typedef ::boost::detail::true_t value; \
1.730 - };
1.731 -
1.732 -// Import a 1-type-argument operator template into boost (if necessary) and
1.733 -// provide a specialization of 'is_chained_base<>' for it.
1.734 -# define BOOST_OPERATOR_TEMPLATE1(template_name1) \
1.735 - BOOST_IMPORT_TEMPLATE1(template_name1) \
1.736 - template<class T, class B> \
1.737 - struct is_chained_base< ::boost::template_name1<T, B> > { \
1.738 - typedef ::boost::detail::true_t value; \
1.739 - };
1.740 -
1.741 -// BOOST_OPERATOR_TEMPLATE(template_name) defines template_name<> such that it
1.742 -// can be used for specifying both 1-argument and 2-argument forms. Requires the
1.743 -// existence of two previously defined class templates named '<template_name>1'
1.744 -// and '<template_name>2' which must implement the corresponding 1- and 2-
1.745 -// argument forms.
1.746 -//
1.747 -// The template type parameter O == is_chained_base<U>::value is used to
1.748 -// distinguish whether the 2nd argument to <template_name> is being used for
1.749 -// base class chaining from another boost operator template or is describing a
1.750 -// 2nd operand type. O == true_t only when U is actually an another operator
1.751 -// template from the library. Partial specialization is used to select an
1.752 -// implementation in terms of either '<template_name>1' or '<template_name>2'.
1.753 -//
1.754 -
1.755 -# define BOOST_OPERATOR_TEMPLATE(template_name) \
1.756 -template <class T \
1.757 - ,class U = T \
1.758 - ,class B = ::boost::detail::empty_base \
1.759 - ,class O = typename is_chained_base<U>::value \
1.760 - > \
1.761 -struct template_name : template_name##2<T, U, B> {}; \
1.762 - \
1.763 -template<class T, class U, class B> \
1.764 -struct template_name<T, U, B, ::boost::detail::true_t> \
1.765 - : template_name##1<T, U> {}; \
1.766 - \
1.767 -template <class T, class B> \
1.768 -struct template_name<T, T, B, ::boost::detail::false_t> \
1.769 - : template_name##1<T, B> {}; \
1.770 - \
1.771 -template<class T, class U, class B, class O> \
1.772 -struct is_chained_base< ::boost::template_name<T, U, B, O> > { \
1.773 - typedef ::boost::detail::true_t value; \
1.774 -}; \
1.775 - \
1.776 -BOOST_OPERATOR_TEMPLATE2(template_name##2) \
1.777 -BOOST_OPERATOR_TEMPLATE1(template_name##1)
1.778 -
1.779 -
1.780 -#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
1.781 -
1.782 -# define BOOST_OPERATOR_TEMPLATE4(template_name4) \
1.783 - BOOST_IMPORT_TEMPLATE4(template_name4)
1.784 -# define BOOST_OPERATOR_TEMPLATE3(template_name3) \
1.785 - BOOST_IMPORT_TEMPLATE3(template_name3)
1.786 -# define BOOST_OPERATOR_TEMPLATE2(template_name2) \
1.787 - BOOST_IMPORT_TEMPLATE2(template_name2)
1.788 -# define BOOST_OPERATOR_TEMPLATE1(template_name1) \
1.789 - BOOST_IMPORT_TEMPLATE1(template_name1)
1.790 -
1.791 - // In this case we can only assume that template_name<> is equivalent to the
1.792 - // more commonly needed template_name1<> form.
1.793 -# define BOOST_OPERATOR_TEMPLATE(template_name) \
1.794 - template <class T, class B = ::boost::detail::empty_base> \
1.795 - struct template_name : template_name##1<T, B> {};
1.796 -
1.797 -#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
1.798 -
1.799 -namespace boost {
1.800 -
1.801 -BOOST_OPERATOR_TEMPLATE(less_than_comparable)
1.802 -BOOST_OPERATOR_TEMPLATE(equality_comparable)
1.803 -BOOST_OPERATOR_TEMPLATE(multipliable)
1.804 -BOOST_OPERATOR_TEMPLATE(addable)
1.805 -BOOST_OPERATOR_TEMPLATE(subtractable)
1.806 -BOOST_OPERATOR_TEMPLATE2(subtractable2_left)
1.807 -BOOST_OPERATOR_TEMPLATE(dividable)
1.808 -BOOST_OPERATOR_TEMPLATE2(dividable2_left)
1.809 -BOOST_OPERATOR_TEMPLATE(modable)
1.810 -BOOST_OPERATOR_TEMPLATE2(modable2_left)
1.811 -BOOST_OPERATOR_TEMPLATE(xorable)
1.812 -BOOST_OPERATOR_TEMPLATE(andable)
1.813 -BOOST_OPERATOR_TEMPLATE(orable)
1.814 -
1.815 -BOOST_OPERATOR_TEMPLATE1(incrementable)
1.816 -BOOST_OPERATOR_TEMPLATE1(decrementable)
1.817 -
1.818 -BOOST_OPERATOR_TEMPLATE2(dereferenceable)
1.819 -BOOST_OPERATOR_TEMPLATE3(indexable)
1.820 -
1.821 -BOOST_OPERATOR_TEMPLATE(left_shiftable)
1.822 -BOOST_OPERATOR_TEMPLATE(right_shiftable)
1.823 -BOOST_OPERATOR_TEMPLATE(equivalent)
1.824 -BOOST_OPERATOR_TEMPLATE(partially_ordered)
1.825 -
1.826 -BOOST_OPERATOR_TEMPLATE(totally_ordered)
1.827 -BOOST_OPERATOR_TEMPLATE(additive)
1.828 -BOOST_OPERATOR_TEMPLATE(multiplicative)
1.829 -BOOST_OPERATOR_TEMPLATE(integer_multiplicative)
1.830 -BOOST_OPERATOR_TEMPLATE(arithmetic)
1.831 -BOOST_OPERATOR_TEMPLATE(integer_arithmetic)
1.832 -BOOST_OPERATOR_TEMPLATE(bitwise)
1.833 -BOOST_OPERATOR_TEMPLATE1(unit_steppable)
1.834 -BOOST_OPERATOR_TEMPLATE(shiftable)
1.835 -BOOST_OPERATOR_TEMPLATE(ring_operators)
1.836 -BOOST_OPERATOR_TEMPLATE(ordered_ring_operators)
1.837 -BOOST_OPERATOR_TEMPLATE(field_operators)
1.838 -BOOST_OPERATOR_TEMPLATE(ordered_field_operators)
1.839 -BOOST_OPERATOR_TEMPLATE(euclidian_ring_operators)
1.840 -BOOST_OPERATOR_TEMPLATE(ordered_euclidian_ring_operators)
1.841 -BOOST_OPERATOR_TEMPLATE2(input_iteratable)
1.842 -BOOST_OPERATOR_TEMPLATE1(output_iteratable)
1.843 -BOOST_OPERATOR_TEMPLATE2(forward_iteratable)
1.844 -BOOST_OPERATOR_TEMPLATE2(bidirectional_iteratable)
1.845 -BOOST_OPERATOR_TEMPLATE4(random_access_iteratable)
1.846 -
1.847 -#undef BOOST_OPERATOR_TEMPLATE
1.848 -#undef BOOST_OPERATOR_TEMPLATE4
1.849 -#undef BOOST_OPERATOR_TEMPLATE3
1.850 -#undef BOOST_OPERATOR_TEMPLATE2
1.851 -#undef BOOST_OPERATOR_TEMPLATE1
1.852 -#undef BOOST_IMPORT_TEMPLATE1
1.853 -#undef BOOST_IMPORT_TEMPLATE2
1.854 -#undef BOOST_IMPORT_TEMPLATE3
1.855 -#undef BOOST_IMPORT_TEMPLATE4
1.856 -
1.857 -// The following 'operators' classes can only be used portably if the derived class
1.858 -// declares ALL of the required member operators.
1.859 -template <class T, class U>
1.860 -struct operators2
1.861 - : totally_ordered2<T,U
1.862 - , integer_arithmetic2<T,U
1.863 - , bitwise2<T,U
1.864 - > > > {};
1.865 -
1.866 -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
1.867 -template <class T, class U = T>
1.868 -struct operators : operators2<T, U> {};
1.869 -
1.870 -template <class T> struct operators<T, T>
1.871 -#else
1.872 -template <class T> struct operators
1.873 -#endif
1.874 - : totally_ordered<T
1.875 - , integer_arithmetic<T
1.876 - , bitwise<T
1.877 - , unit_steppable<T
1.878 - > > > > {};
1.879 -
1.880 -// Iterator helper classes (contributed by Jeremy Siek) -------------------//
1.881 -// (Input and output iterator helpers contributed by Daryle Walker) -------//
1.882 -// (Changed to use combined operator classes by Daryle Walker) ------------//
1.883 -template <class T,
1.884 - class V,
1.885 - class D = std::ptrdiff_t,
1.886 - class P = V const *,
1.887 - class R = V const &>
1.888 -struct input_iterator_helper
1.889 - : input_iteratable<T, P
1.890 - , boost::iterator<std::input_iterator_tag, V, D, P, R
1.891 - > > {};
1.892 -
1.893 -template<class T>
1.894 -struct output_iterator_helper
1.895 - : output_iteratable<T
1.896 - , boost::iterator<std::output_iterator_tag, void, void, void, void
1.897 - > >
1.898 -{
1.899 - T& operator*() { return static_cast<T&>(*this); }
1.900 - T& operator++() { return static_cast<T&>(*this); }
1.901 -};
1.902 -
1.903 -template <class T,
1.904 - class V,
1.905 - class D = std::ptrdiff_t,
1.906 - class P = V*,
1.907 - class R = V&>
1.908 -struct forward_iterator_helper
1.909 - : forward_iteratable<T, P
1.910 - , boost::iterator<std::forward_iterator_tag, V, D, P, R
1.911 - > > {};
1.912 -
1.913 -template <class T,
1.914 - class V,
1.915 - class D = std::ptrdiff_t,
1.916 - class P = V*,
1.917 - class R = V&>
1.918 -struct bidirectional_iterator_helper
1.919 - : bidirectional_iteratable<T, P
1.920 - , boost::iterator<std::bidirectional_iterator_tag, V, D, P, R
1.921 - > > {};
1.922 -
1.923 -template <class T,
1.924 - class V,
1.925 - class D = std::ptrdiff_t,
1.926 - class P = V*,
1.927 - class R = V&>
1.928 -struct random_access_iterator_helper
1.929 - : random_access_iteratable<T, P, D, R
1.930 - , boost::iterator<std::random_access_iterator_tag, V, D, P, R
1.931 - > >
1.932 -{
1.933 - friend D requires_difference_operator(const T& x, const T& y) {
1.934 - return x - y;
1.935 - }
1.936 -}; // random_access_iterator_helper
1.937 -
1.938 -} // namespace boost
1.939 -
1.940 -#if defined(__sgi) && !defined(__GNUC__)
1.941 -#pragma reset woff 1234
1.942 -#endif
1.943 -
1.944 -#endif // BOOST_OPERATORS_HPP