Compare commits

...

8 Commits

Author SHA1 Message Date
Beman Dawes
f009e6754d Branch at revision 46530
[SVN r46531]
2008-06-19 18:57:10 +00:00
Niels Dekker
67f3ca090a Fixed value_init test + doc, according to change of boost::initialized_value, revision [45685]
[SVN r45686]
2008-05-23 16:48:10 +00:00
Niels Dekker
8efae71f4a Changed boost::initialized_value from a class to an instance, to make its use more convenient, as discussed with Fernando.
[SVN r45685]
2008-05-23 16:46:43 +00:00
Douglas Gregor
ad0bcf4a00 result_of implementation that makes use of C++0x decltype, from Daniel Walker. Fixes #862.
[SVN r45256]
2008-05-09 22:08:46 +00:00
Daniel James
f1c86c35c4 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]
2008-04-27 07:39:49 +00:00
Peter Dimov
a5b85eda07 Fix #1846.
[SVN r44705]
2008-04-21 21:42:29 +00:00
Emil Dotchevski
bafe37fdab Boost Exception header compilation tests added.
[SVN r44442]
2008-04-15 21:13:24 +00:00
Daniel Frey
be50b95508 Added test and fix for "convertible to bool" requirement
[SVN r44151]
2008-04-10 14:38:14 +00:00
13 changed files with 463 additions and 246 deletions

View File

@@ -7,7 +7,7 @@
#define UUID_1D94A7C6054E11DB9804B622A1EF5492 #define UUID_1D94A7C6054E11DB9804B622A1EF5492
#include <boost/exception/info_tuple.hpp> #include <boost/exception/info_tuple.hpp>
#include <boost/exception/cloning.hpp> #include <boost/exception_ptr.hpp>
#include <boost/throw_exception.hpp> #include <boost/throw_exception.hpp>
#endif #endif

View File

@@ -8,6 +8,8 @@
// See http://www.boost.org/libs/utility/operators.htm for documentation. // See http://www.boost.org/libs/utility/operators.htm for documentation.
// Revision History // 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 // 24 May 07 Changed empty_base to depend on T, see
// http://svn.boost.org/trac/boost/ticket/979 // http://svn.boost.org/trac/boost/ticket/979
// 21 Oct 02 Modified implementation of operators to allow compilers with a // 21 Oct 02 Modified implementation of operators to allow compilers with a
@@ -124,34 +126,34 @@ namespace boost
template <class T, class U, class B = ::boost::detail::empty_base<T> > template <class T, class U, class B = ::boost::detail::empty_base<T> >
struct less_than_comparable2 : B 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 !static_cast<bool>(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<bool>(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 !(y < x); } friend bool operator<=(const U& x, const T& y) { return !static_cast<bool>(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<bool>(y > x); }
}; };
template <class T, class B = ::boost::detail::empty_base<T> > template <class T, class B = ::boost::detail::empty_base<T> >
struct less_than_comparable1 : B 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 !(y < x); } friend bool operator<=(const T& x, const T& y) { return !static_cast<bool>(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<bool>(x < y); }
}; };
template <class T, class U, class B = ::boost::detail::empty_base<T> > template <class T, class U, class B = ::boost::detail::empty_base<T> >
struct equality_comparable2 : B 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 U& y, const T& x) { return !(x == y); } friend bool operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
friend bool operator!=(const T& y, const U& x) { return !(y == x); } friend bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); }
}; };
template <class T, class B = ::boost::detail::empty_base<T> > template <class T, class B = ::boost::detail::empty_base<T> >
struct equality_comparable1 : B 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<bool>(x == y); }
}; };
// A macro which produces "name_2left" from "name". // A macro which produces "name_2left" from "name".
@@ -356,7 +358,7 @@ struct equivalent2 : B
{ {
friend bool operator==(const T& x, const U& y) friend bool operator==(const T& x, const U& y)
{ {
return !(x < y) && !(x > y); return !static_cast<bool>(x < y) && !static_cast<bool>(x > y);
} }
}; };
@@ -365,7 +367,7 @@ struct equivalent1 : B
{ {
friend bool operator==(const T&x, const T&y) friend bool operator==(const T&x, const T&y)
{ {
return !(x < y) && !(y < x); return !static_cast<bool>(x < y) && !static_cast<bool>(y < x);
} }
}; };
@@ -373,17 +375,17 @@ template <class T, class U, class B = ::boost::detail::empty_base<T> >
struct partially_ordered2 : B struct partially_ordered2 : B
{ {
friend bool operator<=(const T& x, const U& y) friend bool operator<=(const T& x, const U& y)
{ return (x < y) || (x == y); } { return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
friend bool operator>=(const T& x, const U& y) friend bool operator>=(const T& x, const U& y)
{ return (x > y) || (x == y); } { return static_cast<bool>(x > y) || static_cast<bool>(x == y); }
friend bool operator>(const U& x, const T& y) friend bool operator>(const U& x, const T& y)
{ return y < x; } { return y < x; }
friend bool operator<(const U& x, const T& y) friend bool operator<(const U& x, const T& y)
{ return y > x; } { return y > x; }
friend bool operator<=(const U& x, const T& y) friend bool operator<=(const U& x, const T& y)
{ return (y > x) || (y == x); } { return static_cast<bool>(y > x) || static_cast<bool>(y == x); }
friend bool operator>=(const U& x, const T& y) friend bool operator>=(const U& x, const T& y)
{ return (y < x) || (y == x); } { return static_cast<bool>(y < x) || static_cast<bool>(y == x); }
}; };
template <class T, class B = ::boost::detail::empty_base<T> > template <class T, class B = ::boost::detail::empty_base<T> >
@@ -392,9 +394,9 @@ struct partially_ordered1 : B
friend bool operator>(const T& x, const T& y) friend bool operator>(const T& x, const T& y)
{ return y < x; } { return y < x; }
friend bool operator<=(const T& x, const T& y) friend bool operator<=(const T& x, const T& y)
{ return (x < y) || (x == y); } { return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
friend bool operator>=(const T& x, const T& y) friend bool operator>=(const T& x, const T& y)
{ return (y < x) || (x == y); } { return static_cast<bool>(y < x) || static_cast<bool>(x == y); }
}; };
// Combined operator classes (contributed by Daryle Walker) ----------------// // Combined operator classes (contributed by Daryle Walker) ----------------//

View File

@@ -1,6 +1,7 @@
// Copyright (C) 2002 Brad King (brad.king@kitware.com) // Copyright (C) 2002 Brad King (brad.king@kitware.com)
// Douglas Gregor (gregod@cs.rpi.edu) // Douglas Gregor (gregod@cs.rpi.edu)
// Peter Dimov //
// Copyright (C) 2002, 2008 Peter Dimov
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -14,27 +15,31 @@
# include <boost/config.hpp> # include <boost/config.hpp>
# include <boost/detail/workaround.hpp> # include <boost/detail/workaround.hpp>
namespace boost { 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<class T> struct _addp
{ {
typedef T * type;
namespace detail
{
template<class T> struct addressof_impl
{
static inline T * f( T & v, long )
{
return reinterpret_cast<T*>(
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
}
static inline T * f( T * v, int )
{
return v;
}
}; };
template <typename T> typename _addp<T>::type
# else } // namespace detail
template <typename T> T*
# endif template<class T> T * addressof( T & v )
addressof(T& v)
{ {
return reinterpret_cast<T*>( return boost::detail::addressof_impl<T>::f( v, 0 );
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
} }
// Borland doesn't like casting an array reference to a char reference // 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 # endif
} } // namespace boost
#endif // BOOST_UTILITY_ADDRESSOF_HPP #endif // BOOST_UTILITY_ADDRESSOF_HPP

View File

@@ -10,6 +10,46 @@
# error Boost result_of - do not include this file! # error Boost result_of - do not include this file!
#endif #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<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
: mpl::if_<
mpl::or_< is_pointer<F>, is_member_function_pointer<F> >
, 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<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
class result_of_decltype_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
{
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 // CWPro8 requires an argument in a function type specialization
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0 #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0
# define BOOST_RESULT_OF_ARGS void # define BOOST_RESULT_OF_ARGS void
@@ -26,6 +66,8 @@ struct result_of<F(BOOST_RESULT_OF_ARGS)>
#undef BOOST_RESULT_OF_ARGS #undef BOOST_RESULT_OF_ARGS
#endif // defined(BOOST_HAS_DECLTYPE)
#if BOOST_PP_ITERATION() >= 1 #if BOOST_PP_ITERATION() >= 1
namespace detail { namespace detail {

View File

@@ -18,6 +18,9 @@
#include <boost/mpl/has_xxx.hpp> #include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/if.hpp> #include <boost/mpl/if.hpp>
#include <boost/mpl/bool.hpp> #include <boost/mpl/bool.hpp>
#include <boost/mpl/or.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_member_function_pointer.hpp>
#ifndef BOOST_RESULT_OF_NUM_ARGS #ifndef BOOST_RESULT_OF_NUM_ARGS
# define BOOST_RESULT_OF_NUM_ARGS 10 # define BOOST_RESULT_OF_NUM_ARGS 10
@@ -33,6 +36,7 @@ namespace detail {
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
template<typename F, typename FArgs, bool HasResultType> struct result_of_impl; template<typename F, typename FArgs, bool HasResultType> struct result_of_impl;
template<typename F> struct result_of_decltype_impl;
template<typename F> template<typename F>
struct result_of_void_impl struct result_of_void_impl

View File

@@ -5,7 +5,8 @@
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
// 21 Ago 2002 (Created) Fernando Cacciola // 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 #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
#define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
@@ -110,7 +111,7 @@ T& get ( value_initialized<T>& x )
} }
class initialized_value class initialized_value_t
{ {
public : public :
@@ -120,6 +121,8 @@ class initialized_value
} }
}; };
initialized_value_t const initialized_value = {} ;
} // namespace boost } // namespace boost

View File

@@ -7,6 +7,7 @@
// See http://www.boost.org/libs/utility for documentation. // See http://www.boost.org/libs/utility for documentation.
// Revision History // Revision History
// 03 Apr 08 Added convertible_to_bool (Daniel Frey)
// 01 Oct 01 Added tests for "left" operators // 01 Oct 01 Added tests for "left" operators
// and new grouped operators. (Helmut Zeisel) // and new grouped operators. (Helmut Zeisel)
// 20 May 01 Output progress messages. Added tests for new operator // 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 char true_value(unsigned char x) { return x; }
unsigned short true_value(unsigned short 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 // The use of operators<> here tended to obscure
// interactions with certain compiler bugs // interactions with certain compiler bugs
template <class T> template <class T>
@@ -54,8 +72,10 @@ namespace
explicit Wrapped1( T v = T() ) : _value(v) {} explicit Wrapped1( T v = T() ) : _value(v) {}
T value() const { return _value; } T value() const { return _value; }
bool operator<(const Wrapped1& x) const { return _value < x._value; } convertible_to_bool operator<(const Wrapped1& x) const
bool operator==(const Wrapped1& x) const { return _value == x._value; } { return _value < x._value; }
convertible_to_bool operator==(const Wrapped1& x) const
{ return _value == x._value; }
Wrapped1& operator+=(const Wrapped1& x) Wrapped1& operator+=(const Wrapped1& x)
{ _value += x._value; return *this; } { _value += x._value; return *this; }
@@ -97,8 +117,10 @@ namespace
explicit Wrapped2( T v = T() ) : _value(v) {} explicit Wrapped2( T v = T() ) : _value(v) {}
T value() const { return _value; } T value() const { return _value; }
bool operator<(const Wrapped2& x) const { return _value < x._value; } convertible_to_bool operator<(const Wrapped2& x) const
bool operator==(const Wrapped2& x) const { return _value == x._value; } { return _value < x._value; }
convertible_to_bool operator==(const Wrapped2& x) const
{ return _value == x._value; }
Wrapped2& operator+=(const Wrapped2& x) Wrapped2& operator+=(const Wrapped2& x)
{ _value += x._value; return *this; } { _value += x._value; return *this; }
@@ -123,9 +145,13 @@ namespace
Wrapped2& operator++() { ++_value; return *this; } Wrapped2& operator++() { ++_value; return *this; }
Wrapped2& operator--() { --_value; return *this; } Wrapped2& operator--() { --_value; return *this; }
bool operator<(U u) const { return _value < u; } convertible_to_bool operator<(U u) const
bool operator>(U u) const { return _value > u; } { 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; }
Wrapped2& operator+=(U u) { _value += u; return *this; } Wrapped2& operator+=(U u) { _value += u; return *this; }
Wrapped2& operator-=(U u) { _value -= u; return *this; } 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) {} explicit Wrapped3( T v = T() ) : _value(v) {}
T value() const { return _value; } 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: private:
T _value; T _value;
@@ -174,10 +201,13 @@ namespace
explicit Wrapped4( T v = T() ) : _value(v) {} explicit Wrapped4( T v = T() ) : _value(v) {}
T value() const { return _value; } 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; } convertible_to_bool operator<(U u) const
bool operator>(U u) const { return _value > u; } { return _value < u; }
convertible_to_bool operator>(U u) const
{ return _value > u; }
private: private:
T _value; T _value;
@@ -198,11 +228,18 @@ namespace
Wrapped5(U u) : _value(u) {} Wrapped5(U u) : _value(u) {}
T value() const { return _value; } T value() const { return _value; }
bool operator<(const Wrapped5& x) const { return _value < x._value; }
bool operator<(U u) const { return _value < u; } convertible_to_bool operator<(const Wrapped5& x) const
bool operator>(U u) const { return _value > u; } { return _value < x._value; }
bool operator==(const Wrapped5& u) const { return _value == u._value; } convertible_to_bool operator<(U u) const
bool operator==(U u) const { return _value == u; } { 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/=(const Wrapped5& u) { _value /= u._value; return *this;}
Wrapped5& operator/=(U u) { _value /= u; return *this;} Wrapped5& operator/=(U u) { _value /= u; return *this;}
Wrapped5& operator*=(const Wrapped5& u) { _value *= u._value; return *this;} Wrapped5& operator*=(const Wrapped5& u) { _value *= u._value; return *this;}
@@ -231,11 +268,18 @@ namespace
Wrapped6(U u) : _value(u) {} Wrapped6(U u) : _value(u) {}
T value() const { return _value; } T value() const { return _value; }
bool operator<(const Wrapped6& x) const { return _value < x._value; }
bool operator<(U u) const { return _value < u; } convertible_to_bool operator<(const Wrapped6& x) const
bool operator>(U u) const { return _value > u; } { return _value < x._value; }
bool operator==(const Wrapped6& u) const { return _value == u._value; } convertible_to_bool operator<(U u) const
bool operator==(U u) const { return _value == u; } { 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%=(const Wrapped6& u) { _value %= u._value; return *this;}
Wrapped6& operator%=(U u) { _value %= u; return *this;} Wrapped6& operator%=(U u) { _value %= u; return *this;}
Wrapped6& operator/=(const Wrapped6& u) { _value /= u._value; return *this;} Wrapped6& operator/=(const Wrapped6& u) { _value /= u._value; return *this;}
@@ -276,10 +320,10 @@ namespace
template <class X1, class Y1, class X2, class Y2> template <class X1, class Y1, class X2, class Y2>
void test_less_than_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2) void test_less_than_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2)
{ {
BOOST_CHECK( (x1 < y1) == (x2 < y2) ); BOOST_CHECK( static_cast<bool>(x1 < y1) == static_cast<bool>(x2 < y2) );
BOOST_CHECK( (x1 <= y1) == (x2 <= y2) ); BOOST_CHECK( static_cast<bool>(x1 <= y1) == static_cast<bool>(x2 <= y2) );
BOOST_CHECK( (x1 >= y1) == (x2 >= y2) ); BOOST_CHECK( static_cast<bool>(x1 >= y1) == static_cast<bool>(x2 >= y2) );
BOOST_CHECK( (x1 > y1) == (x2 > y2) ); BOOST_CHECK( static_cast<bool>(x1 > y1) == static_cast<bool>(x2 > y2) );
} }
template <class X1, class Y1, class X2, class Y2> template <class X1, class Y1, class X2, class Y2>
@@ -293,8 +337,8 @@ namespace
template <class X1, class Y1, class X2, class Y2> template <class X1, class Y1, class X2, class Y2>
void test_equality_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2) void test_equality_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2)
{ {
BOOST_CHECK( (x1 == y1) == (x2 == y2) ); BOOST_CHECK( static_cast<bool>(x1 == y1) == static_cast<bool>(x2 == y2) );
BOOST_CHECK( (x1 != y1) == (x2 != y2) ); BOOST_CHECK( static_cast<bool>(x1 != y1) == static_cast<bool>(x2 != y2) );
} }
template <class X1, class Y1, class X2, class Y2> template <class X1, class Y1, class X2, class Y2>
@@ -614,14 +658,14 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (i = i2), (i.value() == 2) ); PRIVATE_EXPR_TEST( (i = i2), (i.value() == 2) );
BOOST_CHECK( i2 == i ); BOOST_CHECK( static_cast<bool>(i2 == i) );
BOOST_CHECK( i1 != i2 ); BOOST_CHECK( static_cast<bool>(i1 != i2) );
BOOST_CHECK( i1 < i2 ); BOOST_CHECK( static_cast<bool>(i1 < i2) );
BOOST_CHECK( i1 <= i2 ); BOOST_CHECK( static_cast<bool>(i1 <= i2) );
BOOST_CHECK( i <= i2 ); BOOST_CHECK( static_cast<bool>(i <= i2) );
BOOST_CHECK( i2 > i1 ); BOOST_CHECK( static_cast<bool>(i2 > i1) );
BOOST_CHECK( i2 >= i1 ); BOOST_CHECK( static_cast<bool>(i2 >= i1) );
BOOST_CHECK( i2 >= i ); BOOST_CHECK( static_cast<bool>(i2 >= i) );
PRIVATE_EXPR_TEST( (i = i1 + i2), (i.value() == 3) ); PRIVATE_EXPR_TEST( (i = i1 + i2), (i.value() == 3) );
PRIVATE_EXPR_TEST( (i = i + i2), (i.value() == 5) ); 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) ); PRIVATE_EXPR_TEST( (j = j2), (j.value() == 2) );
BOOST_CHECK( j2 == j ); BOOST_CHECK( static_cast<bool>(j2 == j) );
BOOST_CHECK( 2 == j ); BOOST_CHECK( static_cast<bool>(2 == j) );
BOOST_CHECK( j2 == 2 ); BOOST_CHECK( static_cast<bool>(j2 == 2) );
BOOST_CHECK( j == j2 ); BOOST_CHECK( static_cast<bool>(j == j2) );
BOOST_CHECK( j1 != j2 ); BOOST_CHECK( static_cast<bool>(j1 != j2) );
BOOST_CHECK( j1 != 2 ); BOOST_CHECK( static_cast<bool>(j1 != 2) );
BOOST_CHECK( 1 != j2 ); BOOST_CHECK( static_cast<bool>(1 != j2) );
BOOST_CHECK( j1 < j2 ); BOOST_CHECK( static_cast<bool>(j1 < j2) );
BOOST_CHECK( 1 < j2 ); BOOST_CHECK( static_cast<bool>(1 < j2) );
BOOST_CHECK( j1 < 2 ); BOOST_CHECK( static_cast<bool>(j1 < 2) );
BOOST_CHECK( j1 <= j2 ); BOOST_CHECK( static_cast<bool>(j1 <= j2) );
BOOST_CHECK( 1 <= j2 ); BOOST_CHECK( static_cast<bool>(1 <= j2) );
BOOST_CHECK( j1 <= j ); BOOST_CHECK( static_cast<bool>(j1 <= j) );
BOOST_CHECK( j <= j2 ); BOOST_CHECK( static_cast<bool>(j <= j2) );
BOOST_CHECK( 2 <= j2 ); BOOST_CHECK( static_cast<bool>(2 <= j2) );
BOOST_CHECK( j <= 2 ); BOOST_CHECK( static_cast<bool>(j <= 2) );
BOOST_CHECK( j2 > j1 ); BOOST_CHECK( static_cast<bool>(j2 > j1) );
BOOST_CHECK( 2 > j1 ); BOOST_CHECK( static_cast<bool>(2 > j1) );
BOOST_CHECK( j2 > 1 ); BOOST_CHECK( static_cast<bool>(j2 > 1) );
BOOST_CHECK( j2 >= j1 ); BOOST_CHECK( static_cast<bool>(j2 >= j1) );
BOOST_CHECK( 2 >= j1 ); BOOST_CHECK( static_cast<bool>(2 >= j1) );
BOOST_CHECK( j2 >= 1 ); BOOST_CHECK( static_cast<bool>(j2 >= 1) );
BOOST_CHECK( j2 >= j ); BOOST_CHECK( static_cast<bool>(j2 >= j) );
BOOST_CHECK( 2 >= j ); BOOST_CHECK( static_cast<bool>(2 >= j) );
BOOST_CHECK( j2 >= 2 ); BOOST_CHECK( static_cast<bool>(j2 >= 2) );
BOOST_CHECK( (j1 + 2) == 3 ); BOOST_CHECK( static_cast<bool>((j1 + 2) == 3) );
BOOST_CHECK( (1 + j2) == 3 ); BOOST_CHECK( static_cast<bool>((1 + j2) == 3) );
PRIVATE_EXPR_TEST( (j = j1 + j2), (j.value() == 3) ); PRIVATE_EXPR_TEST( (j = j1 + j2), (j.value() == 3) );
BOOST_CHECK( (j + 2) == 5 ); BOOST_CHECK( static_cast<bool>((j + 2) == 5) );
BOOST_CHECK( (3 + j2) == 5 ); BOOST_CHECK( static_cast<bool>((3 + j2) == 5) );
PRIVATE_EXPR_TEST( (j = j + j2), (j.value() == 5) ); PRIVATE_EXPR_TEST( (j = j + j2), (j.value() == 5) );
BOOST_CHECK( (j - 1) == 4 ); BOOST_CHECK( static_cast<bool>((j - 1) == 4) );
PRIVATE_EXPR_TEST( (j = j - j1), (j.value() == 4) ); PRIVATE_EXPR_TEST( (j = j - j1), (j.value() == 4) );
BOOST_CHECK( (j * 2) == 8 ); BOOST_CHECK( static_cast<bool>((j * 2) == 8) );
BOOST_CHECK( (4 * j2) == 8 ); BOOST_CHECK( static_cast<bool>((4 * j2) == 8) );
PRIVATE_EXPR_TEST( (j = j * j2), (j.value() == 8) ); PRIVATE_EXPR_TEST( (j = j * j2), (j.value() == 8) );
BOOST_CHECK( (j / 2) == 4 ); BOOST_CHECK( static_cast<bool>((j / 2) == 4) );
PRIVATE_EXPR_TEST( (j = j / j2), (j.value() == 4) ); PRIVATE_EXPR_TEST( (j = j / j2), (j.value() == 4) );
BOOST_CHECK( (j % 3) == 1 ); BOOST_CHECK( static_cast<bool>((j % 3) == 1) );
PRIVATE_EXPR_TEST( (j = j % ( j - j1 )), (j.value() == 1) ); PRIVATE_EXPR_TEST( (j = j % ( j - j1 )), (j.value() == 1) );
PRIVATE_EXPR_TEST( (j = j2 + j2), (j.value() == 4) ); PRIVATE_EXPR_TEST( (j = j2 + j2), (j.value() == 4) );
BOOST_CHECK( (1 | j2 | j) == 7 ); BOOST_CHECK( static_cast<bool>((1 | j2 | j) == 7) );
BOOST_CHECK( (j1 | 2 | j) == 7 ); BOOST_CHECK( static_cast<bool>((j1 | 2 | j) == 7) );
BOOST_CHECK( (j1 | j2 | 4) == 7 ); BOOST_CHECK( static_cast<bool>((j1 | j2 | 4) == 7) );
PRIVATE_EXPR_TEST( (j = j1 | j2 | j), (j.value() == 7) ); PRIVATE_EXPR_TEST( (j = j1 | j2 | j), (j.value() == 7) );
BOOST_CHECK( (7 & j2) == 2 ); BOOST_CHECK( static_cast<bool>((7 & j2) == 2) );
BOOST_CHECK( (j & 2) == 2 ); BOOST_CHECK( static_cast<bool>((j & 2) == 2) );
PRIVATE_EXPR_TEST( (j = j & j2), (j.value() == 2) ); PRIVATE_EXPR_TEST( (j = j & j2), (j.value() == 2) );
PRIVATE_EXPR_TEST( (j = j | j1), (j.value() == 3) ); PRIVATE_EXPR_TEST( (j = j | j1), (j.value() == 3) );
BOOST_CHECK( (3 ^ j1) == 2 ); BOOST_CHECK( static_cast<bool>((3 ^ j1) == 2) );
BOOST_CHECK( (j ^ 1) == 2 ); BOOST_CHECK( static_cast<bool>((j ^ 1) == 2) );
PRIVATE_EXPR_TEST( (j = j ^ j1), (j.value() == 2) ); PRIVATE_EXPR_TEST( (j = j ^ j1), (j.value() == 2) );
PRIVATE_EXPR_TEST( (j = ( j + j1 ) * ( j2 | j1 )), (j.value() == 9) ); PRIVATE_EXPR_TEST( (j = ( j + j1 ) * ( j2 | j1 )), (j.value() == 9) );
BOOST_CHECK( (j1 << 2) == 4 ); BOOST_CHECK( static_cast<bool>((j1 << 2) == 4) );
BOOST_CHECK( (j2 << 1) == 4 ); BOOST_CHECK( static_cast<bool>((j2 << 1) == 4) );
PRIVATE_EXPR_TEST( (j = j1 << j2), (j.value() == 4) ); PRIVATE_EXPR_TEST( (j = j1 << j2), (j.value() == 4) );
BOOST_CHECK( (j >> 2) == 1 ); BOOST_CHECK( static_cast<bool>((j >> 2) == 1) );
BOOST_CHECK( (j2 >> 1) == 1 ); BOOST_CHECK( static_cast<bool>((j2 >> 1) == 1) );
PRIVATE_EXPR_TEST( (j = j2 >> j1), (j.value() == 1) ); PRIVATE_EXPR_TEST( (j = j2 >> j1), (j.value() == 1) );
cout << "Performed tests on MyLong objects.\n"; cout << "Performed tests on MyLong objects.\n";
@@ -741,14 +785,14 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (k = k2), (k.value() == 2) ); PRIVATE_EXPR_TEST( (k = k2), (k.value() == 2) );
BOOST_CHECK( k2 == k ); BOOST_CHECK( static_cast<bool>(k2 == k) );
BOOST_CHECK( k1 != k2 ); BOOST_CHECK( static_cast<bool>(k1 != k2) );
BOOST_CHECK( k1 < k2 ); BOOST_CHECK( static_cast<bool>(k1 < k2) );
BOOST_CHECK( k1 <= k2 ); BOOST_CHECK( static_cast<bool>(k1 <= k2) );
BOOST_CHECK( k <= k2 ); BOOST_CHECK( static_cast<bool>(k <= k2) );
BOOST_CHECK( k2 > k1 ); BOOST_CHECK( static_cast<bool>(k2 > k1) );
BOOST_CHECK( k2 >= k1 ); BOOST_CHECK( static_cast<bool>(k2 >= k1) );
BOOST_CHECK( k2 >= k ); BOOST_CHECK( static_cast<bool>(k2 >= k) );
cout << "Performed tests on MyChar objects.\n"; cout << "Performed tests on MyChar objects.\n";
@@ -764,31 +808,31 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (l = l2), (l.value() == 2) ); PRIVATE_EXPR_TEST( (l = l2), (l.value() == 2) );
BOOST_CHECK( l2 == l ); BOOST_CHECK( static_cast<bool>(l2 == l) );
BOOST_CHECK( 2 == l ); BOOST_CHECK( static_cast<bool>(2 == l) );
BOOST_CHECK( l2 == 2 ); BOOST_CHECK( static_cast<bool>(l2 == 2) );
BOOST_CHECK( l == l2 ); BOOST_CHECK( static_cast<bool>(l == l2) );
BOOST_CHECK( l1 != l2 ); BOOST_CHECK( static_cast<bool>(l1 != l2) );
BOOST_CHECK( l1 != 2 ); BOOST_CHECK( static_cast<bool>(l1 != 2) );
BOOST_CHECK( 1 != l2 ); BOOST_CHECK( static_cast<bool>(1 != l2) );
BOOST_CHECK( l1 < l2 ); BOOST_CHECK( static_cast<bool>(l1 < l2) );
BOOST_CHECK( 1 < l2 ); BOOST_CHECK( static_cast<bool>(1 < l2) );
BOOST_CHECK( l1 < 2 ); BOOST_CHECK( static_cast<bool>(l1 < 2) );
BOOST_CHECK( l1 <= l2 ); BOOST_CHECK( static_cast<bool>(l1 <= l2) );
BOOST_CHECK( 1 <= l2 ); BOOST_CHECK( static_cast<bool>(1 <= l2) );
BOOST_CHECK( l1 <= l ); BOOST_CHECK( static_cast<bool>(l1 <= l) );
BOOST_CHECK( l <= l2 ); BOOST_CHECK( static_cast<bool>(l <= l2) );
BOOST_CHECK( 2 <= l2 ); BOOST_CHECK( static_cast<bool>(2 <= l2) );
BOOST_CHECK( l <= 2 ); BOOST_CHECK( static_cast<bool>(l <= 2) );
BOOST_CHECK( l2 > l1 ); BOOST_CHECK( static_cast<bool>(l2 > l1) );
BOOST_CHECK( 2 > l1 ); BOOST_CHECK( static_cast<bool>(2 > l1) );
BOOST_CHECK( l2 > 1 ); BOOST_CHECK( static_cast<bool>(l2 > 1) );
BOOST_CHECK( l2 >= l1 ); BOOST_CHECK( static_cast<bool>(l2 >= l1) );
BOOST_CHECK( 2 >= l1 ); BOOST_CHECK( static_cast<bool>(2 >= l1) );
BOOST_CHECK( l2 >= 1 ); BOOST_CHECK( static_cast<bool>(l2 >= 1) );
BOOST_CHECK( l2 >= l ); BOOST_CHECK( static_cast<bool>(l2 >= l) );
BOOST_CHECK( 2 >= l ); BOOST_CHECK( static_cast<bool>(2 >= l) );
BOOST_CHECK( l2 >= 2 ); BOOST_CHECK( static_cast<bool>(l2 >= 2) );
cout << "Performed tests on MyShort objects.\n"; cout << "Performed tests on MyShort objects.\n";
@@ -807,37 +851,37 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (di = di2), (di.value() == 2) ); PRIVATE_EXPR_TEST( (di = di2), (di.value() == 2) );
BOOST_CHECK( di2 == di ); BOOST_CHECK( static_cast<bool>(di2 == di) );
BOOST_CHECK( 2 == di ); BOOST_CHECK( static_cast<bool>(2 == di) );
BOOST_CHECK( di == 2 ); BOOST_CHECK( static_cast<bool>(di == 2) );
BOOST_CHECK( di1 < di2 ); BOOST_CHECK( static_cast<bool>(di1 < di2) );
BOOST_CHECK( 1 < di2 ); BOOST_CHECK( static_cast<bool>(1 < di2) );
BOOST_CHECK( di1 <= di2 ); BOOST_CHECK( static_cast<bool>(di1 <= di2) );
BOOST_CHECK( 1 <= di2 ); BOOST_CHECK( static_cast<bool>(1 <= di2) );
BOOST_CHECK( di2 > di1 ); BOOST_CHECK( static_cast<bool>(di2 > di1) );
BOOST_CHECK( di2 > 1 ); BOOST_CHECK( static_cast<bool>(di2 > 1) );
BOOST_CHECK( di2 >= di1 ); BOOST_CHECK( static_cast<bool>(di2 >= di1) );
BOOST_CHECK( di2 >= 1 ); BOOST_CHECK( static_cast<bool>(di2 >= 1) );
BOOST_CHECK( di1 / di2 == half ); BOOST_CHECK( static_cast<bool>(di1 / di2 == half) );
BOOST_CHECK( di1 / 2 == half ); BOOST_CHECK( static_cast<bool>(di1 / 2 == half) );
BOOST_CHECK( 1 / di2 == half ); BOOST_CHECK( static_cast<bool>(1 / di2 == half) );
PRIVATE_EXPR_TEST( (tmp=di1), ((tmp/=2) == half) ); PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp/=2) == half) );
PRIVATE_EXPR_TEST( (tmp=di1), ((tmp/=di2) == half) ); PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp/=di2) == half) );
BOOST_CHECK( di1 * di2 == di2 ); BOOST_CHECK( static_cast<bool>(di1 * di2 == di2) );
BOOST_CHECK( di1 * 2 == di2 ); BOOST_CHECK( static_cast<bool>(di1 * 2 == di2) );
BOOST_CHECK( 1 * di2 == di2 ); BOOST_CHECK( static_cast<bool>(1 * di2 == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), ((tmp*=2) == di2) ); PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp*=2) == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), ((tmp*=di2) == di2) ); PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp*=di2) == di2) );
BOOST_CHECK( di2 - di1 == di1 ); BOOST_CHECK( static_cast<bool>(di2 - di1 == di1) );
BOOST_CHECK( di2 - 1 == di1 ); BOOST_CHECK( static_cast<bool>(di2 - 1 == di1) );
BOOST_CHECK( 2 - di1 == di1 ); BOOST_CHECK( static_cast<bool>(2 - di1 == di1) );
PRIVATE_EXPR_TEST( (tmp=di2), ((tmp-=1) == di1) ); PRIVATE_EXPR_TEST( (tmp=di2), static_cast<bool>((tmp-=1) == di1) );
PRIVATE_EXPR_TEST( (tmp=di2), ((tmp-=di1) == di1) ); PRIVATE_EXPR_TEST( (tmp=di2), static_cast<bool>((tmp-=di1) == di1) );
BOOST_CHECK( di1 + di1 == di2 ); BOOST_CHECK( static_cast<bool>(di1 + di1 == di2) );
BOOST_CHECK( di1 + 1 == di2 ); BOOST_CHECK( static_cast<bool>(di1 + 1 == di2) );
BOOST_CHECK( 1 + di1 == di2 ); BOOST_CHECK( static_cast<bool>(1 + di1 == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), ((tmp+=1) == di2) ); PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp+=1) == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), ((tmp+=di1) == di2) ); PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp+=di1) == di2) );
cout << "Performed tests on MyDoubleInt objects.\n"; cout << "Performed tests on MyDoubleInt objects.\n";
@@ -854,42 +898,42 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (li = li2), (li.value() == 2) ); PRIVATE_EXPR_TEST( (li = li2), (li.value() == 2) );
BOOST_CHECK( li2 == li ); BOOST_CHECK( static_cast<bool>(li2 == li) );
BOOST_CHECK( 2 == li ); BOOST_CHECK( static_cast<bool>(2 == li) );
BOOST_CHECK( li == 2 ); BOOST_CHECK( static_cast<bool>(li == 2) );
BOOST_CHECK( li1 < li2 ); BOOST_CHECK( static_cast<bool>(li1 < li2) );
BOOST_CHECK( 1 < li2 ); BOOST_CHECK( static_cast<bool>(1 < li2) );
BOOST_CHECK( li1 <= li2 ); BOOST_CHECK( static_cast<bool>(li1 <= li2) );
BOOST_CHECK( 1 <= li2 ); BOOST_CHECK( static_cast<bool>(1 <= li2) );
BOOST_CHECK( li2 > li1 ); BOOST_CHECK( static_cast<bool>(li2 > li1) );
BOOST_CHECK( li2 > 1 ); BOOST_CHECK( static_cast<bool>(li2 > 1) );
BOOST_CHECK( li2 >= li1 ); BOOST_CHECK( static_cast<bool>(li2 >= li1) );
BOOST_CHECK( li2 >= 1 ); BOOST_CHECK( static_cast<bool>(li2 >= 1) );
BOOST_CHECK( li1 % li2 == li1 ); BOOST_CHECK( static_cast<bool>(li1 % li2 == li1) );
BOOST_CHECK( li1 % 2 == li1 ); BOOST_CHECK( static_cast<bool>(li1 % 2 == li1) );
BOOST_CHECK( 1 % li2 == li1 ); BOOST_CHECK( static_cast<bool>(1 % li2 == li1) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2%=2) == li1) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2%=2) == li1) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2%=li2) == li1) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2%=li2) == li1) );
BOOST_CHECK( li1 / li2 == 0 ); BOOST_CHECK( static_cast<bool>(li1 / li2 == 0) );
BOOST_CHECK( li1 / 2 == 0 ); BOOST_CHECK( static_cast<bool>(li1 / 2 == 0) );
BOOST_CHECK( 1 / li2 == 0 ); BOOST_CHECK( static_cast<bool>(1 / li2 == 0) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2/=2) == 0) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2/=2) == 0) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2/=li2) == 0) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2/=li2) == 0) );
BOOST_CHECK( li1 * li2 == li2 ); BOOST_CHECK( static_cast<bool>(li1 * li2 == li2) );
BOOST_CHECK( li1 * 2 == li2 ); BOOST_CHECK( static_cast<bool>(li1 * 2 == li2) );
BOOST_CHECK( 1 * li2 == li2 ); BOOST_CHECK( static_cast<bool>(1 * li2 == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2*=2) == li2) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2*=2) == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2*=li2) == li2) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2*=li2) == li2) );
BOOST_CHECK( li2 - li1 == li1 ); BOOST_CHECK( static_cast<bool>(li2 - li1 == li1) );
BOOST_CHECK( li2 - 1 == li1 ); BOOST_CHECK( static_cast<bool>(li2 - 1 == li1) );
BOOST_CHECK( 2 - li1 == li1 ); BOOST_CHECK( static_cast<bool>(2 - li1 == li1) );
PRIVATE_EXPR_TEST( (tmp2=li2), ((tmp2-=1) == li1) ); PRIVATE_EXPR_TEST( (tmp2=li2), static_cast<bool>((tmp2-=1) == li1) );
PRIVATE_EXPR_TEST( (tmp2=li2), ((tmp2-=li1) == li1) ); PRIVATE_EXPR_TEST( (tmp2=li2), static_cast<bool>((tmp2-=li1) == li1) );
BOOST_CHECK( li1 + li1 == li2 ); BOOST_CHECK( static_cast<bool>(li1 + li1 == li2) );
BOOST_CHECK( li1 + 1 == li2 ); BOOST_CHECK( static_cast<bool>(li1 + 1 == li2) );
BOOST_CHECK( 1 + li1 == li2 ); BOOST_CHECK( static_cast<bool>(1 + li1 == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2+=1) == li2) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2+=1) == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2+=li1) == li2) ); PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2+=li1) == li2) );
cout << "Performed tests on MyLongInt objects.\n"; cout << "Performed tests on MyLongInt objects.\n";

View File

@@ -315,7 +315,7 @@ Last modified: Mon Aug 11 11:27:03 EST 2003
<p><EFBFBD> Copyright 2003 The Trustees of Indiana University. <p><EFBFBD> Copyright 2003 The Trustees of Indiana University.
Use, modification and distribution is subject to the Boost Software Use, modification and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http:www.boost.org/LICENSE_1_0.txt)</p> http://www.boost.org/LICENSE_1_0.txt)</p>
</body> </body>

0
test/next_prior_test.cpp Executable file → Normal file
View File

View File

@@ -11,35 +11,101 @@
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp> #include <boost/type_traits/is_same.hpp>
struct int_result_type { typedef int result_type; }; struct int_result_type
{
typedef int result_type;
result_type operator()(float);
};
struct int_result_of struct int_result_of
{ {
template<typename F> struct result { typedef int type; }; template<typename F> struct result { typedef int type; };
result<int_result_of(double)>::type operator()(double);
result<const int_result_of(double)>::type operator()(double) const;
result<int_result_of()>::type operator()();
result<volatile int_result_of()>::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; typedef int result_type;
template<typename F> struct result { typedef float type; }; template<typename F> struct result { typedef float type; };
char operator()(char);
}; };
template<typename T> template<typename T>
struct int_result_type_template { typedef int result_type; }; struct int_result_type_template
{
typedef int result_type;
result_type operator()(float);
};
template<typename T> template<typename T>
struct int_result_of_template struct int_result_of_template
{ {
template<typename F> struct result; template<typename F> struct result;
template<typename This, typename That> struct result<This(That)> { typedef int type; }; template<typename This, typename That> struct result<This(That)> { typedef int type; };
typename result<int_result_of_template<T>(double)>::type operator()(double);
typename result<const int_result_of_template<T>(double)>::type operator()(double) const;
typename result<int_result_of_template<T>(double)>::type operator()();
typename result<volatile int_result_of_template<T>(double)>::type operator()() volatile;
}; };
template<typename T> template<typename T>
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; typedef int result_type;
template<typename F> struct result; template<typename F> struct result;
template<typename This, typename That> struct result<This(That)> { typedef float type; }; template<typename This, typename That> struct result<This(That)> { typedef float type; };
char operator()(char);
};
struct result_of_member_function_template
{
template<typename F> struct result;
template<typename This, typename That> struct result<This(That)> { typedef That type; };
template<class T> typename result<result_of_member_function_template(T)>::type operator()(T);
template<typename This, typename That> struct result<const This(That)> { typedef const That type; };
template<class T> typename result<const result_of_member_function_template(T)>::type operator()(T) const;
template<typename This, typename That> struct result<volatile This(That)> { typedef volatile That type; };
template<class T> typename result<volatile result_of_member_function_template(T)>::type operator()(T) volatile;
template<typename This, typename That> struct result<const volatile This(That)> { typedef const volatile That type; };
template<class T> typename result<const volatile result_of_member_function_template(T)>::type operator()(T) const volatile;
template<typename This, typename That> struct result<This(That &, That)> { typedef That & type; };
template<class T> typename result<result_of_member_function_template(T &, T)>::type operator()(T &, T);
template<typename This, typename That> struct result<This(That const &, That)> { typedef That const & type; };
template<class T> typename result<result_of_member_function_template(T const &, T)>::type operator()(T const &, T);
template<typename This, typename That> struct result<This(That volatile &, That)> { typedef That volatile & type; };
template<class T> typename result<result_of_member_function_template(T volatile &, T)>::type operator()(T volatile &, T);
template<typename This, typename That> struct result<This(That const volatile &, That)> { typedef That const volatile & type; };
template<class T> typename result<result_of_member_function_template(T const volatile &, T)>::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<typename T>
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 {}; struct X {};
@@ -60,16 +126,37 @@ int main()
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type(float)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<int_result_type(float)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(double)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of(double)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of(char)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_template<void>(float)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_template<void>(float)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(double)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of_template<void>(double)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of_template<void>(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<result_of<int_result_of(void)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, int>::value));
#else
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, void>::value)); BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, void>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_template<void>(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<result_of<int_result_type_and_float_result_of_and_char_return(char)>::type, char>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return_template<void>(char)>::type, char>::value));
#else
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return(char)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return_template<void>(char)>::type, int>::value));
#endif
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(char, float)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(char, float)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<func_ref(char, float)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<func_ref(char, float)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr_0()>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<func_ptr_0()>::type, int>::value));
@@ -81,5 +168,27 @@ int main()
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_0(X)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_0(X)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(void)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(void)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(double)>::type, double>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const result_of_member_function_template(double)>::type, const double>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile result_of_member_function_template(double)>::type, volatile double>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const volatile result_of_member_function_template(double)>::type, const volatile double>::value));
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int &, int)>::type, int &>::value));
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int const &, int)>::type, int const &>::value));
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int volatile &, int)>::type, int volatile &>::value));
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int const volatile &, int)>::type, int const volatile &>::value));
#if defined(BOOST_HAS_DECLTYPE)
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(void)>::type, unsigned int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const no_result_type_or_result_of(double)>::type, short>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile no_result_type_or_result_of(void)>::type, unsigned short>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const volatile no_result_type_or_result_of(void)>::type, const unsigned short>::value));
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(double)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(void)>::type, unsigned int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const no_result_type_or_result_of_template<void>(double)>::type, short>::value));
BOOST_STATIC_ASSERT((is_same<result_of<volatile no_result_type_or_result_of_template<void>(void)>::type, unsigned short>::value));
BOOST_STATIC_ASSERT((is_same<result_of<const volatile no_result_type_or_result_of_template<void>(void)>::type, const unsigned short>::value));
#endif
return 0; return 0;
} }

View File

@@ -152,11 +152,13 @@ void f() {
...,t<em>N</em>)</code>. The implementation permits ...,t<em>N</em>)</code>. The implementation permits
the type <code>F</code> to be a function pointer, the type <code>F</code> to be a function pointer,
function reference, member function pointer, or class function reference, member function pointer, or class
type. When <code>F</code> is a class type with a type.</p> <p>If your compiler does not support
member type <code>result_type</code>, <code>decltype</code>, then when <code>F</code> is a
class type with a member type <code>result_type</code>,
<code>result_of&lt;F(T1, T2, ..., <code>result_of&lt;F(T1, T2, ...,
T<em>N</em>)&gt;</code> is T<em>N</em>)&gt;</code> is
<code>F::result_type</code>. Otherwise, <code>F::result_type</code>. When <code>F</code>
does not contain <code>result_type</code>,
<code>result_of&lt;F(T1, T2, ..., <code>result_of&lt;F(T1, T2, ...,
T<em>N</em>)&gt;</code> is <code>F::result&lt;F(T1, T<em>N</em>)&gt;</code> is <code>F::result&lt;F(T1,
T2, ..., T<em>N</em>)&gt;::type</code> when T2, ..., T<em>N</em>)&gt;::type</code> when

View File

@@ -28,12 +28,12 @@
</ul> </ul>
<dl class="page-index"> <dl class="page-index">
<dt><a href="#types">Types</a></dt> <dt><a href="#types">Types and objects</a></dt>
</dl> </dl>
<ul> <ul>
<li><a href="#val_init"><code>template class value_initialized&lt;T&gt;</code></a></li> <li><a href="#val_init"><code>template class value_initialized&lt;T&gt;</code></a></li>
<li><a href="#initialized_value"><code>class initialized_value</code></a></li> <li><a href="#initialized_value"><code>initialized_value</code></a></li>
</ul> </ul>
<a href="#acknowledgements">Acknowledgements</a><br> <a href="#acknowledgements">Acknowledgements</a><br>
@@ -53,7 +53,7 @@ union and class types.
Moreover, <code>value_initialized</code> offers a workaround to various Moreover, <code>value_initialized</code> offers a workaround to various
compiler issues regarding value-initialization. compiler issues regarding value-initialization.
Furthermore a convenience class, <code>initialized_value</code> is provided, Furthermore, a <code>const</code> object, <code>initialized_value</code> is provided,
to avoid repeating the type name when retrieving the value from a to avoid repeating the type name when retrieving the value from a
<code>value_initialized&lt;T&gt;</code> object. <code>value_initialized&lt;T&gt;</code> object.
<br> <br>
@@ -123,12 +123,12 @@ constructed by the following declaration:
</pre> </pre>
</p> </p>
<p> <p>
The convenience class <a href="#initialized_value"><code>initialized_value</code></a> The <code>const</code> object <a href="#initialized_value"><code>initialized_value</code></a>
allows value-initializing a variable as follows: allows value-initializing a variable as follows:
<pre> <pre>
T var = initialized_value(); T var = initialized_value ;
</pre> </pre>
This form of initialization is also very similar to <code>T4 var4 = T4()</code>, This form of initialization is semantically equivalent to <code>T4 var4 = T4()</code>,
but robust against the aforementioned compiler issues. but robust against the aforementioned compiler issues.
</p> </p>
@@ -249,7 +249,7 @@ offer a workaround to these issues: <code>value_initialized</code> will now clea
its internal data, prior to constructing the object that it contains. its internal data, prior to constructing the object that it contains.
</p> </p>
<h2><a name="types"></a>Types</h2> <h2><a name="types"></a>Types and objects</h2>
<h2><a name="val_init"><code>template class value_initialized&lt;T&gt;</code></a></h2> <h2><a name="val_init"><code>template class value_initialized&lt;T&gt;</code></a></h2>
@@ -312,19 +312,22 @@ the wrapped object is always performed with the <code>get()</code> idiom:</p>
<pre>value_initialized&lt;int&gt; x ;<br>get(x) = 1 ; // OK<br><br>value_initialized&lt;int const&gt; cx ;<br>get(x) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized&lt;int&gt; const x_c ;<br>get(x_c) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized&lt;int const&gt; const cx_c ;<br>get(cx_c) = 1 ; // ERROR: Cannot modify a const object<br></pre> <pre>value_initialized&lt;int&gt; x ;<br>get(x) = 1 ; // OK<br><br>value_initialized&lt;int const&gt; cx ;<br>get(x) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized&lt;int&gt; const x_c ;<br>get(x_c) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized&lt;int const&gt; const cx_c ;<br>get(cx_c) = 1 ; // ERROR: Cannot modify a const object<br></pre>
<h2><a name="initialized_value"><code>class initialized_value</code></a></h2> <h2><a name="initialized_value"><code>initialized_value</code></a></h2>
<pre> <pre>
namespace boost { namespace boost {
class initialized_value class initialized_value_t
{ {
public : public :
template &lt;class T&gt; operator T() const ; template &lt;class T&gt; operator T() const ;
}; };
initialized_value_t const initialized_value = {} ;
} // namespace boost } // namespace boost
</pre> </pre>
The class <code>initialized_value</code> provides a convenient way to get <code>initialized_value</code> provides a convenient way to get
an initialized value: its conversion operator provides an appropriate an initialized value: its conversion operator provides an appropriate
<em>value-initialized</em> object for any CopyConstructible type. <em>value-initialized</em> object for any CopyConstructible type.
@@ -343,7 +346,7 @@ is rather short now (<code>T</code>), but could of course be
more like <code>Namespace::Template&lt;Arg&gt;::Type</code>. more like <code>Namespace::Template&lt;Arg&gt;::Type</code>.
Instead, one could use <code>initialized_value</code> as follows: Instead, one could use <code>initialized_value</code> as follows:
<pre> <pre>
T var = initialized_value(); T var = initialized_value ;
</pre> </pre>
<h3><a name="references">References</a></h3> <h3><a name="references">References</a></h3>
@@ -368,13 +371,15 @@ Special thanks to Bj&ouml;rn Karlsson who carefully edited and completed this do
<p>value_initialized was reimplemented by Fernando Cacciola and Niels Dekker <p>value_initialized was reimplemented by Fernando Cacciola and Niels Dekker
for Boost release version 1.35 (2008), offering a workaround to various compiler issues. for Boost release version 1.35 (2008), offering a workaround to various compiler issues.
</p> </p>
<p>initialized_value was written by Niels Dekker, and added to Boost release version 1.36 (2008).
</p>
<p>Developed by <a href="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</a>, <p>Developed by <a href="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</a>,
the latest version of this file can be found at <a the latest version of this file can be found at <a
href="http://www.boost.org">www.boost.org</a>. href="http://www.boost.org">www.boost.org</a>.
</p> </p>
<hr> <hr>
<p>Revised 16 January 2008</p> <p>Revised 23 May 2008</p>
<p>&copy; Copyright Fernando Cacciola, 2002, 2008.</p> <p>&copy; Copyright Fernando Cacciola, 2002, 2008.</p>

View File

@@ -7,7 +7,8 @@
// Test program for "boost/utility/value_init.hpp" // Test program for "boost/utility/value_init.hpp"
// //
// 21 Ago 2002 (Created) Fernando Cacciola // 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 <cstring> // For memcmp. #include <cstring> // For memcmp.
#include <iostream> #include <iostream>
@@ -183,7 +184,7 @@ struct CopyFunctionCallTester
template<class T> template<class T>
void check_initialized_value ( T const& y ) void check_initialized_value ( T const& y )
{ {
T initializedValue = boost::initialized_value() ; T initializedValue = boost::initialized_value ;
BOOST_CHECK ( y == initializedValue ) ; BOOST_CHECK ( y == initializedValue ) ;
} }