From 211eb04f3376d7d0b62ac6560acb976a569d2b68 Mon Sep 17 00:00:00 2001 From: Daniel Frey Date: Fri, 22 May 2009 09:00:11 +0000 Subject: [PATCH] Merge [44151], [48025] to release. Closes #3064. [SVN r53172] --- include/boost/operators.hpp | 69 ++++-- operators.htm | 38 ++-- operators_test.cpp | 408 ++++++++++++++++++++---------------- 3 files changed, 300 insertions(+), 215 deletions(-) diff --git a/include/boost/operators.hpp b/include/boost/operators.hpp index b3b1bd7..4b47ba4 100644 --- a/include/boost/operators.hpp +++ b/include/boost/operators.hpp @@ -8,6 +8,9 @@ // See http://www.boost.org/libs/utility/operators.htm for documentation. // Revision History +// 07 Aug 08 Added "euclidean" spelling. (Daniel Frey) +// 03 Apr 08 Make sure "convertible to bool" is sufficient +// for T::operator<, etc. (Daniel Frey) // 24 May 07 Changed empty_base to depend on T, see // http://svn.boost.org/trac/boost/ticket/979 // 21 Oct 02 Modified implementation of operators to allow compilers with a @@ -124,34 +127,34 @@ namespace boost template > struct less_than_comparable2 : B { - friend bool operator<=(const T& x, const U& y) { return !(x > y); } - friend bool operator>=(const T& x, const U& y) { return !(x < y); } + friend bool operator<=(const T& x, const U& y) { return !static_cast(x > y); } + friend bool operator>=(const T& x, const U& y) { return !static_cast(x < y); } friend bool operator>(const U& x, const T& y) { return y < x; } friend bool operator<(const U& x, const T& y) { return y > x; } - friend bool operator<=(const U& x, const T& y) { return !(y < x); } - friend bool operator>=(const U& x, const T& y) { return !(y > x); } + friend bool operator<=(const U& x, const T& y) { return !static_cast(y < x); } + friend bool operator>=(const U& x, const T& y) { return !static_cast(y > x); } }; template > struct less_than_comparable1 : B { friend bool operator>(const T& x, const T& y) { return y < x; } - friend bool operator<=(const T& x, const T& y) { return !(y < x); } - friend bool operator>=(const T& x, const T& y) { return !(x < y); } + friend bool operator<=(const T& x, const T& y) { return !static_cast(y < x); } + friend bool operator>=(const T& x, const T& y) { return !static_cast(x < y); } }; template > struct equality_comparable2 : B { friend bool operator==(const U& y, const T& x) { return x == y; } - friend bool operator!=(const U& y, const T& x) { return !(x == y); } - friend bool operator!=(const T& y, const U& x) { return !(y == x); } + friend bool operator!=(const U& y, const T& x) { return !static_cast(x == y); } + friend bool operator!=(const T& y, const U& x) { return !static_cast(y == x); } }; template > struct equality_comparable1 : B { - friend bool operator!=(const T& x, const T& y) { return !(x == y); } + friend bool operator!=(const T& x, const T& y) { return !static_cast(x == y); } }; // A macro which produces "name_2left" from "name". @@ -356,7 +359,7 @@ struct equivalent2 : B { friend bool operator==(const T& x, const U& y) { - return !(x < y) && !(x > y); + return !static_cast(x < y) && !static_cast(x > y); } }; @@ -365,7 +368,7 @@ struct equivalent1 : B { friend bool operator==(const T&x, const T&y) { - return !(x < y) && !(y < x); + return !static_cast(x < y) && !static_cast(y < x); } }; @@ -373,17 +376,17 @@ template > struct partially_ordered2 : B { friend bool operator<=(const T& x, const U& y) - { return (x < y) || (x == y); } + { return static_cast(x < y) || static_cast(x == y); } friend bool operator>=(const T& x, const U& y) - { return (x > y) || (x == y); } + { return static_cast(x > y) || static_cast(x == y); } friend bool operator>(const U& x, const T& y) { return y < x; } friend bool operator<(const U& x, const T& y) { return y > x; } friend bool operator<=(const U& x, const T& y) - { return (y > x) || (y == x); } + { return static_cast(y > x) || static_cast(y == x); } friend bool operator>=(const U& x, const T& y) - { return (y < x) || (y == x); } + { return static_cast(y < x) || static_cast(y == x); } }; template > @@ -392,9 +395,9 @@ struct partially_ordered1 : B friend bool operator>(const T& x, const T& y) { return y < x; } friend bool operator<=(const T& x, const T& y) - { return (x < y) || (x == y); } + { return static_cast(x < y) || static_cast(x == y); } friend bool operator>=(const T& x, const T& y) - { return (y < x) || (x == y); } + { return static_cast(y < x) || static_cast(x == y); } }; // Combined operator classes (contributed by Daryle Walker) ----------------// @@ -580,7 +583,35 @@ struct ordered_euclidian_ring_operators1 : totally_ordered1 > {}; - + +template > +struct euclidean_ring_operators2 + : ring_operators2 > > > > {}; + +template > +struct euclidean_ring_operators1 + : ring_operators1 > > {}; + +template > +struct ordered_euclidean_ring_operators2 + : totally_ordered2 > {}; + +template > +struct ordered_euclidean_ring_operators1 + : totally_ordered1 > {}; + template > struct input_iteratable : equality_comparable1 euclidian_ring_operators<T>
+ "euclidean_ring_operators1">euclidean_ring_operators<T>
- euclidian_ring_operators1<T> + euclidean_ring_operators1<T>
    @@ -1439,9 +1439,9 @@ T operator+( T lhs, const T& rhs ) euclidian_ring_operators<T, + "euclidean_ring_operators2">euclidean_ring_operators<T, U>
    - euclidian_ring_operators2<T, U> + euclidean_ring_operators2<T, U>
      @@ -1464,14 +1464,14 @@ T operator+( T lhs, const T& rhs ) ordered_euclidian_ring_operators<T>
      + "ordered_euclidean_ring_operators1">ordered_euclidean_ring_operators<T>
      - ordered_euclidian_ring_operators1<T> + ordered_euclidean_ring_operators1<T>
      • euclidian_ring_operators<T>
      • + "#euclidean_ring_operators1">euclidean_ring_operators<T>
      • totally_ordered<T>
      • @@ -1481,14 +1481,14 @@ T operator+( T lhs, const T& rhs ) ordered_euclidian_ring_operators<T, + "ordered_euclidean_ring_operators2">ordered_euclidean_ring_operators<T, U>
        - ordered_euclidian_ring_operators2<T, U> + ordered_euclidean_ring_operators2<T, U>
        • euclidian_ring_operators<T, + "#euclidean_ring_operators2">euclidean_ring_operators<T, U>
        • totally_ordered<T, @@ -1498,6 +1498,15 @@ T operator+( T lhs, const T& rhs ) +

          Spelling: euclidean vs. euclidian

          + +

          Older versions of the Boost.Operators library used + "euclidian", but it was pointed out that + "euclidean" is the more common spelling. + To be compatible with older version, the library now supports + both spellings. +

          +

          Example Templates

          The arithmetic operator class templates The operators_test.cpp program demonstrates the use of the arithmetic operator templates, and - can also be used to verify correct operation. Check the compiler status report for the - test results with selected platforms.

          + can also be used to verify correct operation. Check the compiler status + report for the test results with selected platforms.

          Dereference Operators and Iterator Helpers

          @@ -2119,10 +2127,10 @@ public: backward-compatible.


          -

          Revised: 29 Oct 2004

          +

          Revised: 7 Aug 2008

          Copyright © Beman Dawes, David Abrahams, 1999-2001.

          -

          Copyright © Daniel Frey, 2002-2004.

          +

          Copyright © Daniel Frey, 2002-2008.

          Use, modification, and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/operators_test.cpp b/operators_test.cpp index d42cb6a..5b71f3a 100644 --- a/operators_test.cpp +++ b/operators_test.cpp @@ -7,6 +7,7 @@ // See http://www.boost.org/libs/utility for documentation. // Revision History +// 03 Apr 08 Added convertible_to_bool (Daniel Frey) // 01 Oct 01 Added tests for "left" operators // and new grouped operators. (Helmut Zeisel) // 20 May 01 Output progress messages. Added tests for new operator @@ -43,6 +44,23 @@ namespace unsigned char true_value(unsigned char x) { return x; } unsigned short true_value(unsigned short x) { return x; } + // verify the minimum requirements for some operators + class convertible_to_bool + { + private: + bool _value; + + typedef bool convertible_to_bool::*unspecified_bool_type; + + void operator!() const; + + public: + convertible_to_bool( const bool value ) : _value( value ) {} + + operator unspecified_bool_type() const + { return _value ? &convertible_to_bool::_value : 0; } + }; + // The use of operators<> here tended to obscure // interactions with certain compiler bugs template @@ -54,8 +72,10 @@ namespace explicit Wrapped1( T v = T() ) : _value(v) {} T value() const { return _value; } - bool operator<(const Wrapped1& x) const { return _value < x._value; } - bool operator==(const Wrapped1& x) const { return _value == x._value; } + convertible_to_bool operator<(const Wrapped1& x) const + { return _value < x._value; } + convertible_to_bool operator==(const Wrapped1& x) const + { return _value == x._value; } Wrapped1& operator+=(const Wrapped1& x) { _value += x._value; return *this; } @@ -97,8 +117,10 @@ namespace explicit Wrapped2( T v = T() ) : _value(v) {} T value() const { return _value; } - bool operator<(const Wrapped2& x) const { return _value < x._value; } - bool operator==(const Wrapped2& x) const { return _value == x._value; } + convertible_to_bool operator<(const Wrapped2& x) const + { return _value < x._value; } + convertible_to_bool operator==(const Wrapped2& x) const + { return _value == x._value; } Wrapped2& operator+=(const Wrapped2& x) { _value += x._value; return *this; } @@ -123,9 +145,13 @@ namespace Wrapped2& operator++() { ++_value; return *this; } Wrapped2& operator--() { --_value; return *this; } - bool operator<(U u) const { return _value < u; } - bool operator>(U u) const { return _value > u; } - bool operator==(U u) const { return _value == u; } + convertible_to_bool operator<(U u) const + { return _value < u; } + convertible_to_bool operator>(U u) const + { return _value > u; } + convertible_to_bool operator==(U u) const + { return _value == u; } + Wrapped2& operator+=(U u) { _value += u; return *this; } Wrapped2& operator-=(U u) { _value -= u; return *this; } Wrapped2& operator*=(U u) { _value *= u; return *this; } @@ -153,7 +179,8 @@ namespace explicit Wrapped3( T v = T() ) : _value(v) {} T value() const { return _value; } - bool operator<(const Wrapped3& x) const { return _value < x._value; } + convertible_to_bool operator<(const Wrapped3& x) const + { return _value < x._value; } private: T _value; @@ -174,10 +201,13 @@ namespace explicit Wrapped4( T v = T() ) : _value(v) {} T value() const { return _value; } - bool operator<(const Wrapped4& x) const { return _value < x._value; } + convertible_to_bool operator<(const Wrapped4& x) const + { return _value < x._value; } - bool operator<(U u) const { return _value < u; } - bool operator>(U u) const { return _value > u; } + convertible_to_bool operator<(U u) const + { return _value < u; } + convertible_to_bool operator>(U u) const + { return _value > u; } private: T _value; @@ -198,11 +228,18 @@ namespace Wrapped5(U u) : _value(u) {} T value() const { return _value; } - bool operator<(const Wrapped5& x) const { return _value < x._value; } - bool operator<(U u) const { return _value < u; } - bool operator>(U u) const { return _value > u; } - bool operator==(const Wrapped5& u) const { return _value == u._value; } - bool operator==(U u) const { return _value == u; } + + convertible_to_bool operator<(const Wrapped5& x) const + { return _value < x._value; } + convertible_to_bool operator<(U u) const + { return _value < u; } + convertible_to_bool operator>(U u) const + { return _value > u; } + convertible_to_bool operator==(const Wrapped5& u) const + { return _value == u._value; } + convertible_to_bool operator==(U u) const + { return _value == u; } + Wrapped5& operator/=(const Wrapped5& u) { _value /= u._value; return *this;} Wrapped5& operator/=(U u) { _value /= u; return *this;} Wrapped5& operator*=(const Wrapped5& u) { _value *= u._value; return *this;} @@ -221,8 +258,8 @@ namespace // U must be convertible to T template class Wrapped6 - : boost::ordered_euclidian_ring_operators2, U> - , boost::ordered_euclidian_ring_operators1 > + : boost::ordered_euclidean_ring_operators2, U> + , boost::ordered_euclidean_ring_operators1 > { public: explicit Wrapped6( T v = T() ) : _value(v) {} @@ -231,11 +268,18 @@ namespace Wrapped6(U u) : _value(u) {} T value() const { return _value; } - bool operator<(const Wrapped6& x) const { return _value < x._value; } - bool operator<(U u) const { return _value < u; } - bool operator>(U u) const { return _value > u; } - bool operator==(const Wrapped6& u) const { return _value == u._value; } - bool operator==(U u) const { return _value == u; } + + convertible_to_bool operator<(const Wrapped6& x) const + { return _value < x._value; } + convertible_to_bool operator<(U u) const + { return _value < u; } + convertible_to_bool operator>(U u) const + { return _value > u; } + convertible_to_bool operator==(const Wrapped6& u) const + { return _value == u._value; } + convertible_to_bool operator==(U u) const + { return _value == u; } + Wrapped6& operator%=(const Wrapped6& u) { _value %= u._value; return *this;} Wrapped6& operator%=(U u) { _value %= u; return *this;} Wrapped6& operator/=(const Wrapped6& u) { _value /= u._value; return *this;} @@ -276,10 +320,10 @@ namespace template void test_less_than_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2) { - BOOST_CHECK( (x1 < y1) == (x2 < y2) ); - BOOST_CHECK( (x1 <= y1) == (x2 <= y2) ); - BOOST_CHECK( (x1 >= y1) == (x2 >= y2) ); - BOOST_CHECK( (x1 > y1) == (x2 > y2) ); + BOOST_CHECK( static_cast(x1 < y1) == static_cast(x2 < y2) ); + BOOST_CHECK( static_cast(x1 <= y1) == static_cast(x2 <= y2) ); + BOOST_CHECK( static_cast(x1 >= y1) == static_cast(x2 >= y2) ); + BOOST_CHECK( static_cast(x1 > y1) == static_cast(x2 > y2) ); } template @@ -293,8 +337,8 @@ namespace template void test_equality_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2) { - BOOST_CHECK( (x1 == y1) == (x2 == y2) ); - BOOST_CHECK( (x1 != y1) == (x2 != y2) ); + BOOST_CHECK( static_cast(x1 == y1) == static_cast(x2 == y2) ); + BOOST_CHECK( static_cast(x1 != y1) == static_cast(x2 != y2) ); } template @@ -614,14 +658,14 @@ test_main( int , char * [] ) PRIVATE_EXPR_TEST( (i = i2), (i.value() == 2) ); - BOOST_CHECK( i2 == i ); - BOOST_CHECK( i1 != i2 ); - BOOST_CHECK( i1 < i2 ); - BOOST_CHECK( i1 <= i2 ); - BOOST_CHECK( i <= i2 ); - BOOST_CHECK( i2 > i1 ); - BOOST_CHECK( i2 >= i1 ); - BOOST_CHECK( i2 >= i ); + BOOST_CHECK( static_cast(i2 == i) ); + BOOST_CHECK( static_cast(i1 != i2) ); + BOOST_CHECK( static_cast(i1 < i2) ); + BOOST_CHECK( static_cast(i1 <= i2) ); + BOOST_CHECK( static_cast(i <= i2) ); + BOOST_CHECK( static_cast(i2 > i1) ); + BOOST_CHECK( static_cast(i2 >= i1) ); + BOOST_CHECK( static_cast(i2 >= i) ); PRIVATE_EXPR_TEST( (i = i1 + i2), (i.value() == 3) ); PRIVATE_EXPR_TEST( (i = i + i2), (i.value() == 5) ); @@ -653,78 +697,78 @@ test_main( int , char * [] ) PRIVATE_EXPR_TEST( (j = j2), (j.value() == 2) ); - BOOST_CHECK( j2 == j ); - BOOST_CHECK( 2 == j ); - BOOST_CHECK( j2 == 2 ); - BOOST_CHECK( j == j2 ); - BOOST_CHECK( j1 != j2 ); - BOOST_CHECK( j1 != 2 ); - BOOST_CHECK( 1 != j2 ); - BOOST_CHECK( j1 < j2 ); - BOOST_CHECK( 1 < j2 ); - BOOST_CHECK( j1 < 2 ); - BOOST_CHECK( j1 <= j2 ); - BOOST_CHECK( 1 <= j2 ); - BOOST_CHECK( j1 <= j ); - BOOST_CHECK( j <= j2 ); - BOOST_CHECK( 2 <= j2 ); - BOOST_CHECK( j <= 2 ); - BOOST_CHECK( j2 > j1 ); - BOOST_CHECK( 2 > j1 ); - BOOST_CHECK( j2 > 1 ); - BOOST_CHECK( j2 >= j1 ); - BOOST_CHECK( 2 >= j1 ); - BOOST_CHECK( j2 >= 1 ); - BOOST_CHECK( j2 >= j ); - BOOST_CHECK( 2 >= j ); - BOOST_CHECK( j2 >= 2 ); + BOOST_CHECK( static_cast(j2 == j) ); + BOOST_CHECK( static_cast(2 == j) ); + BOOST_CHECK( static_cast(j2 == 2) ); + BOOST_CHECK( static_cast(j == j2) ); + BOOST_CHECK( static_cast(j1 != j2) ); + BOOST_CHECK( static_cast(j1 != 2) ); + BOOST_CHECK( static_cast(1 != j2) ); + BOOST_CHECK( static_cast(j1 < j2) ); + BOOST_CHECK( static_cast(1 < j2) ); + BOOST_CHECK( static_cast(j1 < 2) ); + BOOST_CHECK( static_cast(j1 <= j2) ); + BOOST_CHECK( static_cast(1 <= j2) ); + BOOST_CHECK( static_cast(j1 <= j) ); + BOOST_CHECK( static_cast(j <= j2) ); + BOOST_CHECK( static_cast(2 <= j2) ); + BOOST_CHECK( static_cast(j <= 2) ); + BOOST_CHECK( static_cast(j2 > j1) ); + BOOST_CHECK( static_cast(2 > j1) ); + BOOST_CHECK( static_cast(j2 > 1) ); + BOOST_CHECK( static_cast(j2 >= j1) ); + BOOST_CHECK( static_cast(2 >= j1) ); + BOOST_CHECK( static_cast(j2 >= 1) ); + BOOST_CHECK( static_cast(j2 >= j) ); + BOOST_CHECK( static_cast(2 >= j) ); + BOOST_CHECK( static_cast(j2 >= 2) ); - BOOST_CHECK( (j1 + 2) == 3 ); - BOOST_CHECK( (1 + j2) == 3 ); + BOOST_CHECK( static_cast((j1 + 2) == 3) ); + BOOST_CHECK( static_cast((1 + j2) == 3) ); PRIVATE_EXPR_TEST( (j = j1 + j2), (j.value() == 3) ); - BOOST_CHECK( (j + 2) == 5 ); - BOOST_CHECK( (3 + j2) == 5 ); + BOOST_CHECK( static_cast((j + 2) == 5) ); + BOOST_CHECK( static_cast((3 + j2) == 5) ); PRIVATE_EXPR_TEST( (j = j + j2), (j.value() == 5) ); - BOOST_CHECK( (j - 1) == 4 ); + BOOST_CHECK( static_cast((j - 1) == 4) ); PRIVATE_EXPR_TEST( (j = j - j1), (j.value() == 4) ); - BOOST_CHECK( (j * 2) == 8 ); - BOOST_CHECK( (4 * j2) == 8 ); + BOOST_CHECK( static_cast((j * 2) == 8) ); + BOOST_CHECK( static_cast((4 * j2) == 8) ); PRIVATE_EXPR_TEST( (j = j * j2), (j.value() == 8) ); - BOOST_CHECK( (j / 2) == 4 ); + BOOST_CHECK( static_cast((j / 2) == 4) ); PRIVATE_EXPR_TEST( (j = j / j2), (j.value() == 4) ); - BOOST_CHECK( (j % 3) == 1 ); + BOOST_CHECK( static_cast((j % 3) == 1) ); PRIVATE_EXPR_TEST( (j = j % ( j - j1 )), (j.value() == 1) ); PRIVATE_EXPR_TEST( (j = j2 + j2), (j.value() == 4) ); - BOOST_CHECK( (1 | j2 | j) == 7 ); - BOOST_CHECK( (j1 | 2 | j) == 7 ); - BOOST_CHECK( (j1 | j2 | 4) == 7 ); + BOOST_CHECK( static_cast((1 | j2 | j) == 7) ); + BOOST_CHECK( static_cast((j1 | 2 | j) == 7) ); + BOOST_CHECK( static_cast((j1 | j2 | 4) == 7) ); PRIVATE_EXPR_TEST( (j = j1 | j2 | j), (j.value() == 7) ); - BOOST_CHECK( (7 & j2) == 2 ); - BOOST_CHECK( (j & 2) == 2 ); + BOOST_CHECK( static_cast((7 & j2) == 2) ); + BOOST_CHECK( static_cast((j & 2) == 2) ); PRIVATE_EXPR_TEST( (j = j & j2), (j.value() == 2) ); PRIVATE_EXPR_TEST( (j = j | j1), (j.value() == 3) ); - BOOST_CHECK( (3 ^ j1) == 2 ); - BOOST_CHECK( (j ^ 1) == 2 ); + BOOST_CHECK( static_cast((3 ^ j1) == 2) ); + BOOST_CHECK( static_cast((j ^ 1) == 2) ); PRIVATE_EXPR_TEST( (j = j ^ j1), (j.value() == 2) ); PRIVATE_EXPR_TEST( (j = ( j + j1 ) * ( j2 | j1 )), (j.value() == 9) ); - BOOST_CHECK( (j1 << 2) == 4 ); - BOOST_CHECK( (j2 << 1) == 4 ); + BOOST_CHECK( static_cast((j1 << 2) == 4) ); + BOOST_CHECK( static_cast((j2 << 1) == 4) ); PRIVATE_EXPR_TEST( (j = j1 << j2), (j.value() == 4) ); - BOOST_CHECK( (j >> 2) == 1 ); - BOOST_CHECK( (j2 >> 1) == 1 ); + BOOST_CHECK( static_cast((j >> 2) == 1) ); + BOOST_CHECK( static_cast((j2 >> 1) == 1) ); PRIVATE_EXPR_TEST( (j = j2 >> j1), (j.value() == 1) ); cout << "Performed tests on MyLong objects.\n"; @@ -741,14 +785,14 @@ test_main( int , char * [] ) PRIVATE_EXPR_TEST( (k = k2), (k.value() == 2) ); - BOOST_CHECK( k2 == k ); - BOOST_CHECK( k1 != k2 ); - BOOST_CHECK( k1 < k2 ); - BOOST_CHECK( k1 <= k2 ); - BOOST_CHECK( k <= k2 ); - BOOST_CHECK( k2 > k1 ); - BOOST_CHECK( k2 >= k1 ); - BOOST_CHECK( k2 >= k ); + BOOST_CHECK( static_cast(k2 == k) ); + BOOST_CHECK( static_cast(k1 != k2) ); + BOOST_CHECK( static_cast(k1 < k2) ); + BOOST_CHECK( static_cast(k1 <= k2) ); + BOOST_CHECK( static_cast(k <= k2) ); + BOOST_CHECK( static_cast(k2 > k1) ); + BOOST_CHECK( static_cast(k2 >= k1) ); + BOOST_CHECK( static_cast(k2 >= k) ); cout << "Performed tests on MyChar objects.\n"; @@ -764,31 +808,31 @@ test_main( int , char * [] ) PRIVATE_EXPR_TEST( (l = l2), (l.value() == 2) ); - BOOST_CHECK( l2 == l ); - BOOST_CHECK( 2 == l ); - BOOST_CHECK( l2 == 2 ); - BOOST_CHECK( l == l2 ); - BOOST_CHECK( l1 != l2 ); - BOOST_CHECK( l1 != 2 ); - BOOST_CHECK( 1 != l2 ); - BOOST_CHECK( l1 < l2 ); - BOOST_CHECK( 1 < l2 ); - BOOST_CHECK( l1 < 2 ); - BOOST_CHECK( l1 <= l2 ); - BOOST_CHECK( 1 <= l2 ); - BOOST_CHECK( l1 <= l ); - BOOST_CHECK( l <= l2 ); - BOOST_CHECK( 2 <= l2 ); - BOOST_CHECK( l <= 2 ); - BOOST_CHECK( l2 > l1 ); - BOOST_CHECK( 2 > l1 ); - BOOST_CHECK( l2 > 1 ); - BOOST_CHECK( l2 >= l1 ); - BOOST_CHECK( 2 >= l1 ); - BOOST_CHECK( l2 >= 1 ); - BOOST_CHECK( l2 >= l ); - BOOST_CHECK( 2 >= l ); - BOOST_CHECK( l2 >= 2 ); + BOOST_CHECK( static_cast(l2 == l) ); + BOOST_CHECK( static_cast(2 == l) ); + BOOST_CHECK( static_cast(l2 == 2) ); + BOOST_CHECK( static_cast(l == l2) ); + BOOST_CHECK( static_cast(l1 != l2) ); + BOOST_CHECK( static_cast(l1 != 2) ); + BOOST_CHECK( static_cast(1 != l2) ); + BOOST_CHECK( static_cast(l1 < l2) ); + BOOST_CHECK( static_cast(1 < l2) ); + BOOST_CHECK( static_cast(l1 < 2) ); + BOOST_CHECK( static_cast(l1 <= l2) ); + BOOST_CHECK( static_cast(1 <= l2) ); + BOOST_CHECK( static_cast(l1 <= l) ); + BOOST_CHECK( static_cast(l <= l2) ); + BOOST_CHECK( static_cast(2 <= l2) ); + BOOST_CHECK( static_cast(l <= 2) ); + BOOST_CHECK( static_cast(l2 > l1) ); + BOOST_CHECK( static_cast(2 > l1) ); + BOOST_CHECK( static_cast(l2 > 1) ); + BOOST_CHECK( static_cast(l2 >= l1) ); + BOOST_CHECK( static_cast(2 >= l1) ); + BOOST_CHECK( static_cast(l2 >= 1) ); + BOOST_CHECK( static_cast(l2 >= l) ); + BOOST_CHECK( static_cast(2 >= l) ); + BOOST_CHECK( static_cast(l2 >= 2) ); cout << "Performed tests on MyShort objects.\n"; @@ -807,37 +851,37 @@ test_main( int , char * [] ) PRIVATE_EXPR_TEST( (di = di2), (di.value() == 2) ); - BOOST_CHECK( di2 == di ); - BOOST_CHECK( 2 == di ); - BOOST_CHECK( di == 2 ); - BOOST_CHECK( di1 < di2 ); - BOOST_CHECK( 1 < di2 ); - BOOST_CHECK( di1 <= di2 ); - BOOST_CHECK( 1 <= di2 ); - BOOST_CHECK( di2 > di1 ); - BOOST_CHECK( di2 > 1 ); - BOOST_CHECK( di2 >= di1 ); - BOOST_CHECK( di2 >= 1 ); - BOOST_CHECK( di1 / di2 == half ); - BOOST_CHECK( di1 / 2 == half ); - BOOST_CHECK( 1 / di2 == half ); - PRIVATE_EXPR_TEST( (tmp=di1), ((tmp/=2) == half) ); - PRIVATE_EXPR_TEST( (tmp=di1), ((tmp/=di2) == half) ); - BOOST_CHECK( di1 * di2 == di2 ); - BOOST_CHECK( di1 * 2 == di2 ); - BOOST_CHECK( 1 * di2 == di2 ); - PRIVATE_EXPR_TEST( (tmp=di1), ((tmp*=2) == di2) ); - PRIVATE_EXPR_TEST( (tmp=di1), ((tmp*=di2) == di2) ); - BOOST_CHECK( di2 - di1 == di1 ); - BOOST_CHECK( di2 - 1 == di1 ); - BOOST_CHECK( 2 - di1 == di1 ); - PRIVATE_EXPR_TEST( (tmp=di2), ((tmp-=1) == di1) ); - PRIVATE_EXPR_TEST( (tmp=di2), ((tmp-=di1) == di1) ); - BOOST_CHECK( di1 + di1 == di2 ); - BOOST_CHECK( di1 + 1 == di2 ); - BOOST_CHECK( 1 + di1 == di2 ); - PRIVATE_EXPR_TEST( (tmp=di1), ((tmp+=1) == di2) ); - PRIVATE_EXPR_TEST( (tmp=di1), ((tmp+=di1) == di2) ); + BOOST_CHECK( static_cast(di2 == di) ); + BOOST_CHECK( static_cast(2 == di) ); + BOOST_CHECK( static_cast(di == 2) ); + BOOST_CHECK( static_cast(di1 < di2) ); + BOOST_CHECK( static_cast(1 < di2) ); + BOOST_CHECK( static_cast(di1 <= di2) ); + BOOST_CHECK( static_cast(1 <= di2) ); + BOOST_CHECK( static_cast(di2 > di1) ); + BOOST_CHECK( static_cast(di2 > 1) ); + BOOST_CHECK( static_cast(di2 >= di1) ); + BOOST_CHECK( static_cast(di2 >= 1) ); + BOOST_CHECK( static_cast(di1 / di2 == half) ); + BOOST_CHECK( static_cast(di1 / 2 == half) ); + BOOST_CHECK( static_cast(1 / di2 == half) ); + PRIVATE_EXPR_TEST( (tmp=di1), static_cast((tmp/=2) == half) ); + PRIVATE_EXPR_TEST( (tmp=di1), static_cast((tmp/=di2) == half) ); + BOOST_CHECK( static_cast(di1 * di2 == di2) ); + BOOST_CHECK( static_cast(di1 * 2 == di2) ); + BOOST_CHECK( static_cast(1 * di2 == di2) ); + PRIVATE_EXPR_TEST( (tmp=di1), static_cast((tmp*=2) == di2) ); + PRIVATE_EXPR_TEST( (tmp=di1), static_cast((tmp*=di2) == di2) ); + BOOST_CHECK( static_cast(di2 - di1 == di1) ); + BOOST_CHECK( static_cast(di2 - 1 == di1) ); + BOOST_CHECK( static_cast(2 - di1 == di1) ); + PRIVATE_EXPR_TEST( (tmp=di2), static_cast((tmp-=1) == di1) ); + PRIVATE_EXPR_TEST( (tmp=di2), static_cast((tmp-=di1) == di1) ); + BOOST_CHECK( static_cast(di1 + di1 == di2) ); + BOOST_CHECK( static_cast(di1 + 1 == di2) ); + BOOST_CHECK( static_cast(1 + di1 == di2) ); + PRIVATE_EXPR_TEST( (tmp=di1), static_cast((tmp+=1) == di2) ); + PRIVATE_EXPR_TEST( (tmp=di1), static_cast((tmp+=di1) == di2) ); cout << "Performed tests on MyDoubleInt objects.\n"; @@ -854,42 +898,42 @@ test_main( int , char * [] ) PRIVATE_EXPR_TEST( (li = li2), (li.value() == 2) ); - BOOST_CHECK( li2 == li ); - BOOST_CHECK( 2 == li ); - BOOST_CHECK( li == 2 ); - BOOST_CHECK( li1 < li2 ); - BOOST_CHECK( 1 < li2 ); - BOOST_CHECK( li1 <= li2 ); - BOOST_CHECK( 1 <= li2 ); - BOOST_CHECK( li2 > li1 ); - BOOST_CHECK( li2 > 1 ); - BOOST_CHECK( li2 >= li1 ); - BOOST_CHECK( li2 >= 1 ); - BOOST_CHECK( li1 % li2 == li1 ); - BOOST_CHECK( li1 % 2 == li1 ); - BOOST_CHECK( 1 % li2 == li1 ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2%=2) == li1) ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2%=li2) == li1) ); - BOOST_CHECK( li1 / li2 == 0 ); - BOOST_CHECK( li1 / 2 == 0 ); - BOOST_CHECK( 1 / li2 == 0 ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2/=2) == 0) ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2/=li2) == 0) ); - BOOST_CHECK( li1 * li2 == li2 ); - BOOST_CHECK( li1 * 2 == li2 ); - BOOST_CHECK( 1 * li2 == li2 ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2*=2) == li2) ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2*=li2) == li2) ); - BOOST_CHECK( li2 - li1 == li1 ); - BOOST_CHECK( li2 - 1 == li1 ); - BOOST_CHECK( 2 - li1 == li1 ); - PRIVATE_EXPR_TEST( (tmp2=li2), ((tmp2-=1) == li1) ); - PRIVATE_EXPR_TEST( (tmp2=li2), ((tmp2-=li1) == li1) ); - BOOST_CHECK( li1 + li1 == li2 ); - BOOST_CHECK( li1 + 1 == li2 ); - BOOST_CHECK( 1 + li1 == li2 ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2+=1) == li2) ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2+=li1) == li2) ); + BOOST_CHECK( static_cast(li2 == li) ); + BOOST_CHECK( static_cast(2 == li) ); + BOOST_CHECK( static_cast(li == 2) ); + BOOST_CHECK( static_cast(li1 < li2) ); + BOOST_CHECK( static_cast(1 < li2) ); + BOOST_CHECK( static_cast(li1 <= li2) ); + BOOST_CHECK( static_cast(1 <= li2) ); + BOOST_CHECK( static_cast(li2 > li1) ); + BOOST_CHECK( static_cast(li2 > 1) ); + BOOST_CHECK( static_cast(li2 >= li1) ); + BOOST_CHECK( static_cast(li2 >= 1) ); + BOOST_CHECK( static_cast(li1 % li2 == li1) ); + BOOST_CHECK( static_cast(li1 % 2 == li1) ); + BOOST_CHECK( static_cast(1 % li2 == li1) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2%=2) == li1) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2%=li2) == li1) ); + BOOST_CHECK( static_cast(li1 / li2 == 0) ); + BOOST_CHECK( static_cast(li1 / 2 == 0) ); + BOOST_CHECK( static_cast(1 / li2 == 0) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2/=2) == 0) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2/=li2) == 0) ); + BOOST_CHECK( static_cast(li1 * li2 == li2) ); + BOOST_CHECK( static_cast(li1 * 2 == li2) ); + BOOST_CHECK( static_cast(1 * li2 == li2) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2*=2) == li2) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2*=li2) == li2) ); + BOOST_CHECK( static_cast(li2 - li1 == li1) ); + BOOST_CHECK( static_cast(li2 - 1 == li1) ); + BOOST_CHECK( static_cast(2 - li1 == li1) ); + PRIVATE_EXPR_TEST( (tmp2=li2), static_cast((tmp2-=1) == li1) ); + PRIVATE_EXPR_TEST( (tmp2=li2), static_cast((tmp2-=li1) == li1) ); + BOOST_CHECK( static_cast(li1 + li1 == li2) ); + BOOST_CHECK( static_cast(li1 + 1 == li2) ); + BOOST_CHECK( static_cast(1 + li1 == li2) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2+=1) == li2) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2+=li1) == li2) ); cout << "Performed tests on MyLongInt objects.\n";