From be50b9550803fe946dbc15d5cedd417259b257e4 Mon Sep 17 00:00:00 2001
From: Daniel Frey
Date: Thu, 10 Apr 2008 14:38:14 +0000
Subject: [PATCH 01/30] Added test and fix for "convertible to bool"
requirement
[SVN r44151]
---
include/boost/operators.hpp | 36 ++--
operators_test.cpp | 404 ++++++++++++++++++++----------------
2 files changed, 243 insertions(+), 197 deletions(-)
diff --git a/include/boost/operators.hpp b/include/boost/operators.hpp
index b3b1bd7..3443cb5 100644
--- a/include/boost/operators.hpp
+++ b/include/boost/operators.hpp
@@ -8,6 +8,8 @@
// See http://www.boost.org/libs/utility/operators.htm for documentation.
// Revision History
+// 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 +126,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 +358,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 +367,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 +375,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 +394,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) ----------------//
diff --git a/operators_test.cpp b/operators_test.cpp
index d42cb6a..dd40fbc 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;}
@@ -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";
From bafe37fdab1a22f552728f59fc6c00105057ba2f Mon Sep 17 00:00:00 2001
From: Emil Dotchevski
Date: Tue, 15 Apr 2008 21:13:24 +0000
Subject: [PATCH 02/30] Boost Exception header compilation tests added.
[SVN r44442]
---
include/boost/exception.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/boost/exception.hpp b/include/boost/exception.hpp
index 6a49ab8..aca1409 100644
--- a/include/boost/exception.hpp
+++ b/include/boost/exception.hpp
@@ -7,7 +7,7 @@
#define UUID_1D94A7C6054E11DB9804B622A1EF5492
#include
-#include
+#include
#include
#endif
From a5b85eda07d936b497dd519a8dbfe8339f6d9d2d Mon Sep 17 00:00:00 2001
From: Peter Dimov
Date: Mon, 21 Apr 2008 21:42:29 +0000
Subject: [PATCH 03/30] Fix #1846.
[SVN r44705]
---
include/boost/utility/addressof.hpp | 43 ++++++++++++++++-------------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp
index 7629488..8e0a586 100644
--- a/include/boost/utility/addressof.hpp
+++ b/include/boost/utility/addressof.hpp
@@ -1,6 +1,7 @@
// Copyright (C) 2002 Brad King (brad.king@kitware.com)
// Douglas Gregor (gregod@cs.rpi.edu)
-// Peter Dimov
+//
+// Copyright (C) 2002, 2008 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -14,27 +15,31 @@
# include
# include
-namespace boost {
-
-// Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov)
-
-// VC7 strips const from nested classes unless we add indirection here
-# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
-
-template struct _addp
+namespace boost
{
- typedef T * type;
+
+namespace detail
+{
+
+template struct addressof_impl
+{
+ static inline T * f( T & v, long )
+ {
+ return reinterpret_cast(
+ &const_cast(reinterpret_cast(v)));
+ }
+
+ static inline T * f( T * v, int )
+ {
+ return v;
+ }
};
-
-template typename _addp::type
-# else
-template T*
-# endif
-addressof(T& v)
+} // namespace detail
+
+template T * addressof( T & v )
{
- return reinterpret_cast(
- &const_cast(reinterpret_cast(v)));
+ return boost::detail::addressof_impl::f( v, 0 );
}
// Borland doesn't like casting an array reference to a char reference
@@ -53,6 +58,6 @@ const T (*addressof(const T (&t)[N]))[N]
}
# endif
-}
+} // namespace boost
#endif // BOOST_UTILITY_ADDRESSOF_HPP
From f1c86c35c43c6a625c2fbd0fe350fec39ab4d829 Mon Sep 17 00:00:00 2001
From: Daniel James
Date: Sun, 27 Apr 2008 07:39:49 +0000
Subject: [PATCH 04/30] Merge in documentation fixes. Apart from the change to
optional's documenation Jamfile, which I included by mistake.
Fixes #1659, #1661, #1684, #1685, 1687, #1690, #1801
I wrote about this at:
http://lists.boost.org/Archives/boost/2008/04/136405.php
Merged revisions 44585-44806 via svnmerge from
https://svn.boost.org/svn/boost/branches/doc
........
r44585 | danieljames | 2008-04-19 16:25:27 +0100 (Sat, 19 Apr 2008) | 2 lines
Fix broken link to vacpp in bjam docs. Refs #1512
........
r44586 | danieljames | 2008-04-19 16:27:36 +0100 (Sat, 19 Apr 2008) | 2 lines
Fix broken link to bcpp in bjam docs. Refs #1513
........
r44587 | danieljames | 2008-04-19 16:33:58 +0100 (Sat, 19 Apr 2008) | 2 lines
DateTime documentation - Fix a link to the serialization library. Refs #1659
........
r44588 | danieljames | 2008-04-19 16:35:36 +0100 (Sat, 19 Apr 2008) | 2 lines
Fix some links in interprocess & intrusive. Refs #1661
........
r44589 | danieljames | 2008-04-19 16:37:39 +0100 (Sat, 19 Apr 2008) | 2 lines
Fix some links in the python docs. Refs #1684.
........
r44590 | danieljames | 2008-04-19 16:38:29 +0100 (Sat, 19 Apr 2008) | 2 lines
Work around a quickbook bug which is affecting the python docs. Refs #1684.
........
r44591 | danieljames | 2008-04-19 16:39:34 +0100 (Sat, 19 Apr 2008) | 2 lines
Fix a broken link in the numeric conversion docs. Refs #1685
........
r44592 | danieljames | 2008-04-19 16:40:45 +0100 (Sat, 19 Apr 2008) | 2 lines
Fix some links in the optional docs. Refs #1687
........
r44593 | danieljames | 2008-04-19 16:42:09 +0100 (Sat, 19 Apr 2008) | 2 lines
Fix link to the hash documentation from bimap. Refs #1690
........
r44599 | danieljames | 2008-04-19 18:07:33 +0100 (Sat, 19 Apr 2008) | 2 lines
Fix a typo in the format library. Refs #1801
........
r44600 | danieljames | 2008-04-19 19:20:59 +0100 (Sat, 19 Apr 2008) | 1 line
Initialise svnmerge.
........
r44641 | danieljames | 2008-04-20 18:59:47 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix the lincense url in shared container iterator documentation.
........
r44642 | danieljames | 2008-04-20 19:00:00 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix image link in the mpi documentation.
........
r44643 | danieljames | 2008-04-20 19:00:11 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix a typo in the spirit docs.
........
r44644 | danieljames | 2008-04-20 19:00:23 +0100 (Sun, 20 Apr 2008) | 2 lines
Escape the slash so that quickbook doesn't think it the start of an italic section, and mess up the link. Refs #1844
........
r44647 | danieljames | 2008-04-20 19:39:47 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix another typo in spirit docs.
........
[SVN r44807]
---
shared_container_iterator.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/shared_container_iterator.html b/shared_container_iterator.html
index dfef648..ed149b5 100644
--- a/shared_container_iterator.html
+++ b/shared_container_iterator.html
@@ -315,7 +315,7 @@ Last modified: Mon Aug 11 11:27:03 EST 2003
© Copyright 2003 The Trustees of Indiana University.
Use, modification and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http:www.boost.org/LICENSE_1_0.txt)
+ http://www.boost.org/LICENSE_1_0.txt)
+
+
+ Swap
+
+
+ template<class T> void swap(T& left, T& right);
+
+
+
+
+ The template function boost::swap allows the values of two variables to be swapped, using argument dependent lookup to select a specialized swap function if available. If no specialized swap function is available, std::swap is used.
+
+
+
+ Rationale
+
+ The generic std::swap function requires that the elements to be swapped are assignable and copy constructible. It is usually implemented using one copy construction and two assignments - this is often both unnecessarily restrictive and unnecessarily slow. In addition, where the generic swap implementation provides only the basic guarantee, specialized swap functions are often able to provide the no-throw exception guarantee (and it is considered best practice to do so where possible1).
+
+ The alternative to using argument dependent lookup in this situation is to provide a template specialization of std::swap for every type that requires a specialized swap. Although this is legal C++, no Boost libraries use this method, whereas many Boost libraries provide specialized swap functions in their own namespaces.
+
+
+ boost::swap also supports swapping built-in arrays. Note that std::swap doesn't yet do so, but a request to add an overload of std::swap for built-in arrays has been well-received by the Library Working Group of the C++ Standards Committee2.
+
+
+
+ Exception Safety
+
+ boost::swap provides the same exception guarantee as the underlying swap function used, with one exception; for an array of type T[n], where n > 1 and the underlying swap function for T provides the strong exception guarantee, boost::swap provides only the basic exception guarantee.
+
+
+
+ Requirements
+ Either:
+
+ - T must be assignable
+ - T must be copy constructible
+
+ Or:
+
+ - A function with the signature swap(T&,T&) is available via argument dependent lookup
+
+ Or:
+
+ - A template specialization of std::swap exists for T
+
+ Or:
+
+ - T is a built-in array of swappable elements
+
+
+
+
+ Portability
+
+ Several older compilers do not support argument dependent lookup – on these compilers boost::swap will call std::swap, ignoring any specialized swap functions that could be found as a result of argument dependent lookup.
+
+
+
+ Credits
+
+ -
+ Niels Dekker - for implementing and documenting support for built-in arrays
+
+ -
+ Joseph Gauterin - for the initial idea, implementation, tests, and documentation
+
+ -
+ Steven Wanatabe - for the idea to use a barrier namespace, enabling the function to have the name 'swap' without introducing ambiguity or infinite recursion
+
+
+
+
+
+ [1]Scott Meyers, Effective C++ Third Edition, Item 25: "Consider support for a non-throwing swap"
+ [2]LWG issue 809 (std::swap should be overloaded for array types)
+
+
+
+ Revised: 3 July 2008
+
+ Copyright 2007, 2008 Joseph Gauterin. Use, modification, and distribution are subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
+
+
+
From ad0bcf4a00670df71a2ed0e10d98a51c954863ea Mon Sep 17 00:00:00 2001
From: Douglas Gregor
Date: Fri, 9 May 2008 22:08:46 +0000
Subject: [PATCH 05/30] result_of implementation that makes use of C++0x
decltype, from Daniel Walker. Fixes #862.
[SVN r45256]
---
.../utility/detail/result_of_iterate.hpp | 42 ++++++
include/boost/utility/result_of.hpp | 4 +
test/result_of_test.cpp | 127 ++++++++++++++++--
utility.htm | 8 +-
4 files changed, 169 insertions(+), 12 deletions(-)
diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp
index 41616c3..6f1b2b1 100644
--- a/include/boost/utility/detail/result_of_iterate.hpp
+++ b/include/boost/utility/detail/result_of_iterate.hpp
@@ -10,6 +10,46 @@
# error Boost result_of - do not include this file!
#endif
+#if defined(BOOST_HAS_DECLTYPE)
+
+// As of N2588, C++0x result_of only supports function call
+// expressions of the form f(x). This precludes support for member
+// function pointers, which are invoked with expressions of the form
+// o->*f(x). This implementation supports both.
+template
+struct result_of
+ : mpl::if_<
+ mpl::or_< is_pointer, is_member_function_pointer >
+ , detail::result_of_impl<
+ F, F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false
+ >
+ , detail::result_of_decltype_impl<
+ F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))
+ >
+ >::type
+{};
+
+namespace detail {
+
+# define BOOST_RESULT_OF_STATIC_MEMBERS(z, n, _) \
+ static T ## n t ## n; \
+ /**/
+
+template
+class result_of_decltype_impl
+{
+ static F f;
+ BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_RESULT_OF_STATIC_MEMBERS, _)
+public:
+ typedef decltype(f(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),t))) type;
+};
+
+} // namespace detail
+
+#else // defined(BOOST_HAS_DECLTYPE)
+
// CWPro8 requires an argument in a function type specialization
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0
# define BOOST_RESULT_OF_ARGS void
@@ -26,6 +66,8 @@ struct result_of
#undef BOOST_RESULT_OF_ARGS
+#endif // defined(BOOST_HAS_DECLTYPE)
+
#if BOOST_PP_ITERATION() >= 1
namespace detail {
diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp
index a5bac6f..07306d6 100644
--- a/include/boost/utility/result_of.hpp
+++ b/include/boost/utility/result_of.hpp
@@ -18,6 +18,9 @@
#include
#include
#include
+#include
+#include
+#include
#ifndef BOOST_RESULT_OF_NUM_ARGS
# define BOOST_RESULT_OF_NUM_ARGS 10
@@ -33,6 +36,7 @@ namespace detail {
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
template struct result_of_impl;
+template struct result_of_decltype_impl;
template
struct result_of_void_impl
diff --git a/test/result_of_test.cpp b/test/result_of_test.cpp
index 10f3410..c6e91ea 100644
--- a/test/result_of_test.cpp
+++ b/test/result_of_test.cpp
@@ -11,35 +11,101 @@
#include
#include
-struct int_result_type { typedef int result_type; };
+struct int_result_type
+{
+ typedef int result_type;
+ result_type operator()(float);
+};
struct int_result_of
{
template struct result { typedef int type; };
+ result::type operator()(double);
+ result::type operator()(double) const;
+ result::type operator()();
+ result::type operator()() volatile;
};
-struct int_result_type_and_float_result_of
+struct int_result_type_and_float_result_of_and_char_return
{
typedef int result_type;
template struct result { typedef float type; };
+ char operator()(char);
};
template
-struct int_result_type_template { typedef int result_type; };
+struct int_result_type_template
+{
+ typedef int result_type;
+ result_type operator()(float);
+};
template
struct int_result_of_template
{
template struct result;
template struct result { typedef int type; };
+ typename result(double)>::type operator()(double);
+ typename result(double)>::type operator()(double) const;
+ typename result(double)>::type operator()();
+ typename result(double)>::type operator()() volatile;
};
template
-struct int_result_type_and_float_result_of_template
+struct int_result_type_and_float_result_of_and_char_return_template
{
typedef int result_type;
template struct result;
template struct result { typedef float type; };
+ char operator()(char);
+};
+
+struct result_of_member_function_template
+{
+ template struct result;
+
+ template struct result { typedef That type; };
+ template typename result::type operator()(T);
+
+ template struct result { typedef const That type; };
+ template typename result::type operator()(T) const;
+
+ template struct result { typedef volatile That type; };
+ template typename result::type operator()(T) volatile;
+
+ template struct result { typedef const volatile That type; };
+ template typename result::type operator()(T) const volatile;
+
+ template struct result { typedef That & type; };
+ template typename result::type operator()(T &, T);
+
+ template struct result { typedef That const & type; };
+ template typename result::type operator()(T const &, T);
+
+ template struct result { typedef That volatile & type; };
+ template typename result::type operator()(T volatile &, T);
+
+ template struct result { typedef That const volatile & type; };
+ template typename result::type operator()(T const volatile &, T);
+};
+
+struct no_result_type_or_result_of
+{
+ int operator()(double);
+ short operator()(double) const;
+ unsigned int operator()();
+ unsigned short operator()() volatile;
+ const unsigned short operator()() const volatile;
+};
+
+template
+struct no_result_type_or_result_of_template
+{
+ int operator()(double);
+ short operator()(double) const;
+ unsigned int operator()();
+ unsigned short operator()() volatile;
+ const unsigned short operator()() const volatile;
};
struct X {};
@@ -60,16 +126,37 @@ int main()
BOOST_STATIC_ASSERT((is_same::type, int>::value));
BOOST_STATIC_ASSERT((is_same::type, int>::value));
- BOOST_STATIC_ASSERT((is_same::type, void>::value));
BOOST_STATIC_ASSERT((is_same::type, int>::value));
- BOOST_STATIC_ASSERT((is_same::type, void>::value));
- BOOST_STATIC_ASSERT((is_same::type, int>::value));
BOOST_STATIC_ASSERT((is_same(float)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value));
- BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value));
+
+ // Prior to decltype, result_of could not deduce the return type
+ // nullary function objects unless they exposed a result_type.
+#if defined(BOOST_HAS_DECLTYPE)
+ BOOST_STATIC_ASSERT((is_same::type, int>::value));
+ BOOST_STATIC_ASSERT((is_same::type, int>::value));
+ BOOST_STATIC_ASSERT((is_same(void)>::type, int>::value));
+ BOOST_STATIC_ASSERT((is_same(void)>::type, int>::value));
+#else
+ BOOST_STATIC_ASSERT((is_same::type, void>::value));
+ BOOST_STATIC_ASSERT((is_same::type, void>::value));
+ BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value));
- BOOST_STATIC_ASSERT((is_same(char)>::type, int>::value));
+#endif
+
+ // Prior to decltype, result_of ignored a nested result<> if
+ // result_type was defined. After decltype, result_of deduces the
+ // actual return type of the function object, ignoring both
+ // result<> and result_type.
+#if defined(BOOST_HAS_DECLTYPE)
+ BOOST_STATIC_ASSERT((is_same::type, char>::value));
+ BOOST_STATIC_ASSERT((is_same(char)>::type, char>::value));
+#else
+ BOOST_STATIC_ASSERT((is_same::type, int>::value));
+ BOOST_STATIC_ASSERT((is_same(char)>::type, int>::value));
+#endif
+
BOOST_STATIC_ASSERT((is_same::type, int>::value));
BOOST_STATIC_ASSERT((is_same::type, int>::value));
BOOST_STATIC_ASSERT((is_same::type, int>::value));
@@ -81,5 +168,27 @@ int main()
BOOST_STATIC_ASSERT((is_same::type, int>::value));
BOOST_STATIC_ASSERT((is_same::type, int>::value));
+ BOOST_STATIC_ASSERT((is_same::type, double>::value));
+ BOOST_STATIC_ASSERT((is_same::type, const double>::value));
+ BOOST_STATIC_ASSERT((is_same::type, volatile double>::value));
+ BOOST_STATIC_ASSERT((is_same::type, const volatile double>::value));
+ BOOST_STATIC_ASSERT((is_same::type, int &>::value));
+ BOOST_STATIC_ASSERT((is_same::type, int const &>::value));
+ BOOST_STATIC_ASSERT((is_same::type, int volatile &>::value));
+ BOOST_STATIC_ASSERT((is_same::type, int const volatile &>::value));
+
+#if defined(BOOST_HAS_DECLTYPE)
+ BOOST_STATIC_ASSERT((is_same::type, int>::value));
+ BOOST_STATIC_ASSERT((is_same::type, unsigned int>::value));
+ BOOST_STATIC_ASSERT((is_same::type, short>::value));
+ BOOST_STATIC_ASSERT((is_same::type, unsigned short>::value));
+ BOOST_STATIC_ASSERT((is_same::type, const unsigned short>::value));
+ BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value));
+ BOOST_STATIC_ASSERT((is_same(void)>::type, unsigned int>::value));
+ BOOST_STATIC_ASSERT((is_same(double)>::type, short>::value));
+ BOOST_STATIC_ASSERT((is_same(void)>::type, unsigned short>::value));
+ BOOST_STATIC_ASSERT((is_same(void)>::type, const unsigned short>::value));
+#endif
+
return 0;
}
diff --git a/utility.htm b/utility.htm
index 9514188..1102d47 100644
--- a/utility.htm
+++ b/utility.htm
@@ -152,11 +152,13 @@ void f() {
...,tN). The implementation permits
the type F
to be a function pointer,
function reference, member function pointer, or class
- type. When F
is a class type with a
- member type result_type
,
+ type.
If your compiler does not support
+ decltype
, then when F
is a
+ class type with a member type result_type
,
result_of<F(T1, T2, ...,
TN)>
is
- F::result_type
. Otherwise,
+ F::result_type
. When F
+ does not contain result_type
,
result_of<F(T1, T2, ...,
TN)>
is F::result<F(T1,
T2, ..., TN)>::type
when
From 8efae71f4aa6f6721daa0fc7084869129305463b Mon Sep 17 00:00:00 2001
From: Niels Dekker
Date: Fri, 23 May 2008 16:46:43 +0000
Subject: [PATCH 06/30] Changed boost::initialized_value from a class to an
instance, to make its use more convenient, as discussed with Fernando.
[SVN r45685]
---
include/boost/utility/value_init.hpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp
index 60879cf..67127c0 100644
--- a/include/boost/utility/value_init.hpp
+++ b/include/boost/utility/value_init.hpp
@@ -5,7 +5,8 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
// 21 Ago 2002 (Created) Fernando Cacciola
-// 18 Feb 2008 (Worked around compiler bugs, added initialized_value) Fernando Cacciola, Niels Dekker
+// 24 Dec 2007 (Refactored and worked around various compiler bugs) Fernando Cacciola, Niels Dekker
+// 23 May 2008 (Fixed operator= const issue, added initialized_value) Niels Dekker, Fernando Cacciola
//
#ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
#define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
@@ -110,7 +111,7 @@ T& get ( value_initialized& x )
}
-class initialized_value
+class initialized_value_t
{
public :
@@ -120,6 +121,8 @@ class initialized_value
}
};
+initialized_value_t const initialized_value = {} ;
+
} // namespace boost
From 67f3ca090aeea6fae4b41aa06c4838e4dca5e131 Mon Sep 17 00:00:00 2001
From: Niels Dekker
Date: Fri, 23 May 2008 16:48:10 +0000
Subject: [PATCH 07/30] Fixed value_init test + doc, according to change of
boost::initialized_value, revision [45685]
[SVN r45686]
---
value_init.htm | 29 +++++++++++++++++------------
value_init_test.cpp | 5 +++--
2 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/value_init.htm b/value_init.htm
index c97a0eb..6bbfcbc 100644
--- a/value_init.htm
+++ b/value_init.htm
@@ -28,12 +28,12 @@
- - Types
+ - Types and objects
Acknowledgements
@@ -53,7 +53,7 @@ union and class types.
Moreover, value_initialized
offers a workaround to various
compiler issues regarding value-initialization.
-Furthermore a convenience class, initialized_value
is provided,
+Furthermore, a const
object, initialized_value
is provided,
to avoid repeating the type name when retrieving the value from a
value_initialized<T>
object.
@@ -123,12 +123,12 @@ constructed by the following declaration:
-The convenience class initialized_value
+The const
object initialized_value
allows value-initializing a variable as follows:
- T var = initialized_value();
+ T var = initialized_value ;
-This form of initialization is also very similar to T4 var4 = T4()
,
+This form of initialization is semantically equivalent to T4 var4 = T4()
,
but robust against the aforementioned compiler issues.
@@ -249,7 +249,7 @@ offer a workaround to these issues: value_initialized
will now clea
its internal data, prior to constructing the object that it contains.
-
Types
+
Types and objects
@@ -312,19 +312,22 @@ the wrapped object is always performed with the get()
idiom:
value_initialized<int> x ;
get(x) = 1 ; // OK
value_initialized<int const> cx ;
get(x) = 1 ; // ERROR: Cannot modify a const object
value_initialized<int> const x_c ;
get(x_c) = 1 ; // ERROR: Cannot modify a const object
value_initialized<int const> const cx_c ;
get(cx_c) = 1 ; // ERROR: Cannot modify a const object
-
+
namespace boost {
-class initialized_value
+class initialized_value_t
{
public :
template <class T> operator T() const ;
};
+
+initialized_value_t const initialized_value = {} ;
+
} // namespace boost
-The class initialized_value
provides a convenient way to get
+initialized_value
provides a convenient way to get
an initialized value: its conversion operator provides an appropriate
value-initialized object for any CopyConstructible type.
@@ -343,7 +346,7 @@ is rather short now (T
), but could of course be
more like Namespace::Template<Arg>::Type
.
Instead, one could use initialized_value
as follows:
- T var = initialized_value();
+ T var = initialized_value ;
@@ -368,13 +371,15 @@ Special thanks to Björn Karlsson who carefully edited and completed this do
value_initialized was reimplemented by Fernando Cacciola and Niels Dekker
for Boost release version 1.35 (2008), offering a workaround to various compiler issues.
+
initialized_value was written by Niels Dekker, and added to Boost release version 1.36 (2008).
+
Developed by Fernando Cacciola,
the latest version of this file can be found at www.boost.org.
-
Revised 16 January 2008
+
Revised 23 May 2008
© Copyright Fernando Cacciola, 2002, 2008.
diff --git a/value_init_test.cpp b/value_init_test.cpp
index b7dd956..7b07b22 100644
--- a/value_init_test.cpp
+++ b/value_init_test.cpp
@@ -7,7 +7,8 @@
// Test program for "boost/utility/value_init.hpp"
//
// 21 Ago 2002 (Created) Fernando Cacciola
-// 18 Feb 2008 (Added tests regarding compiler issues and initialized_value) Fernando Cacciola, Niels Dekker
+// 15 Jan 2008 (Added tests regarding compiler issues) Fernando Cacciola, Niels Dekker
+// 23 May 2008 (Added tests regarding initialized_value) Niels Dekker
#include // For memcmp.
#include
@@ -183,7 +184,7 @@ struct CopyFunctionCallTester
template
void check_initialized_value ( T const& y )
{
- T initializedValue = boost::initialized_value() ;
+ T initializedValue = boost::initialized_value ;
BOOST_CHECK ( y == initializedValue ) ;
}
From 4a564744fe9dcbf87c85c60b89f372de63cc99f3 Mon Sep 17 00:00:00 2001
From: Emil Dotchevski
Date: Wed, 25 Jun 2008 23:27:56 +0000
Subject: [PATCH 08/30] documentation update, added function
exception::diagnostic_information, added std::exception to_string overload,
removed tabs from source files
[SVN r46697]
---
include/boost/exception.hpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/boost/exception.hpp b/include/boost/exception.hpp
index aca1409..d805002 100644
--- a/include/boost/exception.hpp
+++ b/include/boost/exception.hpp
@@ -6,6 +6,12 @@
#ifndef UUID_1D94A7C6054E11DB9804B622A1EF5492
#define UUID_1D94A7C6054E11DB9804B622A1EF5492
+#include
+#include
+#include
+#include
+#include
+#include
#include
#include
#include
From f1ec0c4d04d593a58e95833c13a571e08da3bf5b Mon Sep 17 00:00:00 2001
From: Daniel James
Date: Thu, 26 Jun 2008 19:20:56 +0000
Subject: [PATCH 09/30] Fix a character encoding error.
[SVN r46740]
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index 7605aef..ff22fb4 100644
--- a/index.html
+++ b/index.html
@@ -29,7 +29,7 @@
value_init
-
© Copyright Beman Dawes, 2001
+
© Copyright Beman Dawes, 2001
Distributed under the Boost Software License, Version 1.0. (See
accompanying file
LICENSE_1_0.txt or copy at
From 177ee78bbb5e1283f914e77c936ac586a15a5abc Mon Sep 17 00:00:00 2001
From: Beman Dawes
Date: Sat, 28 Jun 2008 13:45:21 +0000
Subject: [PATCH 10/30] =?UTF-8?q?With=20his=20kind=20permission,=20change?=
=?UTF-8?q?=20Jaakko=20"J=C3=A4rvi"=20to=20"Jarvi"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[SVN r46808]
---
enable_if/test/constructors.cpp | 2 +-
enable_if/test/dummy_arg_disambiguation.cpp | 2 +-
enable_if/test/lazy.cpp | 2 +-
enable_if/test/lazy_test.cpp | 2 +-
enable_if/test/member_templates.cpp | 2 +-
enable_if/test/namespace_disambiguation.cpp | 2 +-
enable_if/test/no_disambiguation.cpp | 2 +-
enable_if/test/partial_specializations.cpp | 2 +-
include/boost/ref.hpp | 2 +-
include/boost/utility/enable_if.hpp | 2 +-
10 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/enable_if/test/constructors.cpp b/enable_if/test/constructors.cpp
index 889133d..0d465de 100644
--- a/enable_if/test/constructors.cpp
+++ b/enable_if/test/constructors.cpp
@@ -6,7 +6,7 @@
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-// Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
+// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu)
diff --git a/enable_if/test/dummy_arg_disambiguation.cpp b/enable_if/test/dummy_arg_disambiguation.cpp
index 90275e9..60dfdfd 100644
--- a/enable_if/test/dummy_arg_disambiguation.cpp
+++ b/enable_if/test/dummy_arg_disambiguation.cpp
@@ -6,7 +6,7 @@
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-// Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
+// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu)
diff --git a/enable_if/test/lazy.cpp b/enable_if/test/lazy.cpp
index 117ec41..f04111e 100644
--- a/enable_if/test/lazy.cpp
+++ b/enable_if/test/lazy.cpp
@@ -6,7 +6,7 @@
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-// Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
+// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu)
diff --git a/enable_if/test/lazy_test.cpp b/enable_if/test/lazy_test.cpp
index 10bb60c..9ec5324 100644
--- a/enable_if/test/lazy_test.cpp
+++ b/enable_if/test/lazy_test.cpp
@@ -6,7 +6,7 @@
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-// Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
+// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu)
diff --git a/enable_if/test/member_templates.cpp b/enable_if/test/member_templates.cpp
index f7c00a0..55e2d80 100644
--- a/enable_if/test/member_templates.cpp
+++ b/enable_if/test/member_templates.cpp
@@ -6,7 +6,7 @@
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-// Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
+// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu)
diff --git a/enable_if/test/namespace_disambiguation.cpp b/enable_if/test/namespace_disambiguation.cpp
index a53d3a7..45d4f0a 100644
--- a/enable_if/test/namespace_disambiguation.cpp
+++ b/enable_if/test/namespace_disambiguation.cpp
@@ -6,7 +6,7 @@
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-// Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
+// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu)
diff --git a/enable_if/test/no_disambiguation.cpp b/enable_if/test/no_disambiguation.cpp
index 122d600..e2416ed 100644
--- a/enable_if/test/no_disambiguation.cpp
+++ b/enable_if/test/no_disambiguation.cpp
@@ -6,7 +6,7 @@
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-// Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
+// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu)
diff --git a/enable_if/test/partial_specializations.cpp b/enable_if/test/partial_specializations.cpp
index 5c322ae..1d4db99 100644
--- a/enable_if/test/partial_specializations.cpp
+++ b/enable_if/test/partial_specializations.cpp
@@ -6,7 +6,7 @@
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-// Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
+// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu)
diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp
index ab09ae7..330ca65 100644
--- a/include/boost/ref.hpp
+++ b/include/boost/ref.hpp
@@ -15,7 +15,7 @@
//
// ref.hpp - ref/cref, useful helper functions
//
-// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
+// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2001, 2002 Peter Dimov
// Copyright (C) 2002 David Abrahams
//
diff --git a/include/boost/utility/enable_if.hpp b/include/boost/utility/enable_if.hpp
index d77d108..d292c6a 100644
--- a/include/boost/utility/enable_if.hpp
+++ b/include/boost/utility/enable_if.hpp
@@ -6,7 +6,7 @@
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-// Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
+// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
// Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu)
From 3c5c2bc107790c476e4523d3ab9e27173fc24327 Mon Sep 17 00:00:00 2001
From: Joseph Gauterin
Date: Sat, 5 Jul 2008 11:16:38 +0000
Subject: [PATCH 11/30] Moved utility\swap to the trunk, as discussed in trac
issue #2056.
[SVN r47093]
---
include/boost/swap.hpp | 12 ++
include/boost/utility/swap.hpp | 51 +++++++++
index.html | 1 +
swap.html | 94 +++++++++++++++
swap/test/Jamfile.v2 | 53 +++++++++
swap/test/lib_header_1.cpp | 18 +++
swap/test/lib_header_2.cpp | 20 ++++
swap/test/mixed_headers_1.cpp | 20 ++++
swap/test/mixed_headers_2.cpp | 20 ++++
swap/test/primitive.cpp | 44 +++++++
swap/test/root_header_1.cpp | 18 +++
swap/test/root_header_2.cpp | 20 ++++
swap/test/specialized_in_boost.cpp | 72 ++++++++++++
swap/test/specialized_in_global.cpp | 60 ++++++++++
swap/test/specialized_in_other.cpp | 72 ++++++++++++
swap/test/specialized_in_std.cpp | 70 ++++++++++++
swap/test/swap_arrays.cpp | 78 +++++++++++++
swap/test/swap_test_class.hpp | 171 ++++++++++++++++++++++++++++
18 files changed, 894 insertions(+)
create mode 100644 include/boost/swap.hpp
create mode 100644 include/boost/utility/swap.hpp
create mode 100644 swap.html
create mode 100644 swap/test/Jamfile.v2
create mode 100644 swap/test/lib_header_1.cpp
create mode 100644 swap/test/lib_header_2.cpp
create mode 100644 swap/test/mixed_headers_1.cpp
create mode 100644 swap/test/mixed_headers_2.cpp
create mode 100644 swap/test/primitive.cpp
create mode 100644 swap/test/root_header_1.cpp
create mode 100644 swap/test/root_header_2.cpp
create mode 100644 swap/test/specialized_in_boost.cpp
create mode 100644 swap/test/specialized_in_global.cpp
create mode 100644 swap/test/specialized_in_other.cpp
create mode 100644 swap/test/specialized_in_std.cpp
create mode 100644 swap/test/swap_arrays.cpp
create mode 100644 swap/test/swap_test_class.hpp
diff --git a/include/boost/swap.hpp b/include/boost/swap.hpp
new file mode 100644
index 0000000..2d8b44c
--- /dev/null
+++ b/include/boost/swap.hpp
@@ -0,0 +1,12 @@
+// Copyright (C) 2007 Joseph Gauterin
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_SWAP_HPP
+#define BOOST_SWAP_HPP
+
+#include "./utility/swap.hpp"
+
+#endif
diff --git a/include/boost/utility/swap.hpp b/include/boost/utility/swap.hpp
new file mode 100644
index 0000000..952adf5
--- /dev/null
+++ b/include/boost/utility/swap.hpp
@@ -0,0 +1,51 @@
+// Copyright (C) 2007, 2008 Steven Watanabe, Joseph Gauterin
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// For more information, see http://www.boost.org
+//
+// Update:
+// 29 June 2008 (Added support for built-in arrays.) Niels Dekker
+
+
+#ifndef BOOST_UTILITY_SWAP_HPP
+#define BOOST_UTILITY_SWAP_HPP
+
+#include //for std::swap
+#include //for std::size_t
+
+namespace boost_swap_impl
+{
+ template
+ void swap_impl(T& left, T& right)
+ {
+ using std::swap;//use std::swap if argument dependent lookup fails
+ swap(left,right);
+ }
+
+ template
+ void swap_impl(T (& left)[N], T (& right)[N])
+ {
+ for (std::size_t i = 0; i < N; ++i)
+ {
+ ::boost_swap_impl::swap_impl(left[i], right[i]);
+ }
+ }
+}
+
+namespace boost
+{
+ namespace swap_adl_barrier
+ {
+ template
+ void swap(T& left, T& right)
+ {
+ ::boost_swap_impl::swap_impl(left, right);
+ }
+ }
+
+ using swap_adl_barrier::swap;
+}
+
+#endif
diff --git a/index.html b/index.html
index ff22fb4..5af6f75 100644
--- a/index.html
+++ b/index.html
@@ -24,6 +24,7 @@
iterator_adaptors
generator iterator adaptors
operators
+ swap
throw_exception
utility
value_init
diff --git a/swap.html b/swap.html
new file mode 100644
index 0000000..e317b11
--- /dev/null
+++ b/swap.html
@@ -0,0 +1,94 @@
+?
+
+
+
+
+
Boost: Swap Documentation
+
+
+