Compare commits

...

39 Commits

Author SHA1 Message Date
Nicola Musatti
26aee4bb06 bcbboost branch rebased on current release
[SVN r49389]
2008-10-19 14:43:01 +00:00
Nicola Musatti
9168cb9c61 CodeGear patch. Fixes #2341
[SVN r49319]
2008-10-13 19:21:03 +00:00
Daniel James
e1991374ae Merge quickbook workaround and fix some links.
Merged revisions 48987,49230-49231 via svnmerge from 
https://svn.boost.org/svn/boost/trunk

........
  r48987 | danieljames | 2008-09-28 13:21:39 +0100 (Sun, 28 Sep 2008) | 1 line
  
  Clean up some link errors.
........
  r49230 | danieljames | 2008-10-09 23:13:48 +0100 (Thu, 09 Oct 2008) | 1 line
  
  position_iterator is meant to be a forward iterator, so avoid using operator+ with it.
........
  r49231 | danieljames | 2008-10-09 23:14:14 +0100 (Thu, 09 Oct 2008) | 4 lines
  
  Work around the problems with window newlines in position_iterator. (I'm
  about to fix them, but this will get quickbook working immediately).
  
  Fixes #2155
........


[SVN r49242]
2008-10-10 09:29:21 +00:00
Nicola Musatti
b1cbdc7b92 Merge from trunk
[SVN r48991]
2008-09-28 21:23:55 +00:00
Nicola Musatti
7c8c503129 Patches for Codegear C++ Builder 2009
[SVN r48981]
2008-09-27 08:59:20 +00:00
Emil Dotchevski
d0ee9a7c28 Boost Exception major refactoring: works with or without RTTI, vastly improved boost::throw_exception integration.
[SVN r48905]
2008-09-19 20:29:26 +00:00
Matthew Calabrese
10e83b490b Merged BOOST_BINARY utility macro.
[SVN r48879]
2008-09-19 08:19:02 +00:00
Marshall Clow
4b24dba257 Replaced copyright symbols with (c) to match trunk
[SVN r48842]
2008-09-18 02:54:03 +00:00
Daniel James
7a036f6f3a Merge some small fixes from trunk.
Merged revisions 46740,46742,47002,47040 via svnmerge from 
https://svn.boost.org/svn/boost/trunk

........
  r46740 | danieljames | 2008-06-26 20:20:56 +0100 (Thu, 26 Jun 2008) | 1 line
  
  Fix a character encoding error.
........
  r46742 | danieljames | 2008-06-26 20:25:38 +0100 (Thu, 26 Jun 2008) | 6 lines
  
  Give the asio documentation its own target.
  
  The asio documentation is built with the rest of the combined documentation but
  is really separate. So give it its own target so that separate parts can be
  built separately.
........
  r47040 | danieljames | 2008-07-03 15:34:56 +0100 (Thu, 03 Jul 2008) | 1 line
  
  Workaround for some template syntax not supported in old versions of Visual C++ 6.5
........


[SVN r47078]
2008-07-04 17:04:47 +00:00
Emil Dotchevski
e632b0fb1f Boost Exception
In other libraries, watch for compile error referring to throw_exception_assert_compatibility in boost::throw_exception. Resolve by throwing an exception that derives from std::exception. This is not a new requirement but it is being enforced now.

[SVN r46818]
2008-06-28 18:29:40 +00:00
Beman Dawes
17bee9d43f With his kind permission, change Jaakko "Järvi" to "Jarvi"
[SVN r46809]
2008-06-28 13:57:20 +00:00
Anthony Williams
492a8ad213 Merge of new boost.thread code along with required changes from boost.bind
[SVN r46474]
2008-06-18 13:01:08 +00:00
Niels Dekker
8827b8ed8b Merged value_init doc + test from trunk, including doc and test for boost::initialized_value, that was added with changeset [46464]
[SVN r46465]
2008-06-17 22:17:14 +00:00
Niels Dekker
8849fbc52d Merged value_init.hpp from trunk, including new boost::initialized_value object. (Was discussed beforehand with Fernando Cacciola.)
[SVN r46464]
2008-06-17 22:14:09 +00:00
Daniel James
50bc75a802 Add minor documentation fixes to the release branch.
(I left out the changes to the hash library).

Merged via svnmerge from 
https://svn.boost.org/svn/boost/trunk

................
  r44807 | danieljames | 2008-04-27 08:39:49 +0100 (Sun, 27 Apr 2008) | 78 lines
  
  Merge in documentation fixes.  Apart from the change to optional's documenation
  Jamfile, which I included by mistake.
  
  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.
  ........
    r44586 | danieljames | 2008-04-19 16:27:36 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix broken link to bcpp in bjam docs.
  ........
    r44587 | danieljames | 2008-04-19 16:33:58 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    DateTime documentation - Fix a link to the serialization library.
  ........
    r44588 | danieljames | 2008-04-19 16:35:36 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix some links in interprocess & intrusive.
  ........
    r44589 | danieljames | 2008-04-19 16:37:39 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix some links in the python docs.
  ........
    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.
  ........
    r44591 | danieljames | 2008-04-19 16:39:34 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix a broken link in the numeric conversion docs.
  ........
    r44592 | danieljames | 2008-04-19 16:40:45 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix some links in the optional docs.
  ........
    r44593 | danieljames | 2008-04-19 16:42:09 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix link to the hash documentation from bimap.
  ........
    r44599 | danieljames | 2008-04-19 18:07:33 +0100 (Sat, 19 Apr 2008) | 2 lines
    
    Fix a typo in the format library.
  ........
    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.
  ........
................
  r45232 | danieljames | 2008-05-08 22:50:19 +0100 (Thu, 08 May 2008) | 1 line
  
  Fix some invalid xml by replacing ampersands with character entities.
................
  r45576 | danieljames | 2008-05-20 16:39:25 +0100 (Tue, 20 May 2008) | 20 lines
  
  Merge some small documentation fixes from the doc branch, and mark some
  previously merged changes as merged.
  
  Merged revisions 44811,45129,45142,45154,45281-45282,45365 via svnmerge from 
  https://svn.boost.org/svn/boost/branches/doc
  
  ........
    r45129 | danieljames | 2008-05-05 12:36:50 +0100 (Mon, 05 May 2008) | 2 lines
    
    Update navbar links in boostbook.
  ........
    r45282 | danieljames | 2008-05-11 14:15:31 +0100 (Sun, 11 May 2008) | 2 lines
    
    Group functions in the hash header - requires Frank's free-function-group fix.
    (not included in release branch).
  ........
    r45365 | danieljames | 2008-05-14 21:39:00 +0100 (Wed, 14 May 2008) | 2 lines
    
    Add boost.root to standalone hash documentation.
    (not included in release branch).
  ........
................


[SVN r45622]
2008-05-21 20:57:05 +00:00
John Maddock
9b52e49fda Merge inspection failure fixes from Trunk.
[SVN r43634]
2008-03-15 18:45:28 +00:00
Daniel James
ab479794f3 Merged revisions 43206,43208-43213 via svnmerge from
https://svn.boost.org/svn/boost/trunk

........
  r43206 | danieljames | 2008-02-10 09:55:03 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Fix some broken links.
........
  r43209 | danieljames | 2008-02-10 14:56:22 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Link to people pages on the website, as they've been removed from the download.
........
  r43210 | danieljames | 2008-02-10 15:02:17 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Point links to the pages that used to be in 'more' to the site.
........
  r43212 | danieljames | 2008-02-10 16:10:16 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Fix links on the home page as well.
........
  r43213 | danieljames | 2008-02-10 16:21:22 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Generated documentation which is no longer generated.
........


[SVN r43214]
2008-02-10 16:39:38 +00:00
Niels Dekker
97b8966337 value_init doc + test: Merged from trunk changeset [42798] to release.
[SVN r42799]
2008-01-15 19:55:28 +00:00
Niels Dekker
88099a882f Merged value_init.hpp from trunk [42277] to release branch, thereby resolving ticket #1459 and #1491. Fernando Cacciola (owner of value_init) encouraged me to do the commit.
[SVN r42501]
2008-01-05 22:38:50 +00:00
Beman Dawes
d5554eb6d7 Pick up missing smart_ptr, utility, and type_traits files from full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41386]
2007-11-25 22:34:55 +00:00
Beman Dawes
13bdfb8bbd Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41370]
2007-11-25 18:38:02 +00:00
Beman Dawes
74462349c2 Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41369]
2007-11-25 18:07:19 +00:00
Nicola Musatti
8f4db5aa5b Merge from trunk
[SVN r39987]
2007-10-13 21:25:29 +00:00
Beman Dawes
6aa648d315 Starting point for releases
[SVN r39706]
2007-10-05 14:25:06 +00:00
Nicola Musatti
de42786286 Branch for CodeGear (Borland) specific fixes
[SVN r39356]
2007-09-17 20:28:43 +00:00
nobody
9ff18c2c96 This commit was manufactured by cvs2svn to create tag
'Version_1_34_1'.

[SVN r38286]
2007-07-24 19:28:14 +00:00
Daniel Frey
d5ea07c737 Merged changes for ticket #979 from HEAD
[SVN r37920]
2007-06-06 20:57:40 +00:00
Fernando Cacciola
aa0096bf42 Testsuite for none_t added.
[SVN r37421]
2007-04-12 14:32:38 +00:00
Daniel James
005c2f3cc8 Fix a couple of links.
[SVN r36656]
2007-01-07 22:58:41 +00:00
Andreas Huber
09f7aab52d Merged L & C issue fixes & HTML conversions from trunk to branch.
[SVN r36281]
2006-12-05 22:33:21 +00:00
Peter Dimov
30a40f9f76 Linked to current_function.html
[SVN r36268]
2006-12-04 20:31:38 +00:00
Vladimir Prus
d9f8bae673 Merge from HEAD.
Allow building of shared versions of some Boost.Test libraries.
Adjust tests to use always use static linking to Boost.Test, since
linking to the shared version requires test changes.

Patch from Juergen Hunold.


[SVN r35990]
2006-11-10 19:59:52 +00:00
Peter Dimov
3c7b409460 License/copyright edits
[SVN r35958]
2006-11-09 20:34:33 +00:00
Beman Dawes
ee3551e8dc Merged copyright and license addition
[SVN r35907]
2006-11-07 19:27:00 +00:00
Rene Rivera
95da2e90de Remove obsolete Boost.Build v1 files.
[SVN r35880]
2006-11-06 17:10:46 +00:00
John Maddock
6dd93ab916 Removed unneeded semicolon.
[SVN r35636]
2006-10-16 18:01:40 +00:00
Hartmut Kaiser
505d419a1b Resolved an ambiguity.
[SVN r35039]
2006-09-08 00:16:31 +00:00
Gennaro Prota
d968b5f5b9 boost guidelines (mainly from inspect tool: tabs, license reference text, etc.); more to do...
[SVN r34753]
2006-07-27 11:48:49 +00:00
nobody
d809d4e832 This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'.
[SVN r33417]
2006-03-21 02:26:31 +00:00
14 changed files with 237 additions and 608 deletions

View File

@@ -8,9 +8,6 @@
// 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
// 07 Aug 08 Added "euclidean" spelling. (Daniel Frey)
// 03 Apr 08 Make sure "convertible to bool" is sufficient
// for T::operator<, etc. (Daniel Frey)
// 24 May 07 Changed empty_base to depend on T, see // 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
@@ -127,34 +124,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 !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 T& x, const U& y) { return !(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<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); } friend bool operator>=(const U& x, const T& y) { return !(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 !static_cast<bool>(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>(x < y); } friend bool operator>=(const T& x, const T& y) { return !(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 !static_cast<bool>(x == y); } friend bool operator!=(const U& y, const T& x) { return !(x == y); }
friend bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); } friend bool operator!=(const T& y, const U& x) { return !(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 !static_cast<bool>(x == y); } friend bool operator!=(const T& x, const T& y) { return !(x == y); }
}; };
// A macro which produces "name_2left" from "name". // A macro which produces "name_2left" from "name".
@@ -359,7 +356,7 @@ struct equivalent2 : B
{ {
friend bool operator==(const T& x, const U& y) friend bool operator==(const T& x, const U& y)
{ {
return !static_cast<bool>(x < y) && !static_cast<bool>(x > y); return !(x < y) && !(x > y);
} }
}; };
@@ -368,7 +365,7 @@ struct equivalent1 : B
{ {
friend bool operator==(const T&x, const T&y) friend bool operator==(const T&x, const T&y)
{ {
return !static_cast<bool>(x < y) && !static_cast<bool>(y < x); return !(x < y) && !(y < x);
} }
}; };
@@ -376,17 +373,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 static_cast<bool>(x < y) || static_cast<bool>(x == y); } { return (x < y) || (x == y); }
friend bool operator>=(const T& x, const U& y) friend bool operator>=(const T& x, const U& y)
{ return static_cast<bool>(x > y) || static_cast<bool>(x == y); } { return (x > y) || (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 static_cast<bool>(y > x) || static_cast<bool>(y == x); } { return (y > x) || (y == x); }
friend bool operator>=(const U& x, const T& y) friend bool operator>=(const U& x, const T& y)
{ return static_cast<bool>(y < x) || static_cast<bool>(y == x); } { return (y < x) || (y == x); }
}; };
template <class T, class B = ::boost::detail::empty_base<T> > template <class T, class B = ::boost::detail::empty_base<T> >
@@ -395,9 +392,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 static_cast<bool>(x < y) || static_cast<bool>(x == y); } { return (x < y) || (x == y); }
friend bool operator>=(const T& x, const T& y) friend bool operator>=(const T& x, const T& y)
{ return static_cast<bool>(y < x) || static_cast<bool>(x == y); } { return (y < x) || (x == y); }
}; };
// Combined operator classes (contributed by Daryle Walker) ----------------// // Combined operator classes (contributed by Daryle Walker) ----------------//
@@ -584,34 +581,6 @@ struct ordered_euclidian_ring_operators1
, euclidian_ring_operators1<T, B , euclidian_ring_operators1<T, B
> > {}; > > {};
template <class T, class U, class B = ::boost::detail::empty_base<T> >
struct euclidean_ring_operators2
: ring_operators2<T, U
, dividable2<T, U
, dividable2_left<T, U
, modable2<T, U
, modable2_left<T, U, B
> > > > > {};
template <class T, class B = ::boost::detail::empty_base<T> >
struct euclidean_ring_operators1
: ring_operators1<T
, dividable1<T
, modable1<T, B
> > > {};
template <class T, class U, class B = ::boost::detail::empty_base<T> >
struct ordered_euclidean_ring_operators2
: totally_ordered2<T, U
, euclidean_ring_operators2<T, U, B
> > {};
template <class T, class B = ::boost::detail::empty_base<T> >
struct ordered_euclidean_ring_operators1
: totally_ordered1<T
, euclidean_ring_operators1<T, B
> > {};
template <class T, class P, class B = ::boost::detail::empty_base<T> > template <class T, class P, class B = ::boost::detail::empty_base<T> >
struct input_iteratable struct input_iteratable
: equality_comparable1<T : equality_comparable1<T
@@ -868,8 +837,6 @@ BOOST_OPERATOR_TEMPLATE(field_operators)
BOOST_OPERATOR_TEMPLATE(ordered_field_operators) BOOST_OPERATOR_TEMPLATE(ordered_field_operators)
BOOST_OPERATOR_TEMPLATE(euclidian_ring_operators) BOOST_OPERATOR_TEMPLATE(euclidian_ring_operators)
BOOST_OPERATOR_TEMPLATE(ordered_euclidian_ring_operators) BOOST_OPERATOR_TEMPLATE(ordered_euclidian_ring_operators)
BOOST_OPERATOR_TEMPLATE(euclidean_ring_operators)
BOOST_OPERATOR_TEMPLATE(ordered_euclidean_ring_operators)
BOOST_OPERATOR_TEMPLATE2(input_iteratable) BOOST_OPERATOR_TEMPLATE2(input_iteratable)
BOOST_OPERATOR_TEMPLATE1(output_iteratable) BOOST_OPERATOR_TEMPLATE1(output_iteratable)
BOOST_OPERATOR_TEMPLATE2(forward_iteratable) BOOST_OPERATOR_TEMPLATE2(forward_iteratable)

View File

@@ -173,12 +173,6 @@ class unwrap_reference
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class T> inline typename unwrap_reference<T>::type&
unwrap_ref(T& t)
{
return t;
}
} // namespace boost } // namespace boost
#endif // #ifndef BOOST_REF_HPP_INCLUDED #endif // #ifndef BOOST_REF_HPP_INCLUDED

View File

@@ -10,47 +10,6 @@
# 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<
typename remove_cv<F>::type,
typename remove_cv<F>::type(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
@@ -62,22 +21,11 @@ public:
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of<F(BOOST_RESULT_OF_ARGS)> struct result_of<F(BOOST_RESULT_OF_ARGS)>
: mpl::if_< : boost::detail::result_of_impl<F, F(BOOST_RESULT_OF_ARGS), (boost::detail::has_result_type<F>::value)> {};
mpl::or_< is_pointer<F>, is_member_function_pointer<F> >
, boost::detail::result_of_impl<
typename remove_cv<F>::type,
typename remove_cv<F>::type(BOOST_RESULT_OF_ARGS),
(boost::detail::has_result_type<F>::value)>
, boost::detail::result_of_impl<
F,
F(BOOST_RESULT_OF_ARGS),
(boost::detail::has_result_type<F>::value)> >::type { };
#endif #endif
#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

@@ -10,18 +10,13 @@
#define BOOST_RESULT_OF_HPP #define BOOST_RESULT_OF_HPP
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/preprocessor/iteration/iterate.hpp> #include <boost/type_traits/ice.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp> #include <boost/type.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp> #include <boost/preprocessor.hpp>
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
#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>
#include <boost/type_traits/remove_cv.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
@@ -37,7 +32,6 @@ 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
@@ -57,11 +51,6 @@ struct result_of_void_impl<R (&)(void)>
typedef R type; typedef R type;
}; };
// Determine the return type of a function pointer or pointer to member.
template<typename F, typename FArgs>
struct result_of_pointer
: result_of_impl<typename remove_cv<F>::type, FArgs, false> { };
template<typename F, typename FArgs> template<typename F, typename FArgs>
struct result_of_impl<F, FArgs, true> struct result_of_impl<F, FArgs, true>
{ {

View File

@@ -7,7 +7,6 @@
// 21 Ago 2002 (Created) Fernando Cacciola // 21 Ago 2002 (Created) Fernando Cacciola
// 24 Dec 2007 (Refactored and worked around various compiler bugs) 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 // 23 May 2008 (Fixed operator= const issue, added initialized_value) Niels Dekker, Fernando Cacciola
// 21 Ago 2008 (Added swap) 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
@@ -23,7 +22,6 @@
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include <boost/type_traits/cv_traits.hpp> #include <boost/type_traits/cv_traits.hpp>
#include <boost/type_traits/alignment_of.hpp> #include <boost/type_traits/alignment_of.hpp>
#include <boost/swap.hpp>
#include <cstring> #include <cstring>
#include <new> #include <new>
@@ -95,11 +93,6 @@ class value_initialized
return wrapper_address()->data; return wrapper_address()->data;
} }
void swap(value_initialized & arg)
{
::boost::swap( this->data(), arg.data() );
}
operator T&() const { return this->data(); } operator T&() const { return this->data(); }
} ; } ;
@@ -117,12 +110,6 @@ T& get ( value_initialized<T>& x )
return x.data() ; return x.data() ;
} }
template<class T>
void swap ( value_initialized<T> & lhs, value_initialized<T> & rhs )
{
lhs.swap(rhs) ;
}
class initialized_value_t class initialized_value_t
{ {

View File

@@ -24,7 +24,6 @@
<a href="iterator_adaptors.htm">iterator_adaptors</a><br> <a href="iterator_adaptors.htm">iterator_adaptors</a><br>
<a href="generator_iterator.htm">generator iterator adaptors</a><br> <a href="generator_iterator.htm">generator iterator adaptors</a><br>
<a href="operators.htm">operators</a><br> <a href="operators.htm">operators</a><br>
<a href="swap.html">swap</a><br>
<a href="throw_exception.html">throw_exception</a><br> <a href="throw_exception.html">throw_exception</a><br>
<a href="utility.htm">utility</a><br> <a href="utility.htm">utility</a><br>
<a href="value_init.htm">value_init</a></p> <a href="value_init.htm">value_init</a></p>

View File

@@ -1420,9 +1420,9 @@ T operator+( T lhs, const T&amp; rhs )
<tr> <tr>
<td><code><a name= <td><code><a name=
"euclidean_ring_operators1">euclidean_ring_operators&lt;T&gt;</a></code><br> "euclidian_ring_operators1">euclidian_ring_operators&lt;T&gt;</a></code><br>
<code>euclidean_ring_operators1&lt;T&gt;</code></td> <code>euclidian_ring_operators1&lt;T&gt;</code></td>
<td> <td>
<ul> <ul>
@@ -1439,9 +1439,9 @@ T operator+( T lhs, const T&amp; rhs )
<tr> <tr>
<td><code><a name= <td><code><a name=
"euclidean_ring_operators2">euclidean_ring_operators&lt;T, "euclidian_ring_operators2">euclidian_ring_operators&lt;T,
U&gt;</a></code><br> U&gt;</a></code><br>
<code>euclidean_ring_operators2&lt;T, U&gt;</code></td> <code>euclidian_ring_operators2&lt;T, U&gt;</code></td>
<td> <td>
<ul> <ul>
@@ -1464,14 +1464,14 @@ T operator+( T lhs, const T&amp; rhs )
<tr> <tr>
<td><code><a name= <td><code><a name=
"ordered_euclidean_ring_operators1">ordered_euclidean_ring_operators&lt;T&gt;</a></code><br> "ordered_euclidian_ring_operators1">ordered_euclidian_ring_operators&lt;T&gt;</a></code><br>
<code>ordered_euclidean_ring_operators1&lt;T&gt;</code></td> <code>ordered_euclidian_ring_operators1&lt;T&gt;</code></td>
<td> <td>
<ul> <ul>
<li><code><a href= <li><code><a href=
"#euclidean_ring_operators1">euclidean_ring_operators&lt;T&gt;</a></code></li> "#euclidian_ring_operators1">euclidian_ring_operators&lt;T&gt;</a></code></li>
<li><code><a href= <li><code><a href=
"#totally_ordered1">totally_ordered&lt;T&gt;</a></code></li> "#totally_ordered1">totally_ordered&lt;T&gt;</a></code></li>
@@ -1481,14 +1481,14 @@ T operator+( T lhs, const T&amp; rhs )
<tr> <tr>
<td><code><a name= <td><code><a name=
"ordered_euclidean_ring_operators2">ordered_euclidean_ring_operators&lt;T, "ordered_euclidian_ring_operators2">ordered_euclidian_ring_operators&lt;T,
U&gt;</a></code><br> U&gt;</a></code><br>
<code>ordered_euclidean_ring_operators2&lt;T, U&gt;</code></td> <code>ordered_euclidian_ring_operators2&lt;T, U&gt;</code></td>
<td> <td>
<ul> <ul>
<li><code><a href= <li><code><a href=
"#euclidean_ring_operators2">euclidean_ring_operators&lt;T, "#euclidian_ring_operators2">euclidian_ring_operators&lt;T,
U&gt;</a></code></li> U&gt;</a></code></li>
<li><code><a href="#totally_ordered2">totally_ordered&lt;T, <li><code><a href="#totally_ordered2">totally_ordered&lt;T,
@@ -1498,15 +1498,6 @@ T operator+( T lhs, const T&amp; rhs )
</tr> </tr>
</table> </table>
<h4>Spelling: euclidean vs. euclidian</h4>
<p>Older versions of the Boost.Operators library used
&quot;<code>euclidian</code>&quot;, but it was pointed out that
&quot;<code>euclidean</code>&quot; is the more common spelling.
To be compatible with older version, the library now supports
both spellings.
</p>
<h3><a name="ex_oprs">Example</a> Templates</h3> <h3><a name="ex_oprs">Example</a> Templates</h3>
<p>The arithmetic operator class templates <code><a href= <p>The arithmetic operator class templates <code><a href=
@@ -1585,8 +1576,9 @@ T operator+( T lhs, const T&amp; rhs )
<p>The <cite><a href="operators_test.cpp">operators_test.cpp</a></cite> <p>The <cite><a href="operators_test.cpp">operators_test.cpp</a></cite>
program demonstrates the use of the arithmetic operator templates, and program demonstrates the use of the arithmetic operator templates, and
can also be used to verify correct operation. Check the compiler status can also be used to verify correct operation. Check the <a href=
report for the test results with selected platforms.</p> "../../status/compiler_status.html">compiler status report</a> for the
test results with selected platforms.</p>
<h2><a name="deref">Dereference</a> Operators and Iterator Helpers</h2> <h2><a name="deref">Dereference</a> Operators and Iterator Helpers</h2>
@@ -2030,7 +2022,7 @@ public:
</pre> </pre>
</blockquote> </blockquote>
<p>Check the <a href="../../status/compiler_status.html">compiler status <p>Check the <a href="http://www.boost.org/development/testing.html">compiler status
report</a> for the test results with selected platforms.</p> report</a> for the test results with selected platforms.</p>
<hr> <hr>
@@ -2127,10 +2119,10 @@ public:
backward-compatible.</p> backward-compatible.</p>
<hr> <hr>
<p>Revised: 7 Aug 2008</p> <p>Revised: 29 Oct 2004</p>
<p>Copyright &copy; Beman Dawes, David Abrahams, 1999-2001.</p> <p>Copyright &copy; Beman Dawes, David Abrahams, 1999-2001.</p>
<p>Copyright &copy; Daniel Frey, 2002-2008.</p> <p>Copyright &copy; Daniel Frey, 2002-2004.</p>
<p>Use, modification, and distribution is subject to the Boost Software <p>Use, modification, and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file License, Version 1.0. (See accompanying file
<a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at

View File

@@ -7,7 +7,6 @@
// 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
@@ -44,23 +43,6 @@ 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>
@@ -72,10 +54,8 @@ 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; }
convertible_to_bool operator<(const Wrapped1& x) const bool operator<(const Wrapped1& x) const { return _value < x._value; }
{ 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; }
Wrapped1& operator+=(const Wrapped1& x) Wrapped1& operator+=(const Wrapped1& x)
{ _value += x._value; return *this; } { _value += x._value; return *this; }
@@ -117,10 +97,8 @@ 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; }
convertible_to_bool operator<(const Wrapped2& x) const bool operator<(const Wrapped2& x) const { return _value < x._value; }
{ 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; }
Wrapped2& operator+=(const Wrapped2& x) Wrapped2& operator+=(const Wrapped2& x)
{ _value += x._value; return *this; } { _value += x._value; return *this; }
@@ -145,13 +123,9 @@ namespace
Wrapped2& operator++() { ++_value; return *this; } Wrapped2& operator++() { ++_value; return *this; }
Wrapped2& operator--() { --_value; return *this; } Wrapped2& operator--() { --_value; return *this; }
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 bool operator==(U u) const { return _value == u; }
{ 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; }
@@ -179,8 +153,7 @@ 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; }
convertible_to_bool operator<(const Wrapped3& x) const bool operator<(const Wrapped3& x) const { return _value < x._value; }
{ return _value < x._value; }
private: private:
T _value; T _value;
@@ -201,13 +174,10 @@ 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; }
convertible_to_bool operator<(const Wrapped4& x) const bool operator<(const Wrapped4& x) const { return _value < x._value; }
{ return _value < x._value; }
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; }
private: private:
T _value; T _value;
@@ -228,18 +198,11 @@ 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; }
convertible_to_bool operator<(const Wrapped5& x) const bool operator<(U u) const { return _value < u; }
{ return _value < x._value; } bool operator>(U u) const { return _value > u; }
convertible_to_bool operator<(U u) const bool operator==(const Wrapped5& u) const { return _value == u._value; }
{ 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==(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;}
@@ -258,8 +221,8 @@ namespace
// U must be convertible to T // U must be convertible to T
template <class T, class U> template <class T, class U>
class Wrapped6 class Wrapped6
: boost::ordered_euclidean_ring_operators2<Wrapped6<T, U>, U> : boost::ordered_euclidian_ring_operators2<Wrapped6<T, U>, U>
, boost::ordered_euclidean_ring_operators1<Wrapped6<T, U> > , boost::ordered_euclidian_ring_operators1<Wrapped6<T, U> >
{ {
public: public:
explicit Wrapped6( T v = T() ) : _value(v) {} explicit Wrapped6( T v = T() ) : _value(v) {}
@@ -268,18 +231,11 @@ 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; }
convertible_to_bool operator<(const Wrapped6& x) const bool operator<(U u) const { return _value < u; }
{ return _value < x._value; } bool operator>(U u) const { return _value > u; }
convertible_to_bool operator<(U u) const bool operator==(const Wrapped6& u) const { return _value == u._value; }
{ 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==(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;}
@@ -320,10 +276,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( 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) ); BOOST_CHECK( (x1 > y1) == (x2 > y2) );
} }
template <class X1, class Y1, class X2, class Y2> template <class X1, class Y1, class X2, class Y2>
@@ -337,8 +293,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( 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) );
} }
template <class X1, class Y1, class X2, class Y2> template <class X1, class Y1, class X2, class Y2>
@@ -658,14 +614,14 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (i = i2), (i.value() == 2) ); PRIVATE_EXPR_TEST( (i = i2), (i.value() == 2) );
BOOST_CHECK( static_cast<bool>(i2 == i) ); BOOST_CHECK( i2 == i );
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( i1 <= i2 );
BOOST_CHECK( static_cast<bool>(i <= i2) ); BOOST_CHECK( i <= i2 );
BOOST_CHECK( static_cast<bool>(i2 > i1) ); BOOST_CHECK( i2 > i1 );
BOOST_CHECK( static_cast<bool>(i2 >= i1) ); BOOST_CHECK( i2 >= i1 );
BOOST_CHECK( static_cast<bool>(i2 >= i) ); BOOST_CHECK( 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) );
@@ -697,78 +653,78 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (j = j2), (j.value() == 2) ); PRIVATE_EXPR_TEST( (j = j2), (j.value() == 2) );
BOOST_CHECK( static_cast<bool>(j2 == j) ); BOOST_CHECK( j2 == j );
BOOST_CHECK( static_cast<bool>(2 == j) ); BOOST_CHECK( 2 == j );
BOOST_CHECK( static_cast<bool>(j2 == 2) ); BOOST_CHECK( j2 == 2 );
BOOST_CHECK( static_cast<bool>(j == j2) ); BOOST_CHECK( j == j2 );
BOOST_CHECK( static_cast<bool>(j1 != j2) ); BOOST_CHECK( j1 != j2 );
BOOST_CHECK( static_cast<bool>(j1 != 2) ); BOOST_CHECK( j1 != 2 );
BOOST_CHECK( static_cast<bool>(1 != j2) ); BOOST_CHECK( 1 != j2 );
BOOST_CHECK( static_cast<bool>(j1 < j2) ); BOOST_CHECK( j1 < j2 );
BOOST_CHECK( static_cast<bool>(1 < j2) ); BOOST_CHECK( 1 < j2 );
BOOST_CHECK( static_cast<bool>(j1 < 2) ); BOOST_CHECK( j1 < 2 );
BOOST_CHECK( static_cast<bool>(j1 <= j2) ); BOOST_CHECK( j1 <= j2 );
BOOST_CHECK( static_cast<bool>(1 <= j2) ); BOOST_CHECK( 1 <= j2 );
BOOST_CHECK( static_cast<bool>(j1 <= j) ); BOOST_CHECK( j1 <= j );
BOOST_CHECK( static_cast<bool>(j <= j2) ); BOOST_CHECK( j <= j2 );
BOOST_CHECK( static_cast<bool>(2 <= j2) ); BOOST_CHECK( 2 <= j2 );
BOOST_CHECK( static_cast<bool>(j <= 2) ); BOOST_CHECK( j <= 2 );
BOOST_CHECK( static_cast<bool>(j2 > j1) ); BOOST_CHECK( j2 > j1 );
BOOST_CHECK( static_cast<bool>(2 > j1) ); BOOST_CHECK( 2 > j1 );
BOOST_CHECK( static_cast<bool>(j2 > 1) ); BOOST_CHECK( j2 > 1 );
BOOST_CHECK( static_cast<bool>(j2 >= j1) ); BOOST_CHECK( j2 >= j1 );
BOOST_CHECK( static_cast<bool>(2 >= j1) ); BOOST_CHECK( 2 >= j1 );
BOOST_CHECK( static_cast<bool>(j2 >= 1) ); BOOST_CHECK( j2 >= 1 );
BOOST_CHECK( static_cast<bool>(j2 >= j) ); BOOST_CHECK( j2 >= j );
BOOST_CHECK( static_cast<bool>(2 >= j) ); BOOST_CHECK( 2 >= j );
BOOST_CHECK( static_cast<bool>(j2 >= 2) ); BOOST_CHECK( j2 >= 2 );
BOOST_CHECK( static_cast<bool>((j1 + 2) == 3) ); BOOST_CHECK( (j1 + 2) == 3 );
BOOST_CHECK( static_cast<bool>((1 + j2) == 3) ); BOOST_CHECK( (1 + j2) == 3 );
PRIVATE_EXPR_TEST( (j = j1 + j2), (j.value() == 3) ); PRIVATE_EXPR_TEST( (j = j1 + j2), (j.value() == 3) );
BOOST_CHECK( static_cast<bool>((j + 2) == 5) ); BOOST_CHECK( (j + 2) == 5 );
BOOST_CHECK( static_cast<bool>((3 + j2) == 5) ); BOOST_CHECK( (3 + j2) == 5 );
PRIVATE_EXPR_TEST( (j = j + j2), (j.value() == 5) ); PRIVATE_EXPR_TEST( (j = j + j2), (j.value() == 5) );
BOOST_CHECK( static_cast<bool>((j - 1) == 4) ); BOOST_CHECK( (j - 1) == 4 );
PRIVATE_EXPR_TEST( (j = j - j1), (j.value() == 4) ); PRIVATE_EXPR_TEST( (j = j - j1), (j.value() == 4) );
BOOST_CHECK( static_cast<bool>((j * 2) == 8) ); BOOST_CHECK( (j * 2) == 8 );
BOOST_CHECK( static_cast<bool>((4 * j2) == 8) ); BOOST_CHECK( (4 * j2) == 8 );
PRIVATE_EXPR_TEST( (j = j * j2), (j.value() == 8) ); PRIVATE_EXPR_TEST( (j = j * j2), (j.value() == 8) );
BOOST_CHECK( static_cast<bool>((j / 2) == 4) ); BOOST_CHECK( (j / 2) == 4 );
PRIVATE_EXPR_TEST( (j = j / j2), (j.value() == 4) ); PRIVATE_EXPR_TEST( (j = j / j2), (j.value() == 4) );
BOOST_CHECK( static_cast<bool>((j % 3) == 1) ); BOOST_CHECK( (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( static_cast<bool>((1 | j2 | j) == 7) ); BOOST_CHECK( (1 | j2 | j) == 7 );
BOOST_CHECK( static_cast<bool>((j1 | 2 | j) == 7) ); BOOST_CHECK( (j1 | 2 | j) == 7 );
BOOST_CHECK( static_cast<bool>((j1 | j2 | 4) == 7) ); BOOST_CHECK( (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( static_cast<bool>((7 & j2) == 2) ); BOOST_CHECK( (7 & j2) == 2 );
BOOST_CHECK( static_cast<bool>((j & 2) == 2) ); BOOST_CHECK( (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( static_cast<bool>((3 ^ j1) == 2) ); BOOST_CHECK( (3 ^ j1) == 2 );
BOOST_CHECK( static_cast<bool>((j ^ 1) == 2) ); BOOST_CHECK( (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( static_cast<bool>((j1 << 2) == 4) ); BOOST_CHECK( (j1 << 2) == 4 );
BOOST_CHECK( static_cast<bool>((j2 << 1) == 4) ); BOOST_CHECK( (j2 << 1) == 4 );
PRIVATE_EXPR_TEST( (j = j1 << j2), (j.value() == 4) ); PRIVATE_EXPR_TEST( (j = j1 << j2), (j.value() == 4) );
BOOST_CHECK( static_cast<bool>((j >> 2) == 1) ); BOOST_CHECK( (j >> 2) == 1 );
BOOST_CHECK( static_cast<bool>((j2 >> 1) == 1) ); BOOST_CHECK( (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";
@@ -785,14 +741,14 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (k = k2), (k.value() == 2) ); PRIVATE_EXPR_TEST( (k = k2), (k.value() == 2) );
BOOST_CHECK( static_cast<bool>(k2 == k) ); BOOST_CHECK( k2 == k );
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( k1 <= k2 );
BOOST_CHECK( static_cast<bool>(k <= k2) ); BOOST_CHECK( k <= k2 );
BOOST_CHECK( static_cast<bool>(k2 > k1) ); BOOST_CHECK( k2 > k1 );
BOOST_CHECK( static_cast<bool>(k2 >= k1) ); BOOST_CHECK( k2 >= k1 );
BOOST_CHECK( static_cast<bool>(k2 >= k) ); BOOST_CHECK( k2 >= k );
cout << "Performed tests on MyChar objects.\n"; cout << "Performed tests on MyChar objects.\n";
@@ -808,31 +764,31 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (l = l2), (l.value() == 2) ); PRIVATE_EXPR_TEST( (l = l2), (l.value() == 2) );
BOOST_CHECK( static_cast<bool>(l2 == l) ); BOOST_CHECK( l2 == l );
BOOST_CHECK( static_cast<bool>(2 == l) ); BOOST_CHECK( 2 == l );
BOOST_CHECK( static_cast<bool>(l2 == 2) ); BOOST_CHECK( l2 == 2 );
BOOST_CHECK( static_cast<bool>(l == l2) ); BOOST_CHECK( l == l2 );
BOOST_CHECK( static_cast<bool>(l1 != l2) ); BOOST_CHECK( l1 != l2 );
BOOST_CHECK( static_cast<bool>(l1 != 2) ); BOOST_CHECK( l1 != 2 );
BOOST_CHECK( static_cast<bool>(1 != l2) ); BOOST_CHECK( 1 != l2 );
BOOST_CHECK( static_cast<bool>(l1 < l2) ); BOOST_CHECK( l1 < l2 );
BOOST_CHECK( static_cast<bool>(1 < l2) ); BOOST_CHECK( 1 < l2 );
BOOST_CHECK( static_cast<bool>(l1 < 2) ); BOOST_CHECK( l1 < 2 );
BOOST_CHECK( static_cast<bool>(l1 <= l2) ); BOOST_CHECK( l1 <= l2 );
BOOST_CHECK( static_cast<bool>(1 <= l2) ); BOOST_CHECK( 1 <= l2 );
BOOST_CHECK( static_cast<bool>(l1 <= l) ); BOOST_CHECK( l1 <= l );
BOOST_CHECK( static_cast<bool>(l <= l2) ); BOOST_CHECK( l <= l2 );
BOOST_CHECK( static_cast<bool>(2 <= l2) ); BOOST_CHECK( 2 <= l2 );
BOOST_CHECK( static_cast<bool>(l <= 2) ); BOOST_CHECK( l <= 2 );
BOOST_CHECK( static_cast<bool>(l2 > l1) ); BOOST_CHECK( l2 > l1 );
BOOST_CHECK( static_cast<bool>(2 > l1) ); BOOST_CHECK( 2 > l1 );
BOOST_CHECK( static_cast<bool>(l2 > 1) ); BOOST_CHECK( l2 > 1 );
BOOST_CHECK( static_cast<bool>(l2 >= l1) ); BOOST_CHECK( l2 >= l1 );
BOOST_CHECK( static_cast<bool>(2 >= l1) ); BOOST_CHECK( 2 >= l1 );
BOOST_CHECK( static_cast<bool>(l2 >= 1) ); BOOST_CHECK( l2 >= 1 );
BOOST_CHECK( static_cast<bool>(l2 >= l) ); BOOST_CHECK( l2 >= l );
BOOST_CHECK( static_cast<bool>(2 >= l) ); BOOST_CHECK( 2 >= l );
BOOST_CHECK( static_cast<bool>(l2 >= 2) ); BOOST_CHECK( l2 >= 2 );
cout << "Performed tests on MyShort objects.\n"; cout << "Performed tests on MyShort objects.\n";
@@ -851,37 +807,37 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (di = di2), (di.value() == 2) ); PRIVATE_EXPR_TEST( (di = di2), (di.value() == 2) );
BOOST_CHECK( static_cast<bool>(di2 == di) ); BOOST_CHECK( di2 == di );
BOOST_CHECK( static_cast<bool>(2 == di) ); BOOST_CHECK( 2 == di );
BOOST_CHECK( static_cast<bool>(di == 2) ); BOOST_CHECK( di == 2 );
BOOST_CHECK( static_cast<bool>(di1 < di2) ); BOOST_CHECK( di1 < di2 );
BOOST_CHECK( static_cast<bool>(1 < di2) ); BOOST_CHECK( 1 < di2 );
BOOST_CHECK( static_cast<bool>(di1 <= di2) ); BOOST_CHECK( di1 <= di2 );
BOOST_CHECK( static_cast<bool>(1 <= di2) ); BOOST_CHECK( 1 <= di2 );
BOOST_CHECK( static_cast<bool>(di2 > di1) ); BOOST_CHECK( di2 > di1 );
BOOST_CHECK( static_cast<bool>(di2 > 1) ); BOOST_CHECK( di2 > 1 );
BOOST_CHECK( static_cast<bool>(di2 >= di1) ); BOOST_CHECK( di2 >= di1 );
BOOST_CHECK( static_cast<bool>(di2 >= 1) ); BOOST_CHECK( di2 >= 1 );
BOOST_CHECK( static_cast<bool>(di1 / di2 == half) ); BOOST_CHECK( di1 / di2 == half );
BOOST_CHECK( static_cast<bool>(di1 / 2 == half) ); BOOST_CHECK( di1 / 2 == half );
BOOST_CHECK( static_cast<bool>(1 / di2 == half) ); BOOST_CHECK( 1 / di2 == half );
PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp/=2) == half) ); PRIVATE_EXPR_TEST( (tmp=di1), ((tmp/=2) == half) );
PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp/=di2) == half) ); PRIVATE_EXPR_TEST( (tmp=di1), ((tmp/=di2) == half) );
BOOST_CHECK( static_cast<bool>(di1 * di2 == di2) ); BOOST_CHECK( di1 * di2 == di2 );
BOOST_CHECK( static_cast<bool>(di1 * 2 == di2) ); BOOST_CHECK( di1 * 2 == di2 );
BOOST_CHECK( static_cast<bool>(1 * di2 == di2) ); BOOST_CHECK( 1 * di2 == di2 );
PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp*=2) == di2) ); PRIVATE_EXPR_TEST( (tmp=di1), ((tmp*=2) == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp*=di2) == di2) ); PRIVATE_EXPR_TEST( (tmp=di1), ((tmp*=di2) == di2) );
BOOST_CHECK( static_cast<bool>(di2 - di1 == di1) ); BOOST_CHECK( di2 - di1 == di1 );
BOOST_CHECK( static_cast<bool>(di2 - 1 == di1) ); BOOST_CHECK( di2 - 1 == di1 );
BOOST_CHECK( static_cast<bool>(2 - di1 == di1) ); BOOST_CHECK( 2 - di1 == di1 );
PRIVATE_EXPR_TEST( (tmp=di2), static_cast<bool>((tmp-=1) == di1) ); PRIVATE_EXPR_TEST( (tmp=di2), ((tmp-=1) == di1) );
PRIVATE_EXPR_TEST( (tmp=di2), static_cast<bool>((tmp-=di1) == di1) ); PRIVATE_EXPR_TEST( (tmp=di2), ((tmp-=di1) == di1) );
BOOST_CHECK( static_cast<bool>(di1 + di1 == di2) ); BOOST_CHECK( di1 + di1 == di2 );
BOOST_CHECK( static_cast<bool>(di1 + 1 == di2) ); BOOST_CHECK( di1 + 1 == di2 );
BOOST_CHECK( static_cast<bool>(1 + di1 == di2) ); BOOST_CHECK( 1 + di1 == di2 );
PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp+=1) == di2) ); PRIVATE_EXPR_TEST( (tmp=di1), ((tmp+=1) == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp+=di1) == di2) ); PRIVATE_EXPR_TEST( (tmp=di1), ((tmp+=di1) == di2) );
cout << "Performed tests on MyDoubleInt objects.\n"; cout << "Performed tests on MyDoubleInt objects.\n";
@@ -898,42 +854,42 @@ test_main( int , char * [] )
PRIVATE_EXPR_TEST( (li = li2), (li.value() == 2) ); PRIVATE_EXPR_TEST( (li = li2), (li.value() == 2) );
BOOST_CHECK( static_cast<bool>(li2 == li) ); BOOST_CHECK( li2 == li );
BOOST_CHECK( static_cast<bool>(2 == li) ); BOOST_CHECK( 2 == li );
BOOST_CHECK( static_cast<bool>(li == 2) ); BOOST_CHECK( li == 2 );
BOOST_CHECK( static_cast<bool>(li1 < li2) ); BOOST_CHECK( li1 < li2 );
BOOST_CHECK( static_cast<bool>(1 < li2) ); BOOST_CHECK( 1 < li2 );
BOOST_CHECK( static_cast<bool>(li1 <= li2) ); BOOST_CHECK( li1 <= li2 );
BOOST_CHECK( static_cast<bool>(1 <= li2) ); BOOST_CHECK( 1 <= li2 );
BOOST_CHECK( static_cast<bool>(li2 > li1) ); BOOST_CHECK( li2 > li1 );
BOOST_CHECK( static_cast<bool>(li2 > 1) ); BOOST_CHECK( li2 > 1 );
BOOST_CHECK( static_cast<bool>(li2 >= li1) ); BOOST_CHECK( li2 >= li1 );
BOOST_CHECK( static_cast<bool>(li2 >= 1) ); BOOST_CHECK( li2 >= 1 );
BOOST_CHECK( static_cast<bool>(li1 % li2 == li1) ); BOOST_CHECK( li1 % li2 == li1 );
BOOST_CHECK( static_cast<bool>(li1 % 2 == li1) ); BOOST_CHECK( li1 % 2 == li1 );
BOOST_CHECK( static_cast<bool>(1 % li2 == li1) ); BOOST_CHECK( 1 % li2 == li1 );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2%=2) == li1) ); PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2%=2) == li1) );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2%=li2) == li1) ); PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2%=li2) == li1) );
BOOST_CHECK( static_cast<bool>(li1 / li2 == 0) ); BOOST_CHECK( li1 / li2 == 0 );
BOOST_CHECK( static_cast<bool>(li1 / 2 == 0) ); BOOST_CHECK( li1 / 2 == 0 );
BOOST_CHECK( static_cast<bool>(1 / li2 == 0) ); BOOST_CHECK( 1 / li2 == 0 );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2/=2) == 0) ); PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2/=2) == 0) );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2/=li2) == 0) ); PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2/=li2) == 0) );
BOOST_CHECK( static_cast<bool>(li1 * li2 == li2) ); BOOST_CHECK( li1 * li2 == li2 );
BOOST_CHECK( static_cast<bool>(li1 * 2 == li2) ); BOOST_CHECK( li1 * 2 == li2 );
BOOST_CHECK( static_cast<bool>(1 * li2 == li2) ); BOOST_CHECK( 1 * li2 == li2 );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2*=2) == li2) ); PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2*=2) == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2*=li2) == li2) ); PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2*=li2) == li2) );
BOOST_CHECK( static_cast<bool>(li2 - li1 == li1) ); BOOST_CHECK( li2 - li1 == li1 );
BOOST_CHECK( static_cast<bool>(li2 - 1 == li1) ); BOOST_CHECK( li2 - 1 == li1 );
BOOST_CHECK( static_cast<bool>(2 - li1 == li1) ); BOOST_CHECK( 2 - li1 == li1 );
PRIVATE_EXPR_TEST( (tmp2=li2), static_cast<bool>((tmp2-=1) == li1) ); PRIVATE_EXPR_TEST( (tmp2=li2), ((tmp2-=1) == li1) );
PRIVATE_EXPR_TEST( (tmp2=li2), static_cast<bool>((tmp2-=li1) == li1) ); PRIVATE_EXPR_TEST( (tmp2=li2), ((tmp2-=li1) == li1) );
BOOST_CHECK( static_cast<bool>(li1 + li1 == li2) ); BOOST_CHECK( li1 + li1 == li2 );
BOOST_CHECK( static_cast<bool>(li1 + 1 == li2) ); BOOST_CHECK( li1 + 1 == li2 );
BOOST_CHECK( static_cast<bool>(1 + li1 == li2) ); BOOST_CHECK( 1 + li1 == li2 );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2+=1) == li2) ); PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2+=1) == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2+=li1) == li2) ); PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2+=li1) == li2) );
cout << "Performed tests on MyLongInt objects.\n"; cout << "Performed tests on MyLongInt objects.\n";

View File

@@ -68,54 +68,11 @@ struct ref_wrapper
} }
}; };
struct copy_counter {
static int count_;
copy_counter(copy_counter const& other) {
++count_;
}
copy_counter() {}
static void reset() { count_ = 0; }
static int count() { return copy_counter::count_; }
};
int copy_counter::count_ = 0;
} // namespace unnamed } // namespace unnamed
template <class T>
void do_unwrap(T t) {
/* typename unwrap_reference<T>::type& lt = */
unwrap_ref(t);
}
void unwrap_test() {
int i = 3;
const int ci = 2;
do_unwrap(i);
do_unwrap(ci);
do_unwrap(ref(i));
do_unwrap(cref(ci));
do_unwrap(ref(ci));
copy_counter cc;
BOOST_CHECK(cc.count() == 0);
do_unwrap(cc);
do_unwrap(ref(cc));
do_unwrap(cref(cc));
BOOST_CHECK(cc.count() == 1);
BOOST_CHECK(unwrap_ref(ref(cc)).count() == 1);
}
int test_main(int, char * []) int test_main(int, char * [])
{ {
ref_wrapper<int>::test(1); ref_wrapper<int>::test(1);
ref_wrapper<int const>::test(1); ref_wrapper<int const>::test(1);
unwrap_test();
return 0; return 0;
} }

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

View File

@@ -11,101 +11,35 @@
#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 struct int_result_type { typedef 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_and_char_return struct int_result_type_and_float_result_of
{ {
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 struct int_result_type_template { typedef int result_type; };
{
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_and_char_return_template struct int_result_type_and_float_result_of_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 {};
@@ -126,37 +60,16 @@ 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<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<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<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));
#endif BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_template<void>(char)>::type, int>::value));
// 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));
@@ -168,31 +81,5 @@ 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));
typedef int (*pf_t)(int);
BOOST_STATIC_ASSERT((is_same<result_of<pf_t(int)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<pf_t const(int)>::type,int>::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

@@ -154,13 +154,11 @@ 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.</p> <p>If your compiler does not support type. When <code>F</code> is a class type with a
<code>decltype</code>, then when <code>F</code> is a member type <code>result_type</code>,
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>. When <code>F</code> <code>F::result_type</code>. Otherwise,
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

@@ -253,7 +253,7 @@ its internal data, prior to constructing the object that it contains.
<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>
<pre>namespace boost {<br><br>template&lt;class T&gt;<br>class value_initialized<br>{<br> public :<br> value_initialized() : x() {}<br> operator T&amp;() const { return x ; }<br> T&amp; data() const { return x ; }<br> void swap( value_initialized&lt;T&gt;&amp; );<br><br> private :<br> <i>unspecified</i> x ;<br>} ;<br><br>template&lt;class T&gt;<br>T const&amp; get ( value_initialized&lt;T&gt; const&amp; x )<br>{<br> return x.data() ;<br>}<br><br>template&lt;class T&gt;<br>T&amp; get ( value_initialized&lt;T&gt;&amp; x )<br>{<br> return x.data() ;<br>}<br><br>} // namespace boost<br></pre> <pre>namespace boost {<br><br>template&lt;class T&gt;<br>class value_initialized<br>{<br> public :<br> value_initialized() : x() {}<br> operator T&amp;() const { return x ; }<br> T&amp; data() const { return x ; }<br><br> private :<br> <i>unspecified</i> x ;<br>} ;<br><br>template&lt;class T&gt;<br>T const&amp; get ( value_initialized&lt;T&gt; const&amp; x )<br>{<br> return x.data() ;<br>}<br><br>template&lt;class T&gt;<br>T&amp; get ( value_initialized&lt;T&gt;&amp; x )<br>{<br> return x.data() ;<br>}<br><br>} // namespace boost<br></pre>
<p>An object of this template class is a <code>T</code>-wrapper convertible <p>An object of this template class is a <code>T</code>-wrapper convertible
to <code>'T&amp;'</code> whose wrapped object (data member of type <code>T</code>) to <code>'T&amp;'</code> whose wrapped object (data member of type <code>T</code>)
@@ -277,10 +277,6 @@ non-member function <code>get()</code>: </p>
Mutable objects can be modified directly from within the wrapper but constant Mutable objects can be modified directly from within the wrapper but constant
objects cannot:</p> objects cannot:</p>
<p>When <code>T</code> is a <em>Swappable</em> type, <code>value_initialized&lt;T&gt;</code>
is swappable as well, by calling its <code>swap</code> member function
as well as by calling <code>boost::swap</code>.</p>
<pre>value_initialized&lt;int&gt; x ; <br>static_cast&lt;int&amp;&gt;(x) = 1 ; // OK<br>get(x) = 1 ; // OK<br><br>value_initialized&lt;int const&gt; y ; <br>static_cast&lt;int&amp;&gt;(y) = 1 ; // ERROR: cannot cast to int&amp;<br>static_cast&lt;int const&amp;&gt;(y) = 1 ; // ERROR: cannot modify a const value<br>get(y) = 1 ; // ERROR: cannot modify a const value</pre> <pre>value_initialized&lt;int&gt; x ; <br>static_cast&lt;int&amp;&gt;(x) = 1 ; // OK<br>get(x) = 1 ; // OK<br><br>value_initialized&lt;int const&gt; y ; <br>static_cast&lt;int&amp;&gt;(y) = 1 ; // ERROR: cannot cast to int&amp;<br>static_cast&lt;int const&amp;&gt;(y) = 1 ; // ERROR: cannot modify a const value<br>get(y) = 1 ; // ERROR: cannot modify a const value</pre>
<h3>Warning:</h3> <h3>Warning:</h3>
@@ -383,7 +379,7 @@ for Boost release version 1.35 (2008), offering a workaround to various compiler
</p> </p>
<hr> <hr>
<p>Revised 28 August 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

@@ -9,7 +9,6 @@
// 21 Ago 2002 (Created) Fernando Cacciola // 21 Ago 2002 (Created) Fernando Cacciola
// 15 Jan 2008 (Added tests regarding compiler issues) 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 // 23 May 2008 (Added tests regarding initialized_value) Niels Dekker
// 21 Ago 2008 (Added swap test) Niels Dekker
#include <cstring> // For memcmp. #include <cstring> // For memcmp.
#include <iostream> #include <iostream>
@@ -182,35 +181,6 @@ struct CopyFunctionCallTester
}; };
//
// A struct that allows testing whether its customized swap function is called.
//
struct SwapFunctionCallTester
{
bool is_custom_swap_called;
int data;
SwapFunctionCallTester()
: is_custom_swap_called(false), data(0) {}
SwapFunctionCallTester(const SwapFunctionCallTester & arg)
: is_custom_swap_called(false), data(arg.data) {}
void swap(SwapFunctionCallTester & arg)
{
std::swap(data, arg.data);
is_custom_swap_called = true;
arg.is_custom_swap_called = true;
}
};
void swap(SwapFunctionCallTester & lhs, SwapFunctionCallTester & rhs)
{
lhs.swap(rhs);
}
template<class T> template<class T>
void check_initialized_value ( T const& y ) void check_initialized_value ( T const& y )
{ {
@@ -353,20 +323,9 @@ int test_main(int, char **)
BOOST_CHECK ( ! get(copyFunctionCallTester3).is_copy_constructed); BOOST_CHECK ( ! get(copyFunctionCallTester3).is_copy_constructed);
BOOST_CHECK ( get(copyFunctionCallTester3).is_assignment_called); BOOST_CHECK ( get(copyFunctionCallTester3).is_assignment_called);
boost::value_initialized<SwapFunctionCallTester> swapFunctionCallTester1;
boost::value_initialized<SwapFunctionCallTester> swapFunctionCallTester2;
get(swapFunctionCallTester1).data = 1;
get(swapFunctionCallTester2).data = 2;
boost::swap(swapFunctionCallTester1, swapFunctionCallTester2);
BOOST_CHECK( get(swapFunctionCallTester1).data == 2 );
BOOST_CHECK( get(swapFunctionCallTester2).data == 1 );
BOOST_CHECK( get(swapFunctionCallTester1).is_custom_swap_called );
BOOST_CHECK( get(swapFunctionCallTester2).is_custom_swap_called );
return 0; return 0;
} }
unsigned int expected_failures = 0; unsigned int expected_failures = 0;