From 7ac180ed548c2b7abb8077f35fa8b857f12b8487 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 16 May 2006 22:55:27 +0000 Subject: [PATCH 001/164] Use forwarding to get SFINAE effect in some common use cases. Rename detail::result_of to detail::result_of_impl to avoid surprises when result_of is used from within boost::detail. [SVN r33981] --- include/boost/utility/detail/result_of_iterate.hpp | 14 +++++++------- include/boost/utility/result_of.hpp | 7 +++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index 5aa3a5c..06c4203 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -21,21 +21,21 @@ template struct result_of - : detail::result_of {}; + : detail::result_of_impl {}; #endif namespace detail { template -struct result_of +struct result_of_impl { typedef R type; }; template -struct result_of +struct result_of_impl { typedef R type; }; @@ -45,7 +45,7 @@ struct result_of #if BOOST_PP_ITERATION() > 1 && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) template -struct result_of { @@ -54,7 +54,7 @@ struct result_of -struct result_of @@ -64,7 +64,7 @@ struct result_of -struct result_of @@ -74,7 +74,7 @@ struct result_of -struct result_of diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp index 668cb69..4db448e 100644 --- a/include/boost/utility/result_of.hpp +++ b/include/boost/utility/result_of.hpp @@ -39,9 +39,8 @@ struct get_result_of template struct get_result_of -{ - typedef typename F::template result::type type; -}; + : F::template result +{}; template struct get_result_of @@ -50,7 +49,7 @@ struct get_result_of }; template -struct result_of : get_result_of::value)> {}; +struct result_of_impl : get_result_of::value)> {}; } // end namespace detail From ce6e9c669869c1b83936d57f78f94cc342b97c11 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 22 Jun 2006 12:47:19 +0000 Subject: [PATCH 002/164] Digital Mars support (Pavel Vozenilek) [SVN r34373] --- include/boost/current_function.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index 40e3abd..aa5756e 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -32,6 +32,10 @@ inline void current_function_helper() # define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__ +#elif defined(__DMC__) && (__DMC__ >= 0x810) + +# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__ + #elif defined(__FUNCSIG__) # define BOOST_CURRENT_FUNCTION __FUNCSIG__ From bf968794c95e7c8f081b909a105e90abedf57453 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Mon, 26 Jun 2006 01:58:38 +0000 Subject: [PATCH 003/164] Fixed an ambiguity. [SVN r34403] --- include/boost/utility/value_init.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index d991486..5591b9b 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -40,7 +40,7 @@ template struct select_base { typedef typename - detail::if_true< ::boost::is_const::value > + ::boost::detail::if_true< ::boost::is_const::value > ::template then< const_T_base, non_const_T_base >::type type ; } ; From e55610a0d08ea0567225d36dfb9a5ec6ee988394 Mon Sep 17 00:00:00 2001 From: Fernando Cacciola Date: Mon, 26 Jun 2006 18:01:38 +0000 Subject: [PATCH 004/164] Some additional functions added to optional (being new there won't be regressions) [SVN r34411] --- in_place_factories.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/in_place_factories.html b/in_place_factories.html index 9b71559..b36387d 100644 --- a/in_place_factories.html +++ b/in_place_factories.html @@ -3,9 +3,8 @@ - - -Header + +In_place_factory Documentation @@ -77,7 +76,7 @@ object is likely to be temporary and serve no purpose besides being the source

A solution to this problem is to support direct construction of the contained object right in the container's storage.
-In this shceme, the user supplies the arguments for the X constructor +In this scheme, the user supplies the arguments for the X constructor directly to the container:

struct C
 {
@@ -138,7 +137,7 @@ The following simplified example shows the basic idea. A complete example follow
 
 void foo()
 {
-  C c( in_place(123,"hello" ) ;
+  C c( in_place(123,"hello") ) ;
 }
 
From c730ab4ffb2b465c7bd288b4768d8752b7c48aa5 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 13 Sep 2006 03:00:18 +0000 Subject: [PATCH 005/164] Parameter library Workarounds for Borland and MSVC Parameter library explicit markup for expected failures value_init.hpp: Borland workarounds Use angle-includes consistently [SVN r35084] --- include/boost/utility/value_init.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index 5591b9b..65600e5 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -9,8 +9,9 @@ #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP -#include "boost/detail/select_type.hpp" -#include "boost/type_traits/cv_traits.hpp" +#include +#include +#include namespace boost { @@ -39,7 +40,10 @@ struct non_const_T_base template struct select_base { - typedef typename + typedef +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + typename +#endif ::boost::detail::if_true< ::boost::is_const::value > ::template then< const_T_base, non_const_T_base >::type type ; } ; From 5b83f641a8170474af4e280f93cf19d44dd765fd Mon Sep 17 00:00:00 2001 From: John Maddock Date: Mon, 16 Oct 2006 18:01:40 +0000 Subject: [PATCH 006/164] Removed unneeded semicolon. [SVN r35636] --- call_traits.htm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/call_traits.htm b/call_traits.htm index 53f093e..6d9bddf 100644 --- a/call_traits.htm +++ b/call_traits.htm @@ -606,7 +606,7 @@ template <bool opt> struct filler { template <typename I, typename T> - static void do_fill(I first, I last, typename boost::call_traits<T>::param_type val); + static void do_fill(I first, I last, typename boost::call_traits<T>::param_type val) { while(first != last) { @@ -762,3 +762,4 @@ href="http://www.yahoogroups.com/list/boost">www.yahoogroups.com/list/boost.

 

+ From 2f69501e558302f710b1416777dc788288115d6a Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Tue, 7 Nov 2006 19:11:57 +0000 Subject: [PATCH 007/164] Add copyright, license [SVN r35905] --- index.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 677539c..daf785e 100644 --- a/index.html +++ b/index.html @@ -27,8 +27,13 @@ value_init


+

© Copyright Beman Dawes, 2001

+

Distributed under the Boost Software License, Version 1.0. (See + accompanying file + LICENSE_1_0.txt or copy at + + www.boost.org/LICENSE_1_0.txt)

Revised - 01 September, 2003

-

 

- - + 07 November, 2006

+ + \ No newline at end of file From 0808883f3c421c2de30daf86e941bd141119a318 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 9 Nov 2006 20:34:33 +0000 Subject: [PATCH 008/164] License/copyright edits [SVN r35958] --- assert.html | 7 +++---- checked_delete.html | 7 +++---- current_function.html | 7 +++---- throw_exception.html | 7 +++---- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/assert.html b/assert.html index a3dec66..4381ae1 100644 --- a/assert.html +++ b/assert.html @@ -48,9 +48,8 @@ void assertion_failed(char const * expr, char const * function, char const * fil can be included multiple times in a single translation unit. BOOST_ASSERT will be redefined each time as specified above.


- Copyright © 2002 by Peter Dimov. Permission to copy, use, modify, sell and - distribute this document is granted provided this copyright notice appears in - all copies. This document is provided "as is" without express or implied - warranty, and with no claim as to its suitability for any purpose.

+ Copyright © 2002 by Peter Dimov. Distributed under the Boost Software License, Version + 1.0. See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt.

diff --git a/checked_delete.html b/checked_delete.html index c123fd5..33b5bcb 100644 --- a/checked_delete.html +++ b/checked_delete.html @@ -115,9 +115,8 @@ template<class T> struct checked_array_deleter


- Copyright © 2002 by Peter Dimov. Permission to copy, use, modify, sell and - distribute this document is granted provided this copyright notice appears in - all copies. This document is provided "as is" without express or implied - warranty, and with no claim as to its suitability for any purpose.

+ Copyright © 2002 by Peter Dimov. Distributed under the Boost Software License, Version + 1.0. See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt.

diff --git a/current_function.html b/current_function.html index f383e3a..373eb22 100644 --- a/current_function.html +++ b/current_function.html @@ -29,9 +29,8 @@ function. On such compilers, the string literal has an unspecified value.


- Copyright © 2002 by Peter Dimov. Permission to copy, use, modify, sell and - distribute this document is granted provided this copyright notice appears in - all copies. This document is provided "as is" without express or implied - warranty, and with no claim as to its suitability for any purpose.

+ Copyright © 2002 by Peter Dimov. Distributed under the Boost Software License, Version + 1.0. See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt.

diff --git a/throw_exception.html b/throw_exception.html index 89466fb..66a63f3 100644 --- a/throw_exception.html +++ b/throw_exception.html @@ -51,9 +51,8 @@ template<class E> void throw_exception(E const & e) }


- Copyright © 2002 by Peter Dimov. Permission to copy, use, modify, sell and - distribute this document is granted provided this copyright notice appears in - all copies. This document is provided "as is" without express or implied - warranty, and with no claim as to its suitability for any purpose.

+ Copyright © 2002 by Peter Dimov. Distributed under the Boost Software License, Version + 1.0. See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt.

From 0782034333903be15da2276fc211f5564078d165 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Fri, 10 Nov 2006 19:09:56 +0000 Subject: [PATCH 009/164] 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 r35989] --- test/Jamfile.v2 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 493011d..d5ecaa0 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -18,15 +18,15 @@ test-suite utility [ run ../binary_search_test.cpp ] [ run ../call_traits_test.cpp : -u ] [ compile-fail ../checked_delete_test.cpp ] - [ run ../compressed_pair_test.cpp ../../test/build//boost_test_exec_monitor : -u ] + [ run ../compressed_pair_test.cpp ../../test/build//boost_test_exec_monitor/static : -u ] [ run ../current_function_test.cpp : : : always_show_run_output ] - [ run ../iterators_test.cpp ../../test/build//boost_test_exec_monitor ] - [ run next_prior_test.cpp ../../test/build//boost_test_exec_monitor ] + [ run ../iterators_test.cpp ../../test/build//boost_test_exec_monitor/static ] + [ run next_prior_test.cpp ../../test/build//boost_test_exec_monitor/static ] [ compile-fail ../noncopyable_test.cpp ] [ run ../numeric_traits_test.cpp ] - [ run ../operators_test.cpp ../../test/build//boost_test_exec_monitor ] + [ run ../operators_test.cpp ../../test/build//boost_test_exec_monitor/static ] [ compile ../ref_ct_test.cpp ] - [ run ../ref_test.cpp ../../test/build//boost_test_exec_monitor ] + [ run ../ref_test.cpp ../../test/build//boost_test_exec_monitor/static ] [ compile result_of_test.cpp ] [ run ../shared_iterator_test.cpp ] [ run ../value_init_test.cpp ] From c9a3ab1d04bcc65c9839c20e3016c0a3aa22b63d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 4 Dec 2006 20:31:38 +0000 Subject: [PATCH 010/164] Linked to current_function.html [SVN r36268] --- index.html | 1 + utility.htm | 1 + 2 files changed, 2 insertions(+) diff --git a/index.html b/index.html index daf785e..1d2bffb 100644 --- a/index.html +++ b/index.html @@ -19,6 +19,7 @@ call_traits
checked_delete
compressed_pair
+ current_function
enable_if
iterator_adaptors
operators
diff --git a/utility.htm b/utility.htm index 16616ad..8d8d80f 100644 --- a/utility.htm +++ b/utility.htm @@ -23,6 +23,7 @@
  • Function template addressof()
  • Class template result_of
  • +
  • Other utilities not part of utility.hpp
  • Function templates checked_delete() and From 92a0602190c239a4e04ce674a3b3539ea7a7bd56 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Tue, 5 Dec 2006 21:11:21 +0000 Subject: [PATCH 011/164] Fixed license & copyright issues and converted to HTML 4.01 [SVN r36280] --- Assignable.html | 199 ++++--- Collection.html | 1036 ++++++++++++++++------------------- CopyConstructible.html | 303 +++++----- LessThanComparable.html | 394 +++++++------ MultiPassInputIterator.html | 157 +++--- generator_iterator.htm | 173 +++--- 6 files changed, 1065 insertions(+), 1197 deletions(-) diff --git a/Assignable.html b/Assignable.html index 557f4e7..54934f1 100644 --- a/Assignable.html +++ b/Assignable.html @@ -1,116 +1,109 @@ - - - -Assignable - - -C++ Boost - -
    -

    Assignable

    + -

    Description

    -A type is Assignable if it is possible to assign one object of the type -to another object of that type. + + + + + Assignable + -

    Notation

    - - - - - + + C++ Boost
    - - - - +

    Assignable

    - - - - +

    Description

    -
    -T - -is type that is a model of Assignable -
    -t - -is an object of type T -
    -u - -is an object of type T or possibly const T -
    -

    Definitions

    -

    Valid expressions

    - - - - - - - - - - - - - +

    A type is Assignable if it is possible to assign one object of the type + to another object of that type.

    -
    -Name - -Expression - -Return type - -Semantics -
    -Assignment - -t = u - -T& - -t is equivalent to u -
    +

    Notation

    + + + -
    T
    -

    Models

    + is type that is a model of Assignable + -
      -
    • int -
    • std::pair -
    + + t -

    See also

    -DefaultConstructible -and -CopyConstructible + is an object of type T + -
    -
    - - -
    Copyright © 2000 -Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu) -
    + + u - - + is an object of type T or possibly const + T + + + +

    Definitions

    + +

    Valid expressions

    + + + + + + + + + + + + + + + + + + + + + +
    NameExpressionReturn typeSemantics
    Assignmentt = uT&t is equivalent to u
    + +

    Models

    + +
      +
    • int
    • + +
    • std::pair
    • +
    + +

    See also

    + +

    DefaultConstructible + and CopyConstructible

    +
    + +

    Valid HTML 4.01 Transitional

    + +

    Revised + 05 December, 2006

    + + + + + + + +
    Copyright © 2000Jeremy Siek, Univ.of + Notre Dame (jsiek@lsc.nd.edu)
    + +

    Distributed under the Boost Software License, Version 1.0. (See + accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt)

    + + diff --git a/Collection.html b/Collection.html index 9069e28..c811e7e 100644 --- a/Collection.html +++ b/Collection.html @@ -1,244 +1,190 @@ - - - -Collection - + - -

    - boost logo -
    Collection -

    + + + + -

    Description

    + Collection + -A Collection is a concept similar to the STL Container -concept. A Collection provides iterators for accessing a range of -elements and provides information about the number of elements in the -Collection. However, a Collection has fewer requirements than a -Container. The motivation for the Collection concept is that there are -many useful Container-like types that do not meet the full -requirements of Container, and many algorithms that can be written -with this reduced set of requirements. To summarize the reduction -in requirements: + +

    boost logo
    + Collection

    -
      -
    • It is not required to "own" its elements: the lifetime -of an element in a Collection does not have to match the lifetime of -the Collection object, though the lifetime of the element should cover -the lifetime of the Collection object. -
    • The semantics of copying a Collection object is not defined (it -could be a deep or shallow copy or not even support copying). -
    • The associated reference type of a Collection does -not have to be a real C++ reference. -
    +

    Description

    +

    A Collection is a concept similar to the STL Container concept. A + Collection provides iterators for accessing a range of elements and + provides information about the number of elements in the Collection. + However, a Collection has fewer requirements than a Container. The + motivation for the Collection concept is that there are many useful + Container-like types that do not meet the full requirements of Container, + and many algorithms that can be written with this reduced set of + requirements. To summarize the reduction in requirements:

    -Because of the reduced requirements, some care must be taken when -writing code that is meant to be generic for all Collection types. -In particular, a Collection object should be passed by-reference -since assumptions can not be made about the behaviour of the -copy constructor. +
      +
    • It is not required to "own" its elements: the lifetime of an element + in a Collection does not have to match the lifetime of the Collection + object, though the lifetime of the element should cover the lifetime of + the Collection object.
    • -

      +

    • The semantics of copying a Collection object is not defined (it could + be a deep or shallow copy or not even support copying).
    • -

      Associated types

      +
    • The associated reference type of a Collection does not have to be a + real C++ reference.
    • +
    Because of the reduced requirements, some care must be taken when + writing code that is meant to be generic for all Collection types. In + particular, a Collection object should be passed by-reference since + assumptions can not be made about the behaviour of the copy constructor. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -Value type - -X::value_type - -The type of the object stored in a Collection. -If the Collection is mutable then -the value type must be Assignable. -Otherwise the value type must be CopyConstructible. -
    -Iterator type - -X::iterator - -The type of iterator used to iterate through a Collection's - elements. The iterator's value type is expected to be the - Collection's value type. A conversion - from the iterator type to the const iterator type must exist. - The iterator type must be an InputIterator. -
    -Const iterator type - -X::const_iterator - -A type of iterator that may be used to examine, but not to modify, - a Collection's elements. -
    -Reference type - -X::reference - -A type that behaves like a reference to the Collection's value type. -[1] -
    -Const reference type - -X::const_reference - -A type that behaves like a const reference to the Collection's value type. -
    -Pointer type - -X::pointer - -A type that behaves as a pointer to the Collection's value type. -
    -Distance type - -X::difference_type - -A signed integral type used to represent the distance between two - of the Collection's iterators. This type must be the same as - the iterator's distance type. -
    -Size type - -X::size_type - -An unsigned integral type that can represent any nonnegative value - of the Collection's distance type. -
    -

    Notation

    - - - - - - - - - - - - - -
    -X - -A type that is a model of Collection. -
    -a, b - -Object of type X. -
    -T - -The value type of X. -
    +

    Associated types

    -

    Valid expressions

    + + + -The following expressions must be valid. -

    +

    -
    Value typeX::value_type
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -Name - -Expression - -Return type -
    -Beginning of range - -a.begin() - -iterator if a is mutable, const_iterator otherwise -
    -End of range - -a.end() - -iterator if a is mutable, const_iterator otherwise -
    -Size - -a.size() - -size_type -
    -Empty Collection - -a.empty() - -Convertible to bool -
    -Swap - -a.swap(b) - -void -
    -

    Expression semantics

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -Name - -Expression - -Semantics - -Postcondition -
    -
    -Beginning of range - -a.begin() - -Returns an iterator pointing to the first element in the Collection. - -a.begin() is either dereferenceable or past-the-end. It is - past-the-end if and only if a.size() == 0. -
    -End of range - -a.end() - -Returns an iterator pointing one past the last element in the - Collection. - -a.end() is past-the-end. -
    -Size - -a.size() - -Returns the size of the Collection, that is, its number of elements. - -a.size() >= 0 -
    -Empty Collection - -a.empty() - -Equivalent to a.size() == 0. (But possibly faster.) - -  -
    -Swap - -a.swap(b) - -Equivalent to swap(a,b) - -  -
    -

    Complexity guarantees

    -begin() and end() are amortized constant time. -

    -size() is at most linear in the Collection's -size. empty() is amortized constant time. -

    -swap() is at most linear in the size of the two collections. -

    Invariants

    - - - - - - - - - - - - - -
    -Valid range - -For any Collection a, [a.begin(), a.end()) is a valid - range. -
    -Range size - -a.size() is equal to the distance from a.begin() to a.end(). -
    -Completeness - -An algorithm that iterates through the range [a.begin(), a.end()) - will pass through every element of a. -
    + + Empty Collection + a.empty() -

    Models

    -
      -
    • array -
    • array_ptr -
    • vector<bool> -
    + Equivalent to a.size() == 0. (But possibly + faster.) +   + -

    Collection Refinements

    + + Swap -There are quite a few concepts that refine the Collection concept, -similar to the concepts that refine the Container concept. Here -is a brief overview of the refining concepts. + a.swap(b) -

    ForwardCollection

    -The elements are arranged in some order that -does not change spontaneously from one iteration to the next. As -a result, a ForwardCollection is -EqualityComparable -and -LessThanComparable. -In addition, the iterator type of a ForwardCollection is a -MultiPassInputIterator which is just an InputIterator with the added -requirements that the iterator can be used to make multiple passes -through a range, and that if it1 == it2 and it1 is -dereferenceable then ++it1 == ++it2. The ForwardCollection -also has a front() method. + Equivalent to swap(a,b) -

    - - - - - - - + + +
    -Name - -Expression - -Return type - -Semantics -
     
    - - -Front - - -a.front() - - -reference if a is mutable,
    const_reference -otherwise. - - -Equivalent to *(a.begin()). - - +

    Complexity guarantees

    - +

    begin() and end() are amortized constant time.

    +

    size() is at most linear in the Collection's size. + empty() is amortized constant time.

    -

    ReversibleCollection

    +

    swap() is at most linear in the size of the two + collections.

    -The container provides access to iterators that traverse in both -directions (forward and reverse). The iterator type must meet all of -the requirements of -BidirectionalIterator -except that the reference type does not have to be a real C++ -reference. The ReversibleCollection adds the following requirements -to those of ForwardCollection. -

    +

    Invariants

    - - - - - - - - - - - - - - - - - - - +
    -Name - -Expression - -Return type - -Semantics -
    -Beginning of range - -a.rbegin() - -reverse_iterator if a is mutable, -const_reverse_iterator otherwise. - -Equivalent to X::reverse_iterator(a.end()). -
    -End of range - -a.rend() - -reverse_iterator if a is mutable, -const_reverse_iterator otherwise. - -Equivalent to X::reverse_iterator(a.begin()). -
    + + - - - - - - + + -
    Valid range
    -Back - -a.back() - -reference if a is mutable,
    const_reference -otherwise. -
    -Equivalent to *(--a.end()). -
    For any Collection a, [a.begin(), + a.end()) is a valid range.
    + + Range size -

    SequentialCollection

    + a.size() is equal to the distance from + a.begin() to a.end(). + -The elements are arranged in a strict linear order. No extra methods -are required. + + Completeness -

    RandomAccessCollection

    + An algorithm that iterates through the range + [a.begin(), a.end()) will pass through every element of + a. + + -The iterators of a RandomAccessCollection satisfy all of the -requirements of RandomAccessIterator -except that the reference type does not have to be a real C++ -reference. In addition, a RandomAccessCollection provides -an element access operator. +

    Models

    -

    +

      +
    • array
    • - - - - - - - - - - - - - +
    • array_ptr
    • -
      -Name - -Expression - -Return type - -Semantics -
      -Element Access - -a[n] - -reference if a is mutable, -const_reference otherwise. - -Returns the nth element of the Collection. -n must be convertible to size_type. -Precondition: 0 <= n < a.size(). -
      +
    • vector<bool>
    • +
    -

    Notes

    +

    Collection Refinements

    -

    [1] +

    There are quite a few concepts that refine the Collection concept, + similar to the concepts that refine the Container concept. Here is a brief + overview of the refining concepts.

    -The reference type does not have to be a real C++ reference. The -requirements of the reference type depend on the context within which -the Collection is being used. Specifically it depends on the -requirements the context places on the value type of the Collection. -The reference type of the Collection must meet the same requirements -as the value type. In addition, the reference objects must be -equivalent to the value type objects in the collection (which is -trivially true if they are the same object). Also, in a mutable -Collection, an assignment to the reference object must result in an -assignment to the object in the Collection (again, which is trivially -true if they are the same object, but non-trivial if the reference -type is a proxy class). +

    ForwardCollection

    -

    See also

    -Container +

    The elements are arranged in some order that does not change + spontaneously from one iteration to the next. As a result, a + ForwardCollection is EqualityComparable + and LessThanComparable. + In addition, the iterator type of a ForwardCollection is a + MultiPassInputIterator which is just an InputIterator with the added + requirements that the iterator can be used to make multiple passes through + a range, and that if it1 == it2 and it1 is + dereferenceable then ++it1 == ++it2. The ForwardCollection also + has a front() method.

    + + + -
    -
    -
    Name
    - -
    Copyright © 2000 -Jeremy Siek, Univ.of Notre Dame and C++ Library & Compiler Group/SGI (jsiek@engr.sgi.com) -
    + Expression - - + Return type + + Semantics + + + + Front + + a.front() + + reference if a is mutable,
    + const_reference otherwise. + + Equivalent to *(a.begin()). + + + +

    ReversibleCollection

    + +

    The container provides access to iterators that traverse in both + directions (forward and reverse). The iterator type must meet all of the + requirements of BidirectionalIterator + except that the reference type does not have to be a real C++ reference. + The ReversibleCollection adds the following requirements to those of + ForwardCollection.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameExpressionReturn typeSemantics
    Beginning of rangea.rbegin()reverse_iterator if a is mutable, + const_reverse_iterator otherwise.Equivalent to + X::reverse_iterator(a.end()).
    End of rangea.rend()reverse_iterator if a is mutable, + const_reverse_iterator otherwise.Equivalent to + X::reverse_iterator(a.begin()).
    Backa.back()reference if a is mutable,
    + const_reference otherwise.
    Equivalent to *(--a.end()).
    + +

    SequentialCollection

    + +

    The elements are arranged in a strict linear order. No extra methods are + required.

    + +

    RandomAccessCollection

    + +

    The iterators of a RandomAccessCollection satisfy all of the + requirements of RandomAccessIterator + except that the reference type does not have to be a real C++ reference. In + addition, a RandomAccessCollection provides an element access operator.

    + + + + + + + + + + + + + + + + + + + + + +
    NameExpressionReturn typeSemantics
    Element Accessa[n]reference if a is mutable, + const_reference otherwise.Returns the nth element of the Collection. n + must be convertible to size_type. Precondition: 0 <= n + < a.size().
    + +

    Notes

    + +

    [1] The reference type does not have to be a + real C++ reference. The requirements of the reference type depend on the + context within which the Collection is being used. Specifically it depends + on the requirements the context places on the value type of the Collection. + The reference type of the Collection must meet the same requirements as the + value type. In addition, the reference objects must be equivalent to the + value type objects in the collection (which is trivially true if they are + the same object). Also, in a mutable Collection, an assignment to the + reference object must result in an assignment to the object in the + Collection (again, which is trivially true if they are the same object, but + non-trivial if the reference type is a proxy class).

    + +

    See also

    + +

    Container

    +
    + +

    Valid HTML 4.01 Transitional

    + +

    Revised + 05 + December, 2006

    + + + + + + + +
    Copyright © 2000Jeremy + Siek, Univ.of Notre Dame and C++ Library & Compiler Group/SGI + (jsiek@engr.sgi.com)
    + +

    Distributed under the Boost Software License, Version 1.0. (See + accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt)

    + + diff --git a/CopyConstructible.html b/CopyConstructible.html index f2d6308..40ff7a7 100644 --- a/CopyConstructible.html +++ b/CopyConstructible.html @@ -1,178 +1,139 @@ - - - -Copy Constructible - - -C++ Boost - -
    -

    Copy Constructible

    + -

    Description

    -A type is Copy Constructible if it is possible to copy objects of that -type. + + + + -

    Notation

    - - - - - + Copy Constructible + - - - - + + C++ Boost
    - - - - +

    Copy Constructible

    -
    -T - -is type that is a model of Copy Constructible -
    -t - -is an object of type T -
    -u - -is an object of type const T -
    -

    Definitions

    -

    Valid expressions

    - - - - - - - - - - - - - +

    Description

    +

    A type is Copy Constructible if it is possible to copy objects of that + type.

    - - -
    -Name - -Expression - -Return type - -Semantics -
    -Copy constructor - -T(t) - -T - -t is equivalent to T(t) -
    -Copy constructor - -
    +  

    Notation

    + + + + + + + + + + + + + + + + + + + +
    Tis type that is a model of Copy Constructible
    tis an object of type T
    uis an object of type const T
    + +

    Definitions

    + +

    Valid expressions

    + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + - - - + + + + + + - - - + - - - + + + + + + + + - - - + - - - + + + + + + + + - - - + + + + +
    NameExpressionReturn typeSemantics
    Copy constructorT(t)Tt is equivalent to T(t)
    Copy constructor +
     T(u)
     
    -
    -T - -u is equivalent to T(u) -
    T
    -Destructor - -
    +      
    u is equivalent to T(u)
    Destructor +
     t.~T()
     
    -
    -T - -  -
    -Address Operator - -
    +      
    T 
    Address Operator +
     &t
     
    -
    -T* - -denotes the address of t -
    -Address Operator - -
    +      
    T*denotes the address of t
    Address Operator +
     &u
     
    -
    -T* - -denotes the address of u -
    T*denotes the address of u
    -
    +

    Models

    +
      +
    • int
    • - -

      Models

      +
    • std::pair
    • +
    -
      -
    • int -
    • std::pair -
    - -

    Concept Checking Class

    - -
    +  

    Concept Checking Class

    +
       template <class T>
       struct CopyConstructibleConcept
       {
    @@ -192,19 +153,33 @@ denotes the address of u
       };
     
    -

    See also

    -Default Constructible -and -Assignable +

    See also

    -
    -
    - - -
    Copyright © 2000 -Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu) -
    +

    Default + Constructible and Assignable

    +
    - - +

    Valid HTML 4.01 Transitional

    + +

    Revised + 05 + December, 2006

    + + + + + + + +
    Copyright © 2000Jeremy Siek, Univ.of + Notre Dame (jsiek@lsc.nd.edu)
    + +

    Distributed under the Boost Software License, Version 1.0. (See + accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt)

    + + diff --git a/LessThanComparable.html b/LessThanComparable.html index 8913b38..a723377 100644 --- a/LessThanComparable.html +++ b/LessThanComparable.html @@ -1,212 +1,210 @@ - + + + - - -LessThanComparable - - -C++ Boost - -
    -

    LessThanComparable

    -

    Description

    -A type is LessThanComparable if it is ordered: it must -be possible to compare two objects of that type using operator<, and -operator< must be a strict weak ordering relation. + + + + LessThanComparable + -

    Refinement of

    -

    Associated types

    -

    Notation

    - - - - - - - - - -
    -X - -A type that is a model of LessThanComparable -
    -x, y, z - -Object of type X -
    -

    Definitions

    -Consider the relation !(x < y) && !(y < x). If this relation is -transitive (that is, if !(x < y) && !(y < x) && !(y < z) && !(z < y) -implies !(x < z) && !(z < x)), then it satisfies the mathematical -definition of an equivalence relation. In this case, operator< -is a strict weak ordering. -

    -If operator< is a strict weak ordering, and if each equivalence class -has only a single element, then operator< is a total ordering. -

    Valid expressions

    - - - - - - - - - - - - - -
    -Name - -Expression - -Type requirements - -Return type -
    -Less - -x < y - -  - -Convertible to bool -
    + + C++ Boost
    +

    LessThanComparable

    +

    Description

    -

    Expression semantics

    - - - - - - - - - - - - - -
    -Name - -Expression - -Precondition - -Semantics - -Postcondition -
    -Less - -x < y - -x and y are in the domain of < - -  -
    +

    A type is LessThanComparable if it is ordered: it must be possible to + compare two objects of that type using operator<, and + operator< must be a strict weak ordering relation.

    +

    Refinement of

    -

    Complexity guarantees

    -

    Invariants

    - - - - - - - - - - - - - -
    -Irreflexivity - -x < x must be false. -
    -Antisymmetry - -x < y implies !(y < x) [2] -
    -Transitivity - -x < y and y < z implies x < z [3] -
    -

    Models

    -
      -
    • -int -
    -

    Notes

    -

    [1] -Only operator< is fundamental; the other inequality operators -are essentially syntactic sugar. -

    [2] -Antisymmetry is a theorem, not an axiom: it follows from -irreflexivity and transitivity. -

    [3] -Because of irreflexivity and transitivity, operator< always -satisfies the definition of a partial ordering. The definition of -a strict weak ordering is stricter, and the definition of a -total ordering is stricter still. -

    See also

    -EqualityComparable, StrictWeakOrdering +

    Associated types

    +

    Notation

    + + + -
    -
    -
    X
    - -
    Copyright © 2000 -Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu) -
    + A type that is a model of LessThanComparable + - - + + x, y, z + + Object of type X + + + +

    Definitions

    + +

    Consider the relation !(x < y) && !(y < x). If + this relation is transitive (that is, if !(x < y) && !(y + < x) && !(y < z) && !(z < y) implies !(x + < z) && !(z < x)), then it satisfies the mathematical + definition of an equivalence relation. In this case, operator< + is a strict weak ordering.

    + +

    If operator< is a strict weak ordering, and if each + equivalence class has only a single element, then operator< is + a total ordering.

    + +

    Valid expressions

    + + + + + + + + + + + + + + + + + + + + + +
    NameExpressionType requirementsReturn type
    Lessx < y Convertible to bool
    + +

    Expression semantics

    + + + + + + + + + + + + + + + + + + + + + + + +
    NameExpressionPreconditionSemanticsPostcondition
    Lessx < yx and y are in the domain of + < 
    + +

    Complexity guarantees

    + +

    Invariants

    + + + + + + + + + + + + + + + + + + + +
    Irreflexivityx < x must be false.
    Antisymmetryx < y implies !(y < x) [2]
    Transitivityx < y and y < z implies x + < z [3]
    + +

    Models

    + +
      +
    • int
    • +
    + +

    Notes

    + +

    [1] Only operator< is fundamental; + the other inequality operators are essentially syntactic sugar.

    + +

    [2] Antisymmetry is a theorem, not an axiom: it + follows from irreflexivity and transitivity.

    + +

    [3] Because of irreflexivity and transitivity, + operator< always satisfies the definition of a partial + ordering. The definition of a strict weak ordering is stricter, + and the definition of a total ordering is stricter still.

    + +

    See also

    + +

    EqualityComparable, + StrictWeakOrdering
    +

    +
    + +

    Valid HTML 4.01 Transitional

    + +

    Revised + 05 + December, 2006

    + + + + + + + +
    Copyright © 2000Jeremy Siek, Univ.of + Notre Dame (jsiek@lsc.nd.edu)
    + +

    Distributed under the Boost Software License, Version 1.0. (See + accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt)

    + + diff --git a/MultiPassInputIterator.html b/MultiPassInputIterator.html index dec6e31..fa7517c 100644 --- a/MultiPassInputIterator.html +++ b/MultiPassInputIterator.html @@ -1,92 +1,95 @@ - - - -MultiPassInputIterator - -C++ Boost + -
    + + + + -

    - -Multi-Pass Input Iterator -

    + MultiPassInputIterator + -This concept is a refinement of Input Iterator, -adding the requirements that the iterator can be used to make multiple -passes through a range, and that if it1 == it2 and -it1 is dereferenceable then ++it1 == ++it2. The -Multi-Pass Input Iterator is very similar to the Forward Iterator. The -only difference is that a Forward Iterator -requires the reference type to be value_type&, whereas -MultiPassInputIterator is like Input Iterator -in that the reference type merely has to be convertible to -value_type. + + C++ Boost
    +

    Multi-Pass Input Iterator

    -

    Design Notes

    +

    This concept is a refinement of Input Iterator, adding + the requirements that the iterator can be used to make multiple passes + through a range, and that if it1 == it2 and it1 is + dereferenceable then ++it1 == ++it2. The Multi-Pass Input Iterator + is very similar to the Forward Iterator. + The only difference is that a Forward Iterator + requires the reference type to be value_type&, + whereas MultiPassInputIterator is like Input Iterator in that + the reference type merely has to be convertible to + value_type.

    -comments by Valentin Bonnard: +

    Design Notes

    -

    I think that introducing Multi-Pass Input Iterator isn't the right -solution. Do you also want to define Multi-Pass Bidirectionnal Iterator -and Multi-Pass Random Access Iterator ? I don't, definitly. It only -confuses the issue. The problem lies into the existing hierarchy of -iterators, which mixes movabillity, modifiabillity and lvalue-ness, -and these are clearly independant. +

    comments by Valentin Bonnard:

    -

    The terms Forward, Bidirectionnal and Random Access are about -movabillity and shouldn't be used to mean anything else. In a -completly orthogonal way, iterators can be immutable, mutable, or -neither. Lvalueness of iterators is also orthogonal with -immutabillity. With these clean concepts, your Multi-Pass Input Iterator -is just called a Forward Iterator. +

    I think that introducing Multi-Pass Input Iterator isn't the right + solution. Do you also want to define Multi-Pass Bidirectionnal Iterator and + Multi-Pass Random Access Iterator ? I don't, definitly. It only confuses + the issue. The problem lies into the existing hierarchy of iterators, which + mixes movabillity, modifiabillity and lvalue-ness, and these are clearly + independant.

    -

    -Other translations are:
    -std::Forward Iterator -> ForwardIterator & Lvalue Iterator
    -std::Bidirectionnal Iterator -> Bidirectionnal Iterator & Lvalue Iterator
    -std::Random Access Iterator -> Random Access Iterator & Lvalue Iterator
    +

    The terms Forward, Bidirectionnal and Random Access are about + movabillity and shouldn't be used to mean anything else. In a completly + orthogonal way, iterators can be immutable, mutable, or neither. Lvalueness + of iterators is also orthogonal with immutabillity. With these clean + concepts, your Multi-Pass Input Iterator is just called a Forward + Iterator.

    -

    -Note that in practice the only operation not allowed on my -Forward Iterator which is allowed on std::Forward Iterator is -&*it. I think that &* is rarely needed in generic code. +

    Other translations are:
    + std::Forward Iterator -> ForwardIterator & Lvalue Iterator
    + std::Bidirectionnal Iterator -> Bidirectionnal Iterator & Lvalue + Iterator
    + std::Random Access Iterator -> Random Access Iterator & Lvalue + Iterator

    -

    -reply by Jeremy Siek: +

    Note that in practice the only operation not allowed on my Forward + Iterator which is allowed on std::Forward Iterator is &*it. I + think that &* is rarely needed in generic code.

    -

    -The above analysis by Valentin is right on. Of course, there is -the problem with backward compatibility. The current STL implementations -are based on the old definition of Forward Iterator. The right course -of action is to get Forward Iterator, etc. changed in the C++ standard. -Once that is done we can drop Multi-Pass Input Iterator. +

    reply by Jeremy Siek:

    +

    The above analysis by Valentin is right on. Of course, there is the + problem with backward compatibility. The current STL implementations are + based on the old definition of Forward Iterator. The right course of action + is to get Forward Iterator, etc. changed in the C++ standard. Once that is + done we can drop Multi-Pass Input Iterator.

    +
    -
    -
    - - -
    Copyright © 2000 -Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu) -
    +

    Valid HTML 4.01 Transitional

    - - +

    Revised + 05 + December, 2006

    + + + + + + + +
    Copyright © 2000Jeremy Siek, Univ.of + Notre Dame (jsiek@lsc.nd.edu)
    + +

    Distributed under the Boost Software License, Version 1.0. (See + accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt)

    + + diff --git a/generator_iterator.htm b/generator_iterator.htm index fd3e3fc..c81d3d1 100644 --- a/generator_iterator.htm +++ b/generator_iterator.htm @@ -1,33 +1,37 @@ - + -Generator Iterator Adaptor Documentation + + + + Generator Iterator Adaptor Documentation - -boost.png (6897 bytes) + boost.png (6897 bytes) -

    Generator Iterator Adaptor

    -Defined in header boost/generator_iterator.hpp -

    -The generator iterator adaptor makes it easier to create custom input -iterators from 0-ary functions and function objects. The adaptor -takes a -Generator -and creates a model of -Input Iterator. -Each increment retrieves an item from the generator and makes it -available to be retrieved by dereferencing. The motivation for this -iterator is that some concepts can be more naturally expressed as a -generator, while most STL algorithms expect an iterator. An example -is the Random Number library. +

    Generator Iterator Adaptor

    -

    Synopsis

    +

    Defined in header boost/generator_iterator.hpp

    -
    -
    +  

    The generator iterator adaptor makes it easier to create custom input + iterators from 0-ary functions and function objects. The adaptor takes a + Generator and + creates a model of Input Iterator. Each + increment retrieves an item from the generator and makes it available to be + retrieved by dereferencing. The motivation for this iterator is that some + concepts can be more naturally expressed as a generator, while most STL + algorithms expect an iterator. An example is the Random Number library.

    + +

    Synopsis

    + +
    +
     namespace boost {
       template <class Generator>
       class generator_iterator_policies;
    @@ -40,21 +44,19 @@ namespace boost {
       make_generator_iterator(Generator & gen);
     }
     
    -
    +
    +
    -
    +

    The Generator Iterator Generator Class

    -

    The Generator Iterator Generator Class

    - -The class generator_iterator_generator is a helper class whose purpose -is to construct a generator iterator type. The template parameter for -this class is the Generator function object type that is being -wrapped. The generator iterator adaptor only holds a reference (or -pointer) to the function object, therefore the function object must -outlive the generator iterator adaptor constructed from it. - -
    -template <class Generator>
    +  

    The class generator_iterator_generator is a helper class whose purpose + is to construct a generator iterator type. The template parameter for this + class is the Generator function object type that is being wrapped. The + generator iterator adaptor only holds a reference (or pointer) to the + function object, therefore the function object must outlive the generator + iterator adaptor constructed from it.

    +
    +template <class Generator>
     class generator_iterator_generator
     {
     public:
    @@ -62,65 +64,65 @@ public:
     }
     
    +

    Template Parameters

    -

    Template Parameters

    + + + -
    Parameter
    - - - - + + - - -
    ParameterDescription
    Description
    Generator -The generator (0-ary function object) type being -wrapped. The return type of the function must be defined as -Generator::result_type. The function object must be a model -of -Generator. -
    + + Generator -

    Concept Model

    -The generator iterator class is a model of -Input Iterator. + The generator (0-ary function object) type being wrapped. The + return type of the function must be defined as + Generator::result_type. The function object must be a model of + Generator. + + -

    Members

    -The generator iterator implements the member functions -and operators required of the -Input Iterator -concept. +

    Concept Model

    -
    +

    The generator iterator class is a model of Input Iterator.

    -
    -

    The Generator Iterator Object Generator

    +

    Members

    -The make_generator_iterator() function provides a -convenient way to create generator iterator objects. The function -saves the user the trouble of explicitly writing out the iterator -types. +

    The generator iterator implements the member functions and operators + required of the Input Iterator + concept.

    +
    -
    -
    +  

    The + Generator Iterator Object Generator

    + +

    The make_generator_iterator() function provides a convenient + way to create generator iterator objects. The function saves the user the + trouble of explicitly writing out the iterator types.

    + +
    +
     template <class Generator>
     typename generator_iterator_generator<Generator>::type
     make_generator_iterator(Generator & gen);
     
    -
    +
    +
    -
    +

    Example

    +

    The following program shows how generator_iterator + transforms a generator into an input iterator.

    -

    Example

    - -The following program shows how generator_iterator -transforms a generator into an input iterator. - -
    -
    -#include <iostream>
    -#include <boost/generator_iterator.hpp>
    +  
    +
    +#include <iostream>
    +#include <boost/generator_iterator.hpp>
     
     class my_generator
     {
    @@ -140,11 +142,22 @@ int main()
         std::cout << *it << std::endl;
     }
     
    -
    +
    +
    -
    +

    Valid HTML 4.01 Transitional

    -Written by Jens Maurer. +

    Revised + 05 December, 2006

    +

    Copyright © 2001 Jens Maurer

    + +

    Distributed under the Boost Software License, Version 1.0. (See + accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt)

    From 1950f292df6f50b43cf6c59c33e771b6a316475a Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 7 Jan 2007 23:50:56 +0000 Subject: [PATCH 012/164] Merge fixed links from RC_1_34_0. [SVN r36660] --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 1d2bffb..b08822b 100644 --- a/index.html +++ b/index.html @@ -30,11 +30,11 @@

    © Copyright Beman Dawes, 2001

    Distributed under the Boost Software License, Version 1.0. (See - accompanying file + accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)

    Revised 07 November, 2006

    - \ No newline at end of file + From 63cde4d3fd724c3eecba9e38e6f2f3f7fcb508ee Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Mon, 8 Jan 2007 20:38:51 +0000 Subject: [PATCH 013/164] slightly modified implementation works around msvc 7.1/8.0 compiler bugs [SVN r36668] --- .../utility/detail/result_of_iterate.hpp | 14 +++++------ include/boost/utility/result_of.hpp | 11 ++++----- test/result_of_test.cpp | 24 +++++++++++++++++++ 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index 06c4203..2c148bc 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -21,21 +21,21 @@ template struct result_of - : detail::result_of_impl {}; + : detail::result_of_impl::value)> {}; #endif namespace detail { template -struct result_of_impl +struct result_of_impl { typedef R type; }; template -struct result_of_impl +struct result_of_impl { typedef R type; }; @@ -47,7 +47,7 @@ template struct result_of_impl + FArgs, false> { typedef R type; }; @@ -57,7 +57,7 @@ template + FArgs, false> { typedef R type; }; @@ -67,7 +67,7 @@ template + FArgs, false> { typedef R type; }; @@ -77,7 +77,7 @@ template + FArgs, false> { typedef R type; }; diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp index 4db448e..5c5c3d2 100644 --- a/include/boost/utility/result_of.hpp +++ b/include/boost/utility/result_of.hpp @@ -29,28 +29,25 @@ namespace detail { BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) -template struct get_result_of; +template struct result_of_impl; template -struct get_result_of +struct result_of_impl { typedef typename F::result_type type; }; template -struct get_result_of +struct result_of_impl : F::template result {}; template -struct get_result_of +struct result_of_impl { typedef void type; }; -template -struct result_of_impl : get_result_of::value)> {}; - } // end namespace detail #define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,)) diff --git a/test/result_of_test.cpp b/test/result_of_test.cpp index af7aba2..ea48e73 100644 --- a/test/result_of_test.cpp +++ b/test/result_of_test.cpp @@ -24,6 +24,24 @@ struct int_result_type_and_float_result_of template struct result { typedef float type; }; }; +template +struct int_result_type_template { typedef int result_type; }; + +template +struct int_result_of_template +{ + template struct result; + template struct result { typedef int type; }; +}; + +template +struct int_result_type_and_float_result_of_template +{ + typedef int result_type; + template struct result; + template struct result { typedef float type; }; +}; + struct X {}; int main() @@ -43,6 +61,12 @@ int main() BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, void>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(float)>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value)); + BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value)); + BOOST_STATIC_ASSERT((is_same(char)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); From 66514f61ff23d377f02f051a1600772613bfaef0 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 24 Jan 2007 06:44:20 +0000 Subject: [PATCH 014/164] fix result_of ambiguity error for nullary functions [SVN r36773] --- .../utility/detail/result_of_iterate.hpp | 13 +++++++---- include/boost/utility/result_of.hpp | 23 ++++++++++++++++--- test/result_of_test.cpp | 7 ++++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index 2c148bc..fa0ab89 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -24,25 +24,27 @@ struct result_of : detail::result_of_impl::value)> {}; #endif +#undef BOOST_RESULT_OF_ARGS + +#if BOOST_PP_ITERATION() >= 1 + namespace detail { template -struct result_of_impl +struct result_of_impl { typedef R type; }; template -struct result_of_impl +struct result_of_impl { typedef R type; }; -#undef BOOST_RESULT_OF_ARGS - -#if BOOST_PP_ITERATION() > 1 && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) template struct result_of_impl struct result_of_impl; +template +struct result_of_void_impl +{ + typedef void type; +}; + +template +struct result_of_void_impl +{ + typedef R type; +}; + +template +struct result_of_void_impl +{ + typedef R type; +}; + template struct result_of_impl { @@ -44,9 +62,8 @@ struct result_of_impl template struct result_of_impl -{ - typedef void type; -}; + : result_of_void_impl +{}; } // end namespace detail diff --git a/test/result_of_test.cpp b/test/result_of_test.cpp index ea48e73..ca1cfae 100644 --- a/test/result_of_test.cpp +++ b/test/result_of_test.cpp @@ -50,10 +50,13 @@ int main() typedef int (*func_ptr)(float, double); typedef int (&func_ref)(float, double); + typedef int (*func_ptr_0)(); + typedef int (&func_ref_0)(); typedef int (X::*mem_func_ptr)(float); typedef int (X::*mem_func_ptr_c)(float) const; typedef int (X::*mem_func_ptr_v)(float) volatile; typedef int (X::*mem_func_ptr_cv)(float) const volatile; + typedef int (X::*mem_func_ptr_0)(); BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); @@ -69,9 +72,13 @@ int main() BOOST_STATIC_ASSERT((is_same(char)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + return 0; } From 2d860e2574952dea7267537151e0eae92ca6a8a4 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 5 Mar 2007 15:25:16 +0000 Subject: [PATCH 015/164] Fix result_of's handling of F(void). [SVN r37140] --- include/boost/utility/result_of.hpp | 21 +++++++++++++++------ test/result_of_test.cpp | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp index c2e6478..cdcac34 100644 --- a/include/boost/utility/result_of.hpp +++ b/include/boost/utility/result_of.hpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include #ifndef BOOST_RESULT_OF_NUM_ARGS # define BOOST_RESULT_OF_NUM_ARGS 10 @@ -55,14 +57,21 @@ struct result_of_impl typedef typename F::result_type type; }; -template -struct result_of_impl - : F::template result -{}; +template +struct is_function_with_no_args : mpl::false_ {}; template -struct result_of_impl - : result_of_void_impl +struct is_function_with_no_args : mpl::true_ {}; + +template +struct result_of_nested_result : F::template result +{}; + +template +struct result_of_impl + : mpl::if_, + result_of_void_impl, + result_of_nested_result >::type {}; } // end namespace detail diff --git a/test/result_of_test.cpp b/test/result_of_test.cpp index ca1cfae..10f3410 100644 --- a/test/result_of_test.cpp +++ b/test/result_of_test.cpp @@ -79,6 +79,7 @@ int main() BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); return 0; } From 06404f7d39eb33f3e75bb01b1e89fa48694868bc Mon Sep 17 00:00:00 2001 From: Daniel Frey Date: Wed, 23 May 2007 22:48:42 +0000 Subject: [PATCH 016/164] Improved empty_base [SVN r37754] --- include/boost/operators.hpp | 204 ++++++++++++++++++------------------ 1 file changed, 103 insertions(+), 101 deletions(-) diff --git a/include/boost/operators.hpp b/include/boost/operators.hpp index fbba602..b3b1bd7 100644 --- a/include/boost/operators.hpp +++ b/include/boost/operators.hpp @@ -8,6 +8,8 @@ // See http://www.boost.org/libs/utility/operators.htm for documentation. // Revision History +// 24 May 07 Changed empty_base to depend on T, see +// http://svn.boost.org/trac/boost/ticket/979 // 21 Oct 02 Modified implementation of operators to allow compilers with a // correct named return value optimization (NRVO) to produce optimal // code. (Daniel Frey) @@ -90,15 +92,15 @@ namespace boost { namespace detail { +template class empty_base { + // Helmut Zeisel, empty base class optimization bug with GCC 3.0.0 #if defined(__GNUC__) && __GNUC__==3 && __GNUC_MINOR__==0 && __GNU_PATCHLEVEL__==0 -class empty_base { bool dummy; -}; -#else -class empty_base {}; #endif +}; + } // namespace detail } // namespace boost @@ -119,7 +121,7 @@ namespace boost // Note that friend functions defined in a class are implicitly inline. // See the C++ std, 11.4 [class.friend] paragraph 5 -template +template > struct less_than_comparable2 : B { friend bool operator<=(const T& x, const U& y) { return !(x > y); } @@ -130,7 +132,7 @@ struct less_than_comparable2 : B friend bool operator>=(const U& x, const T& y) { return !(y > x); } }; -template +template > struct less_than_comparable1 : B { friend bool operator>(const T& x, const T& y) { return y < x; } @@ -138,7 +140,7 @@ struct less_than_comparable1 : B friend bool operator>=(const T& x, const T& y) { return !(x < y); } }; -template +template > struct equality_comparable2 : B { friend bool operator==(const U& y, const T& x) { return x == y; } @@ -146,7 +148,7 @@ struct equality_comparable2 : B friend bool operator!=(const T& y, const U& x) { return !(y == x); } }; -template +template > struct equality_comparable1 : B { friend bool operator!=(const T& x, const T& y) { return !(x == y); } @@ -165,7 +167,7 @@ struct equality_comparable1 : B // implementation available. #define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \ -template \ +template > \ struct NAME##2 : B \ { \ friend T operator OP( const T& lhs, const U& rhs ) \ @@ -174,33 +176,33 @@ struct NAME##2 : B \ { T nrv( rhs ); nrv OP##= lhs; return nrv; } \ }; \ \ -template \ +template > \ struct NAME##1 : B \ { \ friend T operator OP( const T& lhs, const T& rhs ) \ { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ }; -#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \ -template \ -struct NAME##2 : B \ -{ \ - friend T operator OP( const T& lhs, const U& rhs ) \ - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ -}; \ - \ -template \ -struct BOOST_OPERATOR2_LEFT(NAME) : B \ -{ \ - friend T operator OP( const U& lhs, const T& rhs ) \ - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ -}; \ - \ -template \ -struct NAME##1 : B \ -{ \ - friend T operator OP( const T& lhs, const T& rhs ) \ - { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ +#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \ +template > \ +struct NAME##2 : B \ +{ \ + friend T operator OP( const T& lhs, const U& rhs ) \ + { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ +}; \ + \ +template > \ +struct BOOST_OPERATOR2_LEFT(NAME) : B \ +{ \ + friend T operator OP( const U& lhs, const T& rhs ) \ + { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ +}; \ + \ +template > \ +struct NAME##1 : B \ +{ \ + friend T operator OP( const T& lhs, const T& rhs ) \ + { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ }; #else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS) @@ -210,35 +212,35 @@ struct NAME##1 : B \ // BOOST_OPERATOR2_LEFT(NAME) only looks cool, but doesn't provide // optimization opportunities to the compiler :) -#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \ -template \ -struct NAME##2 : B \ -{ \ - friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \ - friend T operator OP( const U& lhs, T rhs ) { return rhs OP##= lhs; } \ -}; \ - \ -template \ -struct NAME##1 : B \ -{ \ - friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \ +#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \ +template > \ +struct NAME##2 : B \ +{ \ + friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \ + friend T operator OP( const U& lhs, T rhs ) { return rhs OP##= lhs; } \ +}; \ + \ +template > \ +struct NAME##1 : B \ +{ \ + friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \ }; #define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \ -template \ +template > \ struct NAME##2 : B \ { \ friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \ }; \ \ -template \ +template > \ struct BOOST_OPERATOR2_LEFT(NAME) : B \ { \ friend T operator OP( const U& lhs, const T& rhs ) \ { return T( lhs ) OP##= rhs; } \ }; \ \ -template \ +template > \ struct NAME##1 : B \ { \ friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \ @@ -261,7 +263,7 @@ BOOST_BINARY_OPERATOR_COMMUTATIVE( orable, | ) // incrementable and decrementable contributed by Jeremy Siek -template +template > struct incrementable : B { friend T operator++(T& x, int) @@ -274,7 +276,7 @@ private: // The use of this typedef works around a Borland bug typedef T incrementable_type; }; -template +template > struct decrementable : B { friend T operator--(T& x, int) @@ -289,7 +291,7 @@ private: // The use of this typedef works around a Borland bug // Iterator operator classes (contributed by Jeremy Siek) ------------------// -template +template > struct dereferenceable : B { P operator->() const @@ -298,7 +300,7 @@ struct dereferenceable : B } }; -template +template > struct indexable : B { R operator[](I n) const @@ -313,14 +315,14 @@ struct indexable : B #if defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS) #define BOOST_BINARY_OPERATOR( NAME, OP ) \ -template \ +template > \ struct NAME##2 : B \ { \ friend T operator OP( const T& lhs, const U& rhs ) \ { T nrv( lhs ); nrv OP##= rhs; return nrv; } \ }; \ \ -template \ +template > \ struct NAME##1 : B \ { \ friend T operator OP( const T& lhs, const T& rhs ) \ @@ -330,13 +332,13 @@ struct NAME##1 : B \ #else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS) #define BOOST_BINARY_OPERATOR( NAME, OP ) \ -template \ +template > \ struct NAME##2 : B \ { \ friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \ }; \ \ -template \ +template > \ struct NAME##1 : B \ { \ friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \ @@ -349,7 +351,7 @@ BOOST_BINARY_OPERATOR( right_shiftable, >> ) #undef BOOST_BINARY_OPERATOR -template +template > struct equivalent2 : B { friend bool operator==(const T& x, const U& y) @@ -358,7 +360,7 @@ struct equivalent2 : B } }; -template +template > struct equivalent1 : B { friend bool operator==(const T&x, const T&y) @@ -367,7 +369,7 @@ struct equivalent1 : B } }; -template +template > struct partially_ordered2 : B { friend bool operator<=(const T& x, const U& y) @@ -384,7 +386,7 @@ struct partially_ordered2 : B { return (y < x) || (y == x); } }; -template +template > struct partially_ordered1 : B { friend bool operator>(const T& x, const T& y) @@ -397,161 +399,161 @@ struct partially_ordered1 : B // Combined operator classes (contributed by Daryle Walker) ----------------// -template +template > struct totally_ordered2 : less_than_comparable2 > {}; -template +template > struct totally_ordered1 : less_than_comparable1 > {}; -template +template > struct additive2 : addable2 > {}; -template +template > struct additive1 : addable1 > {}; -template +template > struct multiplicative2 : multipliable2 > {}; -template +template > struct multiplicative1 : multipliable1 > {}; -template +template > struct integer_multiplicative2 : multiplicative2 > {}; -template +template > struct integer_multiplicative1 : multiplicative1 > {}; -template +template > struct arithmetic2 : additive2 > {}; -template +template > struct arithmetic1 : additive1 > {}; -template +template > struct integer_arithmetic2 : additive2 > {}; -template +template > struct integer_arithmetic1 : additive1 > {}; -template +template > struct bitwise2 : xorable2 > > {}; -template +template > struct bitwise1 : xorable1 > > {}; -template +template > struct unit_steppable : incrementable > {}; -template +template > struct shiftable2 : left_shiftable2 > {}; -template +template > struct shiftable1 : left_shiftable1 > {}; -template +template > struct ring_operators2 : additive2 > > {}; -template +template > struct ring_operators1 : additive1 > {}; -template +template > struct ordered_ring_operators2 : ring_operators2 > {}; -template +template > struct ordered_ring_operators1 : ring_operators1 > {}; -template +template > struct field_operators2 : ring_operators2 > > {}; -template +template > struct field_operators1 : ring_operators1 > {}; -template +template > struct ordered_field_operators2 : field_operators2 > {}; -template +template > struct ordered_field_operators1 : field_operators1 > {}; -template +template > struct euclidian_ring_operators2 : ring_operators2 > > > > {}; -template +template > struct euclidian_ring_operators1 : ring_operators1 > > {}; -template +template > struct ordered_euclidian_ring_operators2 : totally_ordered2 > {}; -template +template > struct ordered_euclidian_ring_operators1 : totally_ordered1 > {}; -template +template > struct input_iteratable : equality_comparable1 > > {}; -template +template > struct output_iteratable : incrementable {}; -template +template > struct forward_iteratable : input_iteratable {}; -template +template > struct bidirectional_iteratable : forward_iteratable +template > struct random_access_iteratable : bidirectional_iteratable \ +# define BOOST_IMPORT_TEMPLATE4(template_name) \ + template > \ struct template_name : ::template_name {}; -# define BOOST_IMPORT_TEMPLATE3(template_name) \ - template \ +# define BOOST_IMPORT_TEMPLATE3(template_name) \ + template > \ struct template_name : ::template_name {}; -# define BOOST_IMPORT_TEMPLATE2(template_name) \ - template \ +# define BOOST_IMPORT_TEMPLATE2(template_name) \ + template > \ struct template_name : ::template_name {}; -# define BOOST_IMPORT_TEMPLATE1(template_name) \ - template \ +# define BOOST_IMPORT_TEMPLATE1(template_name) \ + template > \ struct template_name : ::template_name {}; # endif // BOOST_NO_USING_TEMPLATE @@ -752,7 +754,7 @@ template struct is_chained_base { # define BOOST_OPERATOR_TEMPLATE(template_name) \ template \ ,class O = typename is_chained_base::value \ > \ struct template_name : template_name##2 {}; \ @@ -788,7 +790,7 @@ BOOST_OPERATOR_TEMPLATE1(template_name##1) // In this case we can only assume that template_name<> is equivalent to the // more commonly needed template_name1<> form. # define BOOST_OPERATOR_TEMPLATE(template_name) \ - template \ + template > \ struct template_name : template_name##1 {}; #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION From 66ca84a45d626e071010426802882fac0fb589a2 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 18 Jun 2007 12:48:37 +0000 Subject: [PATCH 017/164] Update result_of information [SVN r38024] --- utility.htm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utility.htm b/utility.htm index 8d8d80f..6ab584e 100644 --- a/utility.htm +++ b/utility.htm @@ -163,9 +163,9 @@ void f() { N > 0 or void when N = 0. For additional information about result_of, see the - current draft of the C++ Library TR, N1647, - or the result_of N1836, + or, for motivation and design rationale, the result_of proposal.

    Class template result_of resides in From c950825ef44370e243991db95f8dbf42053be4c4 Mon Sep 17 00:00:00 2001 From: Tobias Schwinger Date: Tue, 26 Jun 2007 23:07:25 +0000 Subject: [PATCH 018/164] - overloads apply for array construction - adds support for zero arguments - lets apply return the result of the new-expression - revises the preprocessing code [SVN r38101] --- .../detail/in_place_factory_prefix.hpp | 19 ++-- .../detail/in_place_factory_suffix.hpp | 8 +- include/boost/utility/in_place_factory.hpp | 96 ++++++++++++------- .../boost/utility/typed_in_place_factory.hpp | 84 +++++++++------- 4 files changed, 130 insertions(+), 77 deletions(-) diff --git a/include/boost/utility/detail/in_place_factory_prefix.hpp b/include/boost/utility/detail/in_place_factory_prefix.hpp index 092083e..6ce7247 100644 --- a/include/boost/utility/detail/in_place_factory_prefix.hpp +++ b/include/boost/utility/detail/in_place_factory_prefix.hpp @@ -1,4 +1,5 @@ // Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// Copyright (C) 2007, Tobias Schwinger. // // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -9,25 +10,27 @@ // You are welcome to contact the author at: // fernando_cacciola@hotmail.com // -#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP -#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP +#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP +#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP +#include +#include #include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include +#include #define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT(z,n,_) BOOST_PP_CAT(m_a,n) BOOST_PP_LPAREN() BOOST_PP_CAT(a,n) BOOST_PP_RPAREN() #define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL(z,n,_) BOOST_PP_CAT(A,n) const& BOOST_PP_CAT(m_a,n); -#define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_ARG(z,n,_) BOOST_PP_CAT(m_a,n) #define BOOST_MAX_INPLACE_FACTORY_ARITY 10 -#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP +#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP #endif diff --git a/include/boost/utility/detail/in_place_factory_suffix.hpp b/include/boost/utility/detail/in_place_factory_suffix.hpp index 3efe221..b1fc4d3 100644 --- a/include/boost/utility/detail/in_place_factory_suffix.hpp +++ b/include/boost/utility/detail/in_place_factory_suffix.hpp @@ -1,4 +1,5 @@ // Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// Copyright (C) 2007, Tobias Schwinger. // // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -9,15 +10,14 @@ // You are welcome to contact the author at: // fernando_cacciola@hotmail.com // -#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP -#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP +#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP +#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP #undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT #undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL -#undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_ARG #undef BOOST_MAX_INPLACE_FACTORY_ARITY -#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP +#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP #endif diff --git a/include/boost/utility/in_place_factory.hpp b/include/boost/utility/in_place_factory.hpp index 612c9a3..16eaacf 100644 --- a/include/boost/utility/in_place_factory.hpp +++ b/include/boost/utility/in_place_factory.hpp @@ -1,4 +1,5 @@ // Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// Copyright (C) 2007, Tobias Schwinger. // // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -9,50 +10,79 @@ // You are welcome to contact the author at: // fernando_cacciola@hotmail.com // -#ifndef BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP -#define BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP +#ifndef BOOST_UTILITY_INPLACE_FACTORY_04APR2007_HPP +#ifndef BOOST_PP_IS_ITERATING #include -#include - namespace boost { class in_place_factory_base {} ; -#define BOOST_DEFINE_INPLACE_FACTORY_CLASS(z,n,_) \ -template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \ -class BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) : public in_place_factory_base \ -{ \ -public: \ -\ - BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A,const& a) ) \ - : \ - BOOST_PP_ENUM( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _ ) \ - {} \ -\ - template \ - void apply ( void* address BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T) ) const \ - { \ - new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \ - } \ -\ - BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \ -} ; \ -\ -template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \ -BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \ -in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \ -{ \ - return BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \ - ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \ -} ; \ - -BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() ) +#define BOOST_PP_ITERATION_LIMITS (0, BOOST_MAX_INPLACE_FACTORY_ARITY) +#define BOOST_PP_FILENAME_1 +#include BOOST_PP_ITERATE() } // namespace boost #include +#define BOOST_UTILITY_INPLACE_FACTORY_04APR2007_HPP +#else +#define N BOOST_PP_ITERATION() + +#if N +template< BOOST_PP_ENUM_PARAMS(N, class A) > +#endif +class BOOST_PP_CAT(in_place_factory,N) + : + public in_place_factory_base +{ +public: + + explicit BOOST_PP_CAT(in_place_factory,N) + ( BOOST_PP_ENUM_BINARY_PARAMS(N,A,const& a) ) +#if N > 0 + : BOOST_PP_ENUM(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _) +#endif + {} + + template + void* apply(void* address + BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const + { + return new(address) T( BOOST_PP_ENUM_PARAMS(N, m_a) ); + } + + template + void* apply(void* address, std::size_t n + BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const + { + for(char* next = address = this->BOOST_NESTED_TEMPLATE apply(address); + !! --n;) + this->BOOST_NESTED_TEMPLATE apply(next = next+sizeof(T)); + return address; + } + + BOOST_PP_REPEAT(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) +}; + +#if N > 0 +template< BOOST_PP_ENUM_PARAMS(N, class A) > +inline BOOST_PP_CAT(in_place_factory,N)< BOOST_PP_ENUM_PARAMS(N, A) > +in_place( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) ) +{ + return BOOST_PP_CAT(in_place_factory,N)< BOOST_PP_ENUM_PARAMS(N, A) > + ( BOOST_PP_ENUM_PARAMS(N, a) ); +} +#else +inline in_place_factory0 in_place() +{ + return in_place_factory0(); +} +#endif + +#undef N +#endif #endif diff --git a/include/boost/utility/typed_in_place_factory.hpp b/include/boost/utility/typed_in_place_factory.hpp index e19fb75..f5de755 100644 --- a/include/boost/utility/typed_in_place_factory.hpp +++ b/include/boost/utility/typed_in_place_factory.hpp @@ -1,4 +1,5 @@ // Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// Copyright (C) 2007, Tobias Schwinger. // // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -9,8 +10,8 @@ // You are welcome to contact the author at: // fernando_cacciola@hotmail.com // -#ifndef BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP -#define BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP +#ifndef BOOST_UTILITY_TYPED_INPLACE_FACTORY_04APR2007_HPP +#ifndef BOOST_PP_IS_ITERATING #include @@ -18,40 +19,59 @@ namespace boost { class typed_in_place_factory_base {} ; -#define BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS(z,n,_) \ -template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \ -class BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) : public typed_in_place_factory_base \ -{ \ -public: \ -\ - typedef T value_type ; \ -\ - BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A,const& a) ) \ - : \ - BOOST_PP_ENUM( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _ ) \ - {} \ -\ - void apply ( void* address ) const \ - { \ - new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \ - } \ -\ - BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \ -} ; \ -\ -template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \ -BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T , BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \ -in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \ -{ \ - return BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T, BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \ - ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \ -} ; \ - -BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() ) +#define BOOST_PP_ITERATION_LIMITS (0, BOOST_MAX_INPLACE_FACTORY_ARITY) +#define BOOST_PP_FILENAME_1 +#include BOOST_PP_ITERATE() } // namespace boost #include +#define BOOST_UTILITY_TYPED_INPLACE_FACTORY_04APR2007_HPP +#else +#define N BOOST_PP_ITERATION() + +template< class T BOOST_PP_ENUM_TRAILING_PARAMS(N,class A) > +class BOOST_PP_CAT(typed_in_place_factory,N) + : + public typed_in_place_factory_base +{ +public: + + typedef T value_type; + + explicit BOOST_PP_CAT(typed_in_place_factory,N) + ( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) ) +#if N > 0 + : BOOST_PP_ENUM(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _) +#endif + {} + + void* apply (void* address) const + { + return new(address) T( BOOST_PP_ENUM_PARAMS(N, m_a) ); + } + + void* apply (void* address, std::size_t n) const + { + for(char* next = address = this->apply(address); !! --n;) + this->apply(next = next+sizeof(T)); + return address; + } + + BOOST_PP_REPEAT(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) +}; + +template< class T BOOST_PP_ENUM_TRAILING_PARAMS(N, class A) > +inline BOOST_PP_CAT(typed_in_place_factory,N)< + T BOOST_PP_ENUM_TRAILING_PARAMS(N, A) > +in_place( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) ) +{ + return BOOST_PP_CAT(typed_in_place_factory,N)< + T BOOST_PP_ENUM_TRAILING_PARAMS(N, A) >( BOOST_PP_ENUM_PARAMS(N, a) ); +} + +#undef N +#endif #endif From 71cb8cb574934944ad036d163e1ade3d9e33ab38 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 8 Aug 2007 18:05:24 +0000 Subject: [PATCH 019/164] broken msvc name look-up getting confused about which detail namespace [SVN r38511] --- include/boost/utility/detail/result_of_iterate.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index fa0ab89..41616c3 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -21,7 +21,7 @@ template struct result_of - : detail::result_of_impl::value)> {}; + : boost::detail::result_of_impl::value)> {}; #endif #undef BOOST_RESULT_OF_ARGS From 3f72b1018292ef4b8003f8811a1189e040773c60 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 8 Aug 2007 19:02:26 +0000 Subject: [PATCH 020/164] Remove V1 Jamfiles [SVN r38516] --- enable_if/test/Jamfile | 33 -------------------------------- test/Jamfile | 43 ------------------------------------------ 2 files changed, 76 deletions(-) delete mode 100644 enable_if/test/Jamfile delete mode 100755 test/Jamfile diff --git a/enable_if/test/Jamfile b/enable_if/test/Jamfile deleted file mode 100644 index f2e5ee3..0000000 --- a/enable_if/test/Jamfile +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright David Abrahams 2003. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -# For more information, see http://www.boost.org/ - -subproject libs/utility/enable_if/test ; - -# bring in rules for testing -import testing ; - -# Make tests run by default. -DEPENDS all : test ; - -{ - local test_monitor = @boost/libs/test/build/boost_test_exec_monitor ; - - # look in BOOST_ROOT for sources first, just in this Jamfile - local SEARCH_SOURCE = $(BOOST_ROOT) $(SEARCH_SOURCE) ; - - test-suite utility/enable_if - : - [ run libs/utility/enable_if/test/constructors.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/dummy_arg_disambiguation.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/lazy.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/lazy_test.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/member_templates.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/namespace_disambiguation.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/no_disambiguation.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/partial_specializations.cpp $(test_monitor) ] - ; -} diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100755 index 89d77d0..0000000 --- a/test/Jamfile +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright David Abrahams 2003. Permission to copy, use, -# modify, sell and distribute this software is granted provided this -# copyright notice appears in all copies. This software is provided -# "as is" without express or implied warranty, and with no claim as -# to its suitability for any purpose. - -# For more information, see http://www.boost.org/ - -subproject libs/utility/test ; - -# bring in rules for testing -import testing ; - -# Make tests run by default. -DEPENDS all : test ; - -local test_monitor = @boost/libs/test/build/boost_test_exec_monitor ; - -# Please keep the tests ordered by filename -test-suite utility - : - [ run ../addressof_test.cpp ] - [ run ../assert_test.cpp ] - [ run ../base_from_member_test.cpp ] - [ run ../binary_search_test.cpp ] - [ run ../call_traits_test.cpp : -u ] - [ compile-fail ../checked_delete_test.cpp ] - [ run ../compressed_pair_test.cpp $(test_monitor) : -u ] - [ run ../current_function_test.cpp : : : always_show_run_output ] - [ run ../iterators_test.cpp $(test_monitor) ] - [ run next_prior_test.cpp $(test_monitor) ] - [ compile-fail ../noncopyable_test.cpp ] - [ run ../numeric_traits_test.cpp ] - [ run ../operators_test.cpp $(test_monitor) ] - [ compile ../ref_ct_test.cpp ] - [ run ../ref_test.cpp $(test_monitor) ] - [ compile result_of_test.cpp ] - [ run ../shared_iterator_test.cpp ] - [ run ../value_init_test.cpp ] - [ compile-fail ../value_init_test_fail1.cpp ] - [ compile-fail ../value_init_test_fail2.cpp ] - [ compile-fail ../value_init_test_fail3.cpp ] - ; From 55f3c351a388a1bc2c38cb06d4e6a324faaaa66e Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Fri, 7 Sep 2007 17:17:09 +0000 Subject: [PATCH 021/164] Added MSVC workaround to value_initialized, as described by ticket #1217, proposed at the Boost Developers mailing list, and discussed with Fernando Cacciola. [SVN r39157] --- include/boost/utility/value_init.hpp | 84 ++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 4 deletions(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index 65600e5..a564658 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -1,10 +1,11 @@ -// (C) 2002, Fernando Luis Cacciola Carballal. +// (C) Copyright 2002-2007, Fernando Luis Cacciola Carballal. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // 21 Ago 2002 (Created) Fernando Cacciola +// 07 Set 2007 (Worked around MSVC++ bug) Fernando Cacciola, Niels Dekker // #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP @@ -13,6 +14,75 @@ #include #include +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) ) +// Microsoft Visual C++ does not correctly support value initialization, as reported by +// Pavel Kuznetsov (MetaCommunications Engineering), 7/28/2005, Feedback ID 100744, +// Feedback Title: Value-initialization in new-expression +// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744 +// The report was closed at 11/14/2006, and its status was set to "Closed (Won't Fix)". +// Luckily, even in the presence of this compiler bug, boost::value_initialized will still +// do its job correctly, when using the following workaround: +#define BOOST_UTILITY_VALUE_INIT_WORKAROUND +#endif + +#ifdef BOOST_UTILITY_VALUE_INIT_WORKAROUND +#include +#include +#include +#include + +namespace boost { + +namespace vinit_detail { + +template +class const_T_base +{ + protected : + + const_T_base() + { + std::memset(&x, 0, sizeof(x)); + new (&x) T(); + } + + ~const_T_base() { get().T::~T(); } + + T & get() const + { + void const * ptr = &x; + return *static_cast(ptr); + } + + private : + typename ::boost::aligned_storage::value>::type x; +} ; + +template +class non_const_T_base +{ + protected : + + non_const_T_base() + { + std::memset(&x, 0, sizeof(x)); + new (&x) T(); + } + + ~non_const_T_base() { get().T::~T(); } + + T & get() const + { + void * ptr = &x; + return *static_cast(ptr); + } + + private : + mutable typename ::boost::aligned_storage::value>::type x; +} ; + +#else + namespace boost { namespace vinit_detail { @@ -23,20 +93,26 @@ class const_T_base protected : const_T_base() : x() {} + T & get() const { return x; } + private : T x ; } ; template -struct non_const_T_base +class non_const_T_base { protected : non_const_T_base() : x() {} + T & get() const { return x; } + private : mutable T x ; } ; +#endif + template struct select_base { @@ -57,9 +133,9 @@ class value_initialized : private vinit_detail::select_base::type value_initialized() {} - operator T&() const { return this->x ; } + operator T&() const { return this->get(); } - T& data() const { return this->x ; } + T& data() const { return this->get(); } } ; From 01e91a37990b8ca93fa83b0a42f80e69fc9e0d90 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 15 Sep 2007 23:11:50 +0000 Subject: [PATCH 022/164] work around Visual C++ 7.1 internal compiler error [SVN r39302] --- include/boost/utility/value_init.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index a564658..adac8bc 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -69,7 +69,11 @@ class non_const_T_base new (&x) T(); } - ~non_const_T_base() { get().T::~T(); } + ~non_const_T_base() + { + void * ptr = &x; + static_cast(ptr)->T::~T(); + } T & get() const { From 3bb2568fad345116afccbf23aaaf6c556e77c121 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 16 Sep 2007 09:33:34 +0000 Subject: [PATCH 023/164] Visual C++ 7.1 ICE workaround by Ralf W. Grosse-Kunstleve added to ~const_T_base() as well. See also Boost Developers mailing list, subject "utility/value_init.hpp: VC 7.1 ICE & workaround" [SVN r39308] --- include/boost/utility/value_init.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index adac8bc..4cd8e1b 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -46,7 +46,11 @@ class const_T_base new (&x) T(); } - ~const_T_base() { get().T::~T(); } + ~const_T_base() + { + void const * ptr = &x; + static_cast(ptr)->T::~T(); + } T & get() const { From 8f03aeac4ebeebef3cb53a75be6b0d6f15dba2c2 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 16 Sep 2007 09:48:28 +0000 Subject: [PATCH 024/164] Added unit test to make sure that Visual C++ 7.1 ICE reported by Ralf W. Grosse-Kunstleve (Boost Developers mailing list, subject "utility/value_init.hpp: VC 7.1 ICE & workaround") will not occur anymore. [SVN r39309] --- value_init_test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/value_init_test.cpp b/value_init_test.cpp index fe73cc1..08f9b87 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -95,6 +95,9 @@ int test_main(int, char **) test( POD(0,0,0.0), POD('a',1234,56.78) ) ; test( NonPOD( std::string() ), NonPOD( std::string("something") ) ) ; + NonPOD NonPOD_object( std::string("NonPOD_object") ); + test( 0, &NonPOD_object ) ; + return 0; } From bddd52c4b91dc2fb86083bfc4730d993a12d8c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Sch=C3=B6pflin?= Date: Thu, 11 Oct 2007 07:36:41 +0000 Subject: [PATCH 025/164] Fixed bug preventing compilation on Tru64/CXX. [SVN r39918] --- include/boost/utility/typed_in_place_factory.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/utility/typed_in_place_factory.hpp b/include/boost/utility/typed_in_place_factory.hpp index f5de755..347b7f4 100644 --- a/include/boost/utility/typed_in_place_factory.hpp +++ b/include/boost/utility/typed_in_place_factory.hpp @@ -54,8 +54,8 @@ public: void* apply (void* address, std::size_t n) const { - for(char* next = address = this->apply(address); !! --n;) - this->apply(next = next+sizeof(T)); + for(void* next = address = this->apply(address); !! --n;) + this->apply(next = static_cast(next) + sizeof(T)); return address; } From cd8f85afee1792f2051164a6ca3b98c0a06632f3 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Tue, 16 Oct 2007 17:00:28 +0000 Subject: [PATCH 026/164] Disabled MSVC warning C4345, in response to Gennadiy Rozental, Boost Developer mailing list, "[utility] value_init warning", October 14, 2007. Push'n'pop reminder from Paul A Bristow taken into account. [SVN r40088] --- include/boost/utility/value_init.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index 4cd8e1b..b6d1246 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -31,6 +31,16 @@ #include #include +#ifdef BOOST_MSVC +#pragma warning(push) +#if _MSC_VER >= 1310 +// When using MSVC 7.1 or higher, placement new, "new (&x) T()", may trigger warning C4345: +// "behavior change: an object of POD type constructed with an initializer of the form () +// will be default-initialized". There is no need to worry about this, though. +#pragma warning(disable: 4345) +#endif +#endif + namespace boost { namespace vinit_detail { @@ -89,6 +99,11 @@ class non_const_T_base mutable typename ::boost::aligned_storage::value>::type x; } ; +#ifdef BOOST_MSVC +// Restores the state of warning C4345. +#pragma warning(pop) +#endif + #else namespace boost { From 42e0001370418c45c250bebb4f8c44623b25da47 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Tue, 16 Oct 2007 17:06:39 +0000 Subject: [PATCH 027/164] Added value_initialized test, having T as aggregate POD struct. In the past, this would have triggered MSVC warning C4345; this warning is now disabled within value_init.hpp, changeset [40088] [SVN r40089] --- value_init_test.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/value_init_test.cpp b/value_init_test.cpp index 08f9b87..6bca270 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -60,6 +60,20 @@ struct NonPOD : NonPODBase std::string id ; } ; +// +// Sample aggregate POD struct type +// +struct AggregatePODStruct +{ + float f; + char c; + int i; +}; + +bool operator == ( AggregatePODStruct const& lhs, AggregatePODStruct const& rhs ) +{ return lhs.f == rhs.f && lhs.c == rhs.c && lhs.i == rhs.i ; } + + template void test ( T const& y, T const& z ) { @@ -98,6 +112,10 @@ int test_main(int, char **) NonPOD NonPOD_object( std::string("NonPOD_object") ); test( 0, &NonPOD_object ) ; + AggregatePODStruct zeroInitializedAggregatePODStruct = { 0.0f, '\0', 0 }; + AggregatePODStruct nonZeroInitializedAggregatePODStruct = { 1.25f, 'a', -1 }; + test(zeroInitializedAggregatePODStruct, nonZeroInitializedAggregatePODStruct); + return 0; } From 56b0846099e8e0ac07441df34d01be994a1d66bd Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 3 Nov 2007 20:55:22 +0000 Subject: [PATCH 028/164] BOOST_VERIFY added. [SVN r40728] --- assert.html | 10 +++- include/boost/assert.hpp | 13 ++++ test/Jamfile.v2 | 1 + verify_test.cpp | 126 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 verify_test.cpp diff --git a/assert.html b/assert.html index 4381ae1..e65e791 100644 --- a/assert.html +++ b/assert.html @@ -47,9 +47,13 @@ void assertion_failed(char const * expr, char const * function, char const * fil

    As is the case with <cassert>, <boost/assert.hpp> can be included multiple times in a single translation unit. BOOST_ASSERT will be redefined each time as specified above.

    +

    <boost/assert.hpp> also defines the macro BOOST_VERIFY. + It has exactly the same behavior as BOOST_ASSERT, except + that the expression that is passed to BOOST_VERIFY is always + evaluated.


    - Copyright © 2002 by Peter Dimov. Distributed under the Boost Software License, Version - 1.0. See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt.

    + Copyright © 2002, 2007 by Peter Dimov. Distributed under the Boost + Software License, Version 1.0. See accompanying file + LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.

    diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index 5619f29..c227f17 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -2,6 +2,7 @@ // boost/assert.hpp - BOOST_ASSERT(expr) // // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. +// Copyright (c) 2007 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -35,3 +36,15 @@ void assertion_failed(char const * expr, char const * function, char const * fil # include // .h to support old libraries w/o - effect is the same # define BOOST_ASSERT(expr) assert(expr) #endif + +#undef BOOST_VERIFY + +#if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) ) + +# define BOOST_VERIFY(expr) ((void)(expr)) + +#else + +# define BOOST_VERIFY(expr) BOOST_ASSERT(expr) + +#endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d5ecaa0..0e8ba8f 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -33,4 +33,5 @@ test-suite utility [ compile-fail ../value_init_test_fail1.cpp ] [ compile-fail ../value_init_test_fail2.cpp ] [ compile-fail ../value_init_test_fail3.cpp ] + [ run verify_test.cpp ] ; diff --git a/verify_test.cpp b/verify_test.cpp new file mode 100644 index 0000000..3481636 --- /dev/null +++ b/verify_test.cpp @@ -0,0 +1,126 @@ +// +// verify_test.cpp - a test for BOOST_VERIFY +// +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// Copyright (c) 2007 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#include + +#include + +int f( int & x ) +{ + return ++x; +} + +void test_default() +{ + int x = 1; + + BOOST_VERIFY( 1 ); + BOOST_VERIFY( x == 1 ); + BOOST_VERIFY( ++x ); + BOOST_VERIFY( f(x) ); + BOOST_VERIFY( &x ); + + BOOST_TEST( x == 3 ); +} + +#define BOOST_DISABLE_ASSERTS +#include + +void test_disabled() +{ + int x = 1; + + BOOST_VERIFY( 1 ); + BOOST_VERIFY( x == 1 ); + BOOST_VERIFY( ++x ); + BOOST_VERIFY( f(x) ); + BOOST_VERIFY( &x ); + + BOOST_TEST( x == 3 ); + + BOOST_VERIFY( 0 ); + BOOST_VERIFY( !x ); + BOOST_VERIFY( x == 0 ); + BOOST_VERIFY( !++x ); + BOOST_VERIFY( !f(x) ); + + BOOST_TEST( x == 5 ); + + void * p = 0; + BOOST_VERIFY( p ); +} + +#undef BOOST_DISABLE_ASSERTS + +#define BOOST_ENABLE_ASSERT_HANDLER +#include +#include +#include + +int handler_invoked = 0; + +void boost::assertion_failed(char const * expr, char const * function, char const * file, long line) +{ +#if !defined(BOOST_NO_STDC_NAMESPACE) + using std::printf; +#endif + + printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, function, file, line); + ++handler_invoked; +} + +struct X +{ + static bool f() + { + BOOST_VERIFY( 0 ); + return false; + } +}; + +void test_handler() +{ + int x = 1; + + BOOST_VERIFY( 1 ); + BOOST_VERIFY( x == 1 ); + BOOST_VERIFY( ++x ); + BOOST_VERIFY( f(x) ); + BOOST_VERIFY( &x ); + + BOOST_TEST( x == 3 ); + + BOOST_VERIFY( 0 ); + BOOST_VERIFY( !x ); + BOOST_VERIFY( x == 0 ); + BOOST_VERIFY( !++x ); + BOOST_VERIFY( !f(x) ); + + BOOST_TEST( x == 5 ); + + void * p = 0; + BOOST_VERIFY( p ); + + BOOST_VERIFY( X::f() ); + + BOOST_TEST( handler_invoked == 8 ); +} + +#undef BOOST_ENABLE_ASSERT_HANDLER + +int main() +{ + test_default(); + test_disabled(); + test_handler(); + + return boost::report_errors(); +} From ea8c99b1d53dfec647819f809a8b0679d8a9b20e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 3 Nov 2007 22:47:17 +0000 Subject: [PATCH 029/164] Added a sentence with a brief explanation of the intended uses of BOOST_VERIFY. [SVN r40731] --- assert.html | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/assert.html b/assert.html index e65e791..a970cef 100644 --- a/assert.html +++ b/assert.html @@ -47,13 +47,15 @@ void assertion_failed(char const * expr, char const * function, char const * fil

    As is the case with <cassert>, <boost/assert.hpp> can be included multiple times in a single translation unit. BOOST_ASSERT will be redefined each time as specified above.

    -

    <boost/assert.hpp> also defines the macro BOOST_VERIFY. - It has exactly the same behavior as BOOST_ASSERT, except - that the expression that is passed to BOOST_VERIFY is always - evaluated.

    +

    <boost/assert.hpp> also defines the macro BOOST_VERIFY. + It has exactly the same behavior as BOOST_ASSERT, except that + the expression that is passed to BOOST_VERIFY is always + evaluated. This is useful when the asserted expression has desirable side + effects; it can also help suppress warnings about unused variables when the + only use of the variable is inside an assertion.


    - Copyright © 2002, 2007 by Peter Dimov. Distributed under the Boost - Software License, Version 1.0. See accompanying file - LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.

    + Copyright © 2002, 2007 by Peter Dimov. Distributed under the Boost Software + License, Version 1.0. See accompanying file LICENSE_1_0.txt + or copy at http://www.boost.org/LICENSE_1_0.txt.

    From 7ddb5598874814fb23e5e57a0429a9620e224f68 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 4 Nov 2007 12:01:16 +0000 Subject: [PATCH 030/164] Fix path to test case. [SVN r40736] --- test/Jamfile.v2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 0e8ba8f..f30154c 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -33,5 +33,6 @@ test-suite utility [ compile-fail ../value_init_test_fail1.cpp ] [ compile-fail ../value_init_test_fail2.cpp ] [ compile-fail ../value_init_test_fail3.cpp ] - [ run verify_test.cpp ] + [ run ../verify_test.cpp ] ; + From b3a971e7e906335308bb03cf05e983cabdf430c8 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Wed, 7 Nov 2007 16:08:09 +0000 Subject: [PATCH 031/164] Copyright and/or License cleanup [SVN r40890] --- OptionalPointee.html | 10 ++++++++-- compressed_pair.htm | 19 ++++++++++--------- test/Jamfile.v2 | 9 ++++----- utility.htm | 12 ++++++------ value_init.htm | 20 ++++++++++---------- value_init_test.cpp | 2 +- value_init_test_fail1.cpp | 2 +- value_init_test_fail2.cpp | 2 +- value_init_test_fail3.cpp | 2 +- 9 files changed, 42 insertions(+), 36 deletions(-) diff --git a/OptionalPointee.html b/OptionalPointee.html index a6d6d97..462d6f3 100644 --- a/OptionalPointee.html +++ b/OptionalPointee.html @@ -145,14 +145,20 @@ objects are is implemented in +

    Acknowledgements

    +

    Based on the original concept developed by Augustus Saunders. +
    +


    Copyright © 2003 -Fernando Cacciola, -based on the original concept developed by Augustus Saunders. +Fernando Cacciola
    +

    Distributed under the Boost Software License, Version 1.0. See +www.boost.org/LICENSE_1_0.txt

    + \ No newline at end of file diff --git a/compressed_pair.htm b/compressed_pair.htm index 4662fc5..f054d08 100644 --- a/compressed_pair.htm +++ b/compressed_pair.htm @@ -3,7 +3,7 @@ Header - + @@ -59,17 +59,18 @@ public: empty type, then assigning to that member will produce memory corruption, unless the empty type has a "do nothing" assignment operator defined. This is due to a bug in the way VC6 generates implicit assignment operators.

    -
    -

    Revised 08 May 2001

    -

    © Copyright boost.org 2000. Permission to copy, use, modify, sell and - distribute this document is granted provided this copyright notice appears in - all copies. This document is provided "as is" without express or implied - warranty, and with no claim as to its suitability for any purpose.

    +

    Acknowledgements

    Based on contributions by Steve Cleary, Beman Dawes, Howard Hinnant and John Maddock.

    Maintained by John Maddock, the latest version of this file can be found at www.boost.org, and the boost discussion list at www.yahoogroups.com/list/boost.

    -

     

    +
    +

    Revised + 07 November 2007

    +

    © Copyright Beman Dawes, 2000.

    +

    Distributed under the Boost Software License, Version 1.0. See +www.boost.org/LICENSE_1_0.txt

    + - + \ No newline at end of file diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f30154c..56c84a4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -1,8 +1,7 @@ -# Copyright David Abrahams 2003. Permission to copy, use, -# modify, sell and distribute this software is granted provided this -# copyright notice appears in all copies. This software is provided -# "as is" without express or implied warranty, and with no claim as -# to its suitability for any purpose. +# Copyright David Abrahams 2003. + +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt # For more information, see http://www.boost.org/ diff --git a/utility.htm b/utility.htm index 6ab584e..937a8a3 100644 --- a/utility.htm +++ b/utility.htm @@ -183,12 +183,12 @@ void f() {

    See separate documentation.


    Revised  02 May, 200407 November, 2007

    -

    © Copyright boost.org 1999-2003. Permission to copy, use, modify, sell and distribute - this document is granted provided this copyright notice appears in all copies. - This document is provided "as is" without express or implied - warranty, and with no claim as to its suitability for any purpose.

    +

    © Copyright Beman Dawes 1999-2003.

    +

    Distributed under the Boost Software License, Version 1.0. See +www.boost.org/LICENSE_1_0.txt

    + - + \ No newline at end of file diff --git a/value_init.htm b/value_init.htm index d8c28e3..8ceba8b 100644 --- a/value_init.htm +++ b/value_init.htm @@ -197,23 +197,23 @@ the wrapped object is always performed with the get() idiom:

    value_initialized was developed by Fernando Cacciola, with help and suggestions from David Abrahams and Darin Adler.
    Special thanks to Björn Karlsson who carefully edited and completed this documentation. -
     
    - -
    -

    Revised 19 September 2002

    - -

    © Copyright boost.org 2002. Permission to copy, use, modify, sell -and distribute this document is granted provided this copyright notice appears -in all copies. This document is provided "as is" without express or implied -warranty, and with no claim as to its suitability for any purpose.

    Developed by Fernando Cacciola, the latest version of this file can be found at www.boost.org, and the boost discussion list at www.yahoogroups.com/list/boost.

    + +
    +

    Revised 19 September 2002

    + +

    © Copyright Fernando Cacciola, 2002.

    + +

    Distributed under the Boost Software License, Version 1.0. See +www.boost.org/LICENSE_1_0.txt

    +

    - + \ No newline at end of file diff --git a/value_init_test.cpp b/value_init_test.cpp index 6bca270..e3df4dd 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -1,4 +1,4 @@ -// (C) 2002, Fernando Luis Cacciola Carballal. +// Copyright 2002, Fernando Luis Cacciola Carballal. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at diff --git a/value_init_test_fail1.cpp b/value_init_test_fail1.cpp index 8904732..e3f6f1a 100644 --- a/value_init_test_fail1.cpp +++ b/value_init_test_fail1.cpp @@ -1,4 +1,4 @@ -// (C) 2002, Fernando Luis Cacciola Carballal. +// Copyright 2002, Fernando Luis Cacciola Carballal. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at diff --git a/value_init_test_fail2.cpp b/value_init_test_fail2.cpp index 1f40061..bbc7c90 100644 --- a/value_init_test_fail2.cpp +++ b/value_init_test_fail2.cpp @@ -1,4 +1,4 @@ -// (C) 2002, Fernando Luis Cacciola Carballal. +// Copyright 2002, Fernando Luis Cacciola Carballal. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at diff --git a/value_init_test_fail3.cpp b/value_init_test_fail3.cpp index 72fd761..9bea5ba 100644 --- a/value_init_test_fail3.cpp +++ b/value_init_test_fail3.cpp @@ -1,4 +1,4 @@ -// (C) 2002, Fernando Luis Cacciola Carballal. +// Copyright 2002, Fernando Luis Cacciola Carballal. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at From ec46e40809478ddaf55775595f95be7677be179d Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 18 Nov 2007 22:11:57 +0000 Subject: [PATCH 032/164] Code refactoring: removed private base classes of value_initialized, as suggested by Fernando Cacciola. [SVN r41216] --- include/boost/utility/value_init.hpp | 139 ++++++++------------------- 1 file changed, 41 insertions(+), 98 deletions(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index b6d1246..c4cd3e1 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -6,6 +6,7 @@ // // 21 Ago 2002 (Created) Fernando Cacciola // 07 Set 2007 (Worked around MSVC++ bug) Fernando Cacciola, Niels Dekker +// 16 Nov 2007 (Refactoring: removed private base classes) Fernando Cacciola, Niels Dekker // #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP @@ -14,7 +15,6 @@ #include #include -#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) ) // Microsoft Visual C++ does not correctly support value initialization, as reported by // Pavel Kuznetsov (MetaCommunications Engineering), 7/28/2005, Feedback ID 100744, // Feedback Title: Value-initialization in new-expression @@ -22,10 +22,12 @@ // The report was closed at 11/14/2006, and its status was set to "Closed (Won't Fix)". // Luckily, even in the presence of this compiler bug, boost::value_initialized will still // do its job correctly, when using the following workaround: -#define BOOST_UTILITY_VALUE_INIT_WORKAROUND +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) +# define BOOST_UTILITY_VALUE_INIT_WORKAROUND #endif #ifdef BOOST_UTILITY_VALUE_INIT_WORKAROUND + #include #include #include @@ -43,60 +45,34 @@ namespace boost { -namespace vinit_detail { - template -class const_T_base +class value_initialized { - protected : - - const_T_base() - { - std::memset(&x, 0, sizeof(x)); - new (&x) T(); - } - - ~const_T_base() - { - void const * ptr = &x; - static_cast(ptr)->T::~T(); - } - - T & get() const - { - void const * ptr = &x; - return *static_cast(ptr); - } - - private : - typename ::boost::aligned_storage::value>::type x; -} ; - -template -class non_const_T_base -{ - protected : - - non_const_T_base() - { - std::memset(&x, 0, sizeof(x)); - new (&x) T(); - } - - ~non_const_T_base() - { - void * ptr = &x; - static_cast(ptr)->T::~T(); - } - - T & get() const - { - void * ptr = &x; - return *static_cast(ptr); - } - private : mutable typename ::boost::aligned_storage::value>::type x; + + public : + + value_initialized() + { + std::memset(&x, 0, sizeof(x)); + new (&x) T(); + } + + ~value_initialized() + { + void * ptr = &x; + static_cast(ptr)->T::~T(); + } + + T& data() const + { + void * ptr = &x; + return *static_cast(ptr); + } + + operator T&() const { return this->data(); } + } ; #ifdef BOOST_MSVC @@ -108,59 +84,27 @@ class non_const_T_base namespace boost { -namespace vinit_detail { - template -class const_T_base -{ - protected : - - const_T_base() : x() {} - T & get() const { return x; } - - private : - T x ; -} ; - -template -class non_const_T_base -{ - protected : - - non_const_T_base() : x() {} - T & get() const { return x; } - - private : - mutable T x ; -} ; - -#endif - -template -struct select_base -{ - typedef -#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - typename -#endif - ::boost::detail::if_true< ::boost::is_const::value > - ::template then< const_T_base, non_const_T_base >::type type ; -} ; - -} // namespace vinit_detail - -template -class value_initialized : private vinit_detail::select_base::type +class value_initialized { public : - value_initialized() {} + value_initialized() : x() {} - operator T&() const { return this->get(); } + T& data() const { return x; } - T& data() const { return this->get(); } + operator T&() const { return this->data(); } + + mutable +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + typename +#endif + ::boost::remove_const::type x ; } ; +#endif + + template T const& get ( value_initialized const& x ) @@ -177,4 +121,3 @@ T& get ( value_initialized& x ) #endif - From 09ab16bfc113596e0b52089ea52d65d50871297d Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sat, 24 Nov 2007 11:51:03 +0000 Subject: [PATCH 033/164] Checked the result of value_init test function, hoping to pinpoint exactly for what particular type T value_initialized might fail, on some platforms [SVN r41326] --- value_init_test.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/value_init_test.cpp b/value_init_test.cpp index e3df4dd..4c576a6 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -74,9 +74,15 @@ bool operator == ( AggregatePODStruct const& lhs, AggregatePODStruct const& rhs { return lhs.f == rhs.f && lhs.c == rhs.c && lhs.i == rhs.i ; } +// +// This test function tests boost::value_initialized for a specific type T. +// The first argument (y) is assumed have the value of a value-initialized object. +// Returns true on success. +// template -void test ( T const& y, T const& z ) +bool test ( T const& y, T const& z ) { + const boost::unit_test::counter_t counter_before_test = boost::minimal_test::errors_counter(); boost::value_initialized x ; BOOST_CHECK ( y == x ) ; BOOST_CHECK ( y == boost::get(x) ) ; @@ -100,21 +106,22 @@ void test ( T const& y, T const& z ) BOOST_CHECK ( y == cx_c ) ; BOOST_CHECK ( y == boost::get(cx_c) ) ; #endif + return boost::minimal_test::errors_counter() == counter_before_test ; } int test_main(int, char **) { - test( 0,1234 ) ; - test( 0.0,12.34 ) ; - test( POD(0,0,0.0), POD('a',1234,56.78) ) ; - test( NonPOD( std::string() ), NonPOD( std::string("something") ) ) ; + BOOST_CHECK ( test( 0,1234 ) ) ; + BOOST_CHECK ( test( 0.0,12.34 ) ) ; + BOOST_CHECK ( test( POD(0,0,0.0), POD('a',1234,56.78) ) ) ; + BOOST_CHECK ( test( NonPOD( std::string() ), NonPOD( std::string("something") ) ) ) ; NonPOD NonPOD_object( std::string("NonPOD_object") ); - test( 0, &NonPOD_object ) ; + BOOST_CHECK ( test( 0, &NonPOD_object ) ) ; AggregatePODStruct zeroInitializedAggregatePODStruct = { 0.0f, '\0', 0 }; AggregatePODStruct nonZeroInitializedAggregatePODStruct = { 1.25f, 'a', -1 }; - test(zeroInitializedAggregatePODStruct, nonZeroInitializedAggregatePODStruct); + BOOST_CHECK ( test(zeroInitializedAggregatePODStruct, nonZeroInitializedAggregatePODStruct) ); return 0; } From 6a2aa822f8b95bacae5e37fcbf8a37c2f51ce801 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Tue, 27 Nov 2007 21:34:08 +0000 Subject: [PATCH 034/164] Added value_init test for struct as used in MSVC bug report regarding value-initialization. [SVN r41423] --- value_init_test.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/value_init_test.cpp b/value_init_test.cpp index 4c576a6..711fe53 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -73,6 +73,22 @@ struct AggregatePODStruct bool operator == ( AggregatePODStruct const& lhs, AggregatePODStruct const& rhs ) { return lhs.f == rhs.f && lhs.c == rhs.c && lhs.i == rhs.i ; } +// +// An aggregate struct that contains an std::string and an int. +// Pavel Kuznetsov (MetaCommunications Engineering) used a struct like +// this to reproduce the Microsoft Visual C++ compiler bug, reported as +// Feedback ID 100744, "Value-initialization in new-expression" +// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744 +// +struct StringAndInt +{ + std::string s; + int i; +}; + +bool operator == ( StringAndInt const& lhs, StringAndInt const& rhs ) +{ return lhs.s == rhs.s && lhs.i == rhs.i ; } + // // This test function tests boost::value_initialized for a specific type T. @@ -123,13 +139,15 @@ int test_main(int, char **) AggregatePODStruct nonZeroInitializedAggregatePODStruct = { 1.25f, 'a', -1 }; BOOST_CHECK ( test(zeroInitializedAggregatePODStruct, nonZeroInitializedAggregatePODStruct) ); + StringAndInt stringAndInt0; + StringAndInt stringAndInt1; + stringAndInt0.i = 0; + stringAndInt1.i = 1; + stringAndInt1.s = std::string("1"); + BOOST_CHECK ( test(stringAndInt0, stringAndInt1) ); + return 0; } unsigned int expected_failures = 0; - - - - - From 33041ad664924aa16537958fe44adbd608d344c6 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 28 Nov 2007 17:19:37 +0000 Subject: [PATCH 035/164] Added tests for two more struct types to value_init_test -- discussed with Fernando Cacciola [SVN r41436] --- value_init_test.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/value_init_test.cpp b/value_init_test.cpp index 711fe53..5187a77 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -90,6 +90,42 @@ bool operator == ( StringAndInt const& lhs, StringAndInt const& rhs ) { return lhs.s == rhs.s && lhs.i == rhs.i ; } +// +// A struct that has an explicit (user defined) destructor. +// Some compilers do not correctly value-initialize such a struct, for example: +// Microsoft Visual C++, Feedback ID 100744, "Value-initialization in new-expression" +// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744 +// +struct StructWithDestructor +{ + int i; + ~StructWithDestructor() {} +}; + +bool operator == ( StructWithDestructor const& lhs, StructWithDestructor const& rhs ) +{ return lhs.i == rhs.i ; } + + +// +// A struct that has a virtual function. +// Some compilers do not correctly value-initialize such a struct either, for example: +// Microsoft Visual C++, Feedback ID 100744, "Value-initialization in new-expression" +// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744 +// +struct StructWithVirtualFunction +{ + int i; + virtual void VirtualFunction(); +}; + +void StructWithVirtualFunction::VirtualFunction() +{ +} + +bool operator == ( StructWithVirtualFunction const& lhs, StructWithVirtualFunction const& rhs ) +{ return lhs.i == rhs.i ; } + + // // This test function tests boost::value_initialized for a specific type T. // The first argument (y) is assumed have the value of a value-initialized object. @@ -146,6 +182,18 @@ int test_main(int, char **) stringAndInt1.s = std::string("1"); BOOST_CHECK ( test(stringAndInt0, stringAndInt1) ); + StructWithDestructor structWithDestructor0; + StructWithDestructor structWithDestructor1; + structWithDestructor0.i = 0; + structWithDestructor1.i = 1; + BOOST_CHECK ( test(structWithDestructor0, structWithDestructor1) ); + + StructWithVirtualFunction structWithVirtualFunction0; + StructWithVirtualFunction structWithVirtualFunction1; + structWithVirtualFunction0.i = 0; + structWithVirtualFunction1.i = 1; + BOOST_CHECK ( test(structWithVirtualFunction0, structWithVirtualFunction1) ); + return 0; } From 882d38c2c747b786fd4b73391e88d23109e22f26 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sat, 1 Dec 2007 12:14:37 +0000 Subject: [PATCH 036/164] Added value_init tests, based upon GCC bug report by Jonathan Wakely. Added URL to Borland bug report. [SVN r41529] --- value_init_test.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/value_init_test.cpp b/value_init_test.cpp index 5187a77..450993b 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -62,6 +62,9 @@ struct NonPOD : NonPODBase // // Sample aggregate POD struct type +// Some compilers do not correctly value-initialize such a struct, for example: +// Borland C++ Report #51854, "Value-initialization: POD struct should be zero-initialized " +// http://qc.codegear.com/wc/qcmain.aspx?d=51854 // struct AggregatePODStruct { @@ -126,6 +129,29 @@ bool operator == ( StructWithVirtualFunction const& lhs, StructWithVirtualFuncti { return lhs.i == rhs.i ; } +// +// A struct that is derived from an aggregate POD struct. +// Some compilers do not correctly value-initialize such a struct, for example: +// GCC Bugzilla Bug 30111, "Value-initialization of POD base class doesn't initialize members", +// reported by Jonathan Wakely, http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111 +// +struct DerivedFromAggregatePODStruct : AggregatePODStruct +{ + DerivedFromAggregatePODStruct() : AggregatePODStruct() {} +}; + +// +// A struct that wraps an aggregate POD struct as data member. +// +struct AggregatePODStructWrapper +{ + AggregatePODStructWrapper() : dataMember() {} + AggregatePODStruct dataMember; +}; + +bool operator == ( AggregatePODStructWrapper const& lhs, AggregatePODStructWrapper const& rhs ) +{ return lhs.dataMember == rhs.dataMember ; } + // // This test function tests boost::value_initialized for a specific type T. // The first argument (y) is assumed have the value of a value-initialized object. @@ -194,6 +220,18 @@ int test_main(int, char **) structWithVirtualFunction1.i = 1; BOOST_CHECK ( test(structWithVirtualFunction0, structWithVirtualFunction1) ); + DerivedFromAggregatePODStruct derivedFromAggregatePODStruct0; + DerivedFromAggregatePODStruct derivedFromAggregatePODStruct1; + static_cast(derivedFromAggregatePODStruct0) = zeroInitializedAggregatePODStruct; + static_cast(derivedFromAggregatePODStruct1) = nonZeroInitializedAggregatePODStruct; + BOOST_CHECK ( test(derivedFromAggregatePODStruct0, derivedFromAggregatePODStruct1) ); + + AggregatePODStructWrapper aggregatePODStructWrapper0; + AggregatePODStructWrapper aggregatePODStructWrapper1; + aggregatePODStructWrapper0.dataMember = zeroInitializedAggregatePODStruct; + aggregatePODStructWrapper1.dataMember = nonZeroInitializedAggregatePODStruct; + BOOST_CHECK ( test(aggregatePODStructWrapper0, aggregatePODStructWrapper1) ); + return 0; } From 7300ac83f176e178a14eabd3774c516b4aff2cf5 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Mon, 3 Dec 2007 18:14:37 +0000 Subject: [PATCH 037/164] Added value_init test for C style array of bytes [SVN r41647] --- value_init_test.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/value_init_test.cpp b/value_init_test.cpp index 450993b..e536693 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -152,6 +152,8 @@ struct AggregatePODStructWrapper bool operator == ( AggregatePODStructWrapper const& lhs, AggregatePODStructWrapper const& rhs ) { return lhs.dataMember == rhs.dataMember ; } +typedef unsigned char ArrayOfBytes[256]; + // // This test function tests boost::value_initialized for a specific type T. // The first argument (y) is assumed have the value of a value-initialized object. @@ -232,6 +234,10 @@ int test_main(int, char **) aggregatePODStructWrapper1.dataMember = nonZeroInitializedAggregatePODStruct; BOOST_CHECK ( test(aggregatePODStructWrapper0, aggregatePODStructWrapper1) ); + ArrayOfBytes zeroInitializedArrayOfBytes = { 0 }; + boost::value_initialized valueInitializedArrayOfBytes; + BOOST_CHECK (std::memcmp(get(valueInitializedArrayOfBytes), zeroInitializedArrayOfBytes, sizeof(ArrayOfBytes)) == 0); + return 0; } From e1a63495b60e349135d34764f1138b62ecc865c0 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Mon, 3 Dec 2007 18:20:19 +0000 Subject: [PATCH 038/164] Added missing #include to value_init_test.cpp. (My mistake!) [SVN r41648] --- value_init_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/value_init_test.cpp b/value_init_test.cpp index e536693..d5410cb 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -8,6 +8,7 @@ // // Initial: 21 Agu 2002 +#include // For memcmp. #include #include From a470b591fb61fcb86c66d714779bf228938963ce Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Mon, 3 Dec 2007 21:41:59 +0000 Subject: [PATCH 039/164] Added value_init test for an value_initialized object allocated on the heap. [SVN r41667] --- value_init_test.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/value_init_test.cpp b/value_init_test.cpp index d5410cb..fcbada5 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -13,6 +13,7 @@ #include #include "boost/utility/value_init.hpp" +#include #ifdef __BORLANDC__ #pragma hdrstop @@ -178,6 +179,9 @@ bool test ( T const& y, T const& z ) x_c_ref = z ; BOOST_CHECK ( x_c == z ) ; + boost::shared_ptr > ptr( new boost::value_initialized ); + BOOST_CHECK ( y == *ptr ) ; + #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) boost::value_initialized cx ; BOOST_CHECK ( y == cx ) ; @@ -187,6 +191,7 @@ bool test ( T const& y, T const& z ) BOOST_CHECK ( y == cx_c ) ; BOOST_CHECK ( y == boost::get(cx_c) ) ; #endif + return boost::minimal_test::errors_counter() == counter_before_test ; } From 808067397797ab85d7b80820411c78f0a28ad5dc Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 9 Dec 2007 11:53:08 +0000 Subject: [PATCH 040/164] Added value_init tests if a copy function of T is called when value_initialized is copied -- a case I hadn't thought of before... [SVN r41919] --- value_init_test.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/value_init_test.cpp b/value_init_test.cpp index fcbada5..00c3333 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -156,6 +156,29 @@ bool operator == ( AggregatePODStructWrapper const& lhs, AggregatePODStructWrapp typedef unsigned char ArrayOfBytes[256]; + +// +// A struct that allows testing whether the appropriate copy functions are called. +// +struct CopyFunctionCallTester +{ + bool is_copy_constructed; + bool is_assignment_called; + + CopyFunctionCallTester() + : is_copy_constructed(false), is_assignment_called(false) {} + + CopyFunctionCallTester(const CopyFunctionCallTester & ) + : is_copy_constructed(true), is_assignment_called(false) {} + + CopyFunctionCallTester & operator=(const CopyFunctionCallTester & ) + { + is_assignment_called = true ; + return *this ; + } +}; + + // // This test function tests boost::value_initialized for a specific type T. // The first argument (y) is assumed have the value of a value-initialized object. @@ -244,8 +267,22 @@ int test_main(int, char **) boost::value_initialized valueInitializedArrayOfBytes; BOOST_CHECK (std::memcmp(get(valueInitializedArrayOfBytes), zeroInitializedArrayOfBytes, sizeof(ArrayOfBytes)) == 0); + boost::value_initialized copyFunctionCallTester1; + BOOST_CHECK ( ! get(copyFunctionCallTester1).is_copy_constructed); + BOOST_CHECK ( ! get(copyFunctionCallTester1).is_assignment_called); + + boost::value_initialized copyFunctionCallTester2 = boost::value_initialized(copyFunctionCallTester1); + BOOST_CHECK ( get(copyFunctionCallTester2).is_copy_constructed); + BOOST_CHECK ( ! get(copyFunctionCallTester2).is_assignment_called); + + boost::value_initialized copyFunctionCallTester3; + copyFunctionCallTester3 = boost::value_initialized(copyFunctionCallTester1); + BOOST_CHECK ( ! get(copyFunctionCallTester3).is_copy_constructed); + BOOST_CHECK ( get(copyFunctionCallTester3).is_assignment_called); + return 0; } unsigned int expected_failures = 0; + From 01274cf6acdfa34143638bd4b661c5812613132b Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 9 Dec 2007 22:49:58 +0000 Subject: [PATCH 041/164] value_init.hpp now no longer distinguished between workaround and non-workaround, because many compilers don't do value-initialization well. Fixed copy construction and assignment -- discussed with Fernando Cacciola [SVN r41942] --- include/boost/utility/value_init.hpp | 123 ++++++++++++++------------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index c4cd3e1..f5f04bf 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -7,103 +7,106 @@ // 21 Ago 2002 (Created) Fernando Cacciola // 07 Set 2007 (Worked around MSVC++ bug) Fernando Cacciola, Niels Dekker // 16 Nov 2007 (Refactoring: removed private base classes) Fernando Cacciola, Niels Dekker +// 09 Dec 2007 (Worked around various compiler bugs) Fernando Cacciola, Niels Dekker // #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP -#include -#include -#include - -// Microsoft Visual C++ does not correctly support value initialization, as reported by -// Pavel Kuznetsov (MetaCommunications Engineering), 7/28/2005, Feedback ID 100744, -// Feedback Title: Value-initialization in new-expression +// Note: The implementation of boost::value_initialized had to deal with the +// fact that various compilers haven't fully implemented value-initialization: +// Microsoft Feedback ID 100744 - Value-initialization in new-expression +// Reported by Pavel Kuznetsov (MetaCommunications Engineering), 2005-07-28 // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744 -// The report was closed at 11/14/2006, and its status was set to "Closed (Won't Fix)". -// Luckily, even in the presence of this compiler bug, boost::value_initialized will still -// do its job correctly, when using the following workaround: -#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) -# define BOOST_UTILITY_VALUE_INIT_WORKAROUND -#endif - -#ifdef BOOST_UTILITY_VALUE_INIT_WORKAROUND +// GCC Bug 30111 - Value-initialization of POD base class doesn't initialize members +// Reported by Jonathan Wakely, 2006-12-07 +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111 +// GCC Bug 33916 - Default constructor fails to initialize array members +// Reported by Michael Elizabeth Chastain, 2007-10-26 +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916 +// Borland Report 51854 - Value-initialization: POD struct should be zero-initialized +// Reported by Niels Dekker (LKEB, Leiden University Medical Center), 2007-11-09 +// http://qc.codegear.com/wc/qcmain.aspx?d=51854 +// The constructor of boost::value_initialized works around these issues, by +// clearing the bytes of T, before constructing the T object it contains. #include +#include +#include +#include #include #include #include -#ifdef BOOST_MSVC -#pragma warning(push) -#if _MSC_VER >= 1310 -// When using MSVC 7.1 or higher, placement new, "new (&x) T()", may trigger warning C4345: -// "behavior change: an object of POD type constructed with an initializer of the form () -// will be default-initialized". There is no need to worry about this, though. -#pragma warning(disable: 4345) -#endif -#endif - namespace boost { template class value_initialized { private : - mutable typename ::boost::aligned_storage::value>::type x; + struct wrapper + { +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) + typename +#endif + remove_const::type data; + }; + + mutable +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) + typename +#endif + ::boost::aligned_storage::value>::type x; public : value_initialized() { std::memset(&x, 0, sizeof(x)); - new (&x) T(); +#ifdef BOOST_MSVC +#pragma warning(push) +#if _MSC_VER >= 1310 +// When using MSVC 7.1 or higher, the following placement new expression may trigger warning C4345: +// "behavior change: an object of POD type constructed with an initializer of the form () +// will be default-initialized". There is no need to worry about this, though. +#pragma warning(disable: 4345) +#endif +#endif + new (&x) wrapper(); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + } + + value_initialized(value_initialized const & arg) + { + void const * const ptr = &(arg.x); + new (&x) wrapper( *static_cast(ptr) ); + } + + value_initialized & operator=(value_initialized const & arg) + { + T & this_data = this->data(); + T const & arg_data = arg.data(); + this_data = arg_data; + return *this; } ~value_initialized() { - void * ptr = &x; - static_cast(ptr)->T::~T(); + void * const ptr = &x; + static_cast(ptr)->wrapper::~wrapper(); } T& data() const { - void * ptr = &x; - return *static_cast(ptr); + void * const ptr = &x; + return static_cast(ptr)->data; } operator T&() const { return this->data(); } } ; -#ifdef BOOST_MSVC -// Restores the state of warning C4345. -#pragma warning(pop) -#endif - -#else - -namespace boost { - -template -class value_initialized -{ - public : - - value_initialized() : x() {} - - T& data() const { return x; } - - operator T&() const { return this->data(); } - - mutable -#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - typename -#endif - ::boost::remove_const::type x ; - -} ; -#endif - template From c1fd67048031a696f3b413127f3e8ac28b840005 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 21 Dec 2007 21:18:17 +0000 Subject: [PATCH 042/164] Reduce header dependencies, from Shunsuke Sogame. Fixes #1535 [SVN r42234] --- include/boost/utility/result_of.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp index cdcac34..a5bac6f 100644 --- a/include/boost/utility/result_of.hpp +++ b/include/boost/utility/result_of.hpp @@ -10,9 +10,10 @@ #define BOOST_RESULT_OF_HPP #include -#include -#include -#include +#include +#include +#include +#include #include #include #include From ac1567b3fcc3451ab04c303e88d15f2bb9f0e449 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Mon, 24 Dec 2007 20:42:16 +0000 Subject: [PATCH 043/164] value_init now uses aligned_storage::address(), instead of "&x", as recommended by Fernando Cacciola (by mail) [SVN r42277] --- include/boost/utility/value_init.hpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index f5f04bf..097f21a 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -5,9 +5,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // // 21 Ago 2002 (Created) Fernando Cacciola -// 07 Set 2007 (Worked around MSVC++ bug) Fernando Cacciola, Niels Dekker -// 16 Nov 2007 (Refactoring: removed private base classes) Fernando Cacciola, Niels Dekker -// 09 Dec 2007 (Worked around various compiler bugs) Fernando Cacciola, Niels Dekker +// 24 Dec 2007 (Refactored and worked around various compiler bugs) Fernando Cacciola, Niels Dekker // #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP @@ -30,7 +28,6 @@ // clearing the bytes of T, before constructing the T object it contains. #include -#include #include #include #include @@ -51,17 +48,13 @@ class value_initialized remove_const::type data; }; - mutable -#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) - typename -#endif - ::boost::aligned_storage::value>::type x; + mutable aligned_storage::value> x; public : value_initialized() { - std::memset(&x, 0, sizeof(x)); + std::memset(x.address(), 0, sizeof(x)); #ifdef BOOST_MSVC #pragma warning(push) #if _MSC_VER >= 1310 @@ -71,7 +64,7 @@ class value_initialized #pragma warning(disable: 4345) #endif #endif - new (&x) wrapper(); + new (x.address()) wrapper(); #ifdef BOOST_MSVC #pragma warning(pop) #endif @@ -79,8 +72,7 @@ class value_initialized value_initialized(value_initialized const & arg) { - void const * const ptr = &(arg.x); - new (&x) wrapper( *static_cast(ptr) ); + new (x.address()) wrapper( *static_cast(arg.x.address()) ); } value_initialized & operator=(value_initialized const & arg) @@ -93,14 +85,12 @@ class value_initialized ~value_initialized() { - void * const ptr = &x; - static_cast(ptr)->wrapper::~wrapper(); + static_cast(x.address())->wrapper::~wrapper(); } T& data() const { - void * const ptr = &x; - return static_cast(ptr)->data; + return static_cast(x.address())->data; } operator T&() const { return this->data(); } From d731b8e1c5a43aa6d7bbac5991d04f97bdbe6408 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Mon, 24 Dec 2007 22:00:37 +0000 Subject: [PATCH 044/164] Added value_init tests, testing copy construction and assignment. [SVN r42278] --- value_init_test.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/value_init_test.cpp b/value_init_test.cpp index 00c3333..6dc8e27 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -202,6 +202,13 @@ bool test ( T const& y, T const& z ) x_c_ref = z ; BOOST_CHECK ( x_c == z ) ; + boost::value_initialized const copy1 = x; + BOOST_CHECK ( boost::get(copy1) == boost::get(x) ) ; + + boost::value_initialized copy2; + copy2 = x; + BOOST_CHECK ( boost::get(copy2) == boost::get(x) ) ; + boost::shared_ptr > ptr( new boost::value_initialized ); BOOST_CHECK ( y == *ptr ) ; From ac93de7c1be8bb096e135e1fcd9e400d00cafe1a Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Mon, 14 Jan 2008 18:17:30 +0000 Subject: [PATCH 045/164] Documented value_init workaround to compiler issues, added new introduction, updated to 2003 edition of C++ Standard -- reviewed by Fernando Cacciola [SVN r42771] --- value_init.htm | 157 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 139 insertions(+), 18 deletions(-) diff --git a/value_init.htm b/value_init.htm index 8ceba8b..7cf9e9b 100644 --- a/value_init.htm +++ b/value_init.htm @@ -17,11 +17,13 @@
    Rationale
    Introduction
    +
    Details
    @@ -46,22 +48,89 @@ for initialization. Depending on the type, the value of a newly constructed the default constructor), or indeterminate. When writing generic code, this problem must be addressed. value_initialized provides a solution with consistent syntax for value initialization of scalar, -union and class types.
    +union and class types. +Moreover, value_initialized offers a workaround to various +compiler issues regarding value-initialization. + +

    Introduction

    +

    +There are various ways to initialize a variable, in C++. The following +declarations all may have a local variable initialized to its default +value: +

    +  T1 var1;
    +  T2 var2 = 0;
    +  T3 var3 = {};
    +  T4 var4 = T4();
    +
    +Unfortunately, whether or not any of those declarations correctly +initialize the variable very much depends on its type. The first +declaration is valid for any +DefaultConstructible type (by definition). +However, it does not always do an initialization! +It correctly initializes the variable when it's an instance of a +class, and the author of the class has provided a proper default +constructor. On the other hand, the value of var1 is indeterminate when +its type is an arithmetic type, like int, float, or char. +An arithmetic variable +is of course initialized properly by the second declaration, T2 +var2 = 0. But this initialization form usually won't work for a +class type (unless the class was especially written to support being +initialized that way). The third form, T3 var3 = {} +initializes an aggregate, typically a "C-style" struct or a "C-style" array. +However, the syntax is not allowed for a class that has an explicitly declared +constructor. (But watch out for an upcoming C++ language change, +by Bjarne Stroustrup et al [3]!) +The fourth form is the most generic form of them, as it +can be used to initialize arithmetic types, class types, aggregates, pointers, and +other types. The declaration, T4 var4 = T4(), should be read +as follows: First a temporary object is created, by T4(). +This object is value-initialized. Next the temporary +object is copied to the named variable, var4. Afterwards, the temporary +is destroyed. While the copying and the destruction are likely to +be optimized away, C++ still requires the type T4 to be +CopyConstructible. +(So T4 needs to be both DefaultConstructible and CopyConstructible.) +A class may not be CopyConstructible, for example because it may have a +private and undefined copy constructor, +or because it may be derived from boost::noncopyable. +Scott Meyers [4] explains why a class would be defined like that. +

    +

    +There is another, less obvious disadvantage to the fourth form, T4 var4 = T4(): +It suffers from various compiler issues, causing +a variable to be left uninitialized in some compiler specific cases. +

    +

    +The template value_initialized +offers a generic way to initialize +an object, like T4 var4 = T4(), but without requiring its type +to be CopyConstructible. And it offers a workaround to those compiler issues +regarding value-initialization as well! It allows getting an initialized +variable of any type; it only requires the type to be DefaultConstructible. +A properly value-initialized object of type T is +constructed by the following declaration: +

    +  value_initialized<T> var;
    +
    +

    + +

    Details

    The C++ standard [1] contains the definitions of zero-initialization and default-initialization. Informally, zero-initialization means that the object is given the initial value 0 (converted to the type) and default-initialization means that - POD [2] types are zero-initialized, while class + POD [2] types are zero-initialized, while non-POD class types are initialized with their corresponding default constructors. A declaration can contain an initializer, which specifies the object's initial value. The initializer can be just '()', which states that -the object shall be default-initialized (but see below). However, if a declaration +the object shall be value-initialized (but see below). However, if a declaration has no initializer and it is of a non-const, non-static - POD type, the initial value is indeterminate:(see §8.5 for the + POD type, the initial value is indeterminate: (see §8.5, [dcl.init], for the accurate definitions).

    int x ; // no initializer. x value is indeterminate.
    std::string s ; // no initializer, s is default-constructed.

    int y = int() ;
    // y is initialized using copy-initialization
    // but the temporary uses an empty set of parentheses as the initializer,
    // so it is default-constructed.
    // A default constructed POD type is zero-initialized,
    // therefore, y == 0.

    void foo ( std::string ) ;
    foo ( std::string() ) ;
    // the temporary string is default constructed
    // as indicated by the initializer ()
    @@ -87,14 +156,11 @@ the object shall be default-initialized (but see below). However, if a decla

    In order to specify value-initialization of an object we need to use the empty-set initializer: ().

    -

    (but recall that the current C++ Standard states that '()' invokes default-initialization, -not value-initialization)

    -

    As before, a declaration with no intializer specifies default-initialization, and a declaration with a non-empty initializer specifies copy (=xxx) or direct (xxx) initialization.

    -
    template<class T> void eat(T);
    int x ; // indeterminate initial value.
    std::string s; // default-initialized.
    eat ( int() ) ; // value-initialized
    eat ( std::string() ) ; // value-initialied
    +
    template<class T> void eat(T);
    int x ; // indeterminate initial value.
    std::string s; // default-initialized.
    eat ( int() ) ; // value-initialized
    eat ( std::string() ) ; // value-initialized

    value-initialization syntax

    @@ -102,7 +168,7 @@ not value-initialization)

    parentheses is not permitted by the syntax of initializers because it is parsed as the declaration of a function taking no arguments:

    -
    int x() ; // declares function int(*)()
    int y ( int() ) ; // decalares function int(*)( int(*)() )
    +
    int x() ; // declares function int(*)()

    Thus, the empty () must be put in some other initialization context.

    @@ -124,8 +190,50 @@ data member:

    template<class T> 
    struct W
    {
    // value-initialization of 'data' here.
    W() : data() {}
    T data ;
    } ;
    W<int> w ;
    // w.data is value-initialized for any type.
    -

    This is the solution supplied by the value_initialized<> template - class.

    +

    This is the solution as it was supplied by earlier versions of the +value_initialized<T> template + class. Unfortunately this approach suffered from various compiler issues.

    + +

    compiler issues

    + +Various compilers haven't yet fully implemented value-initialization. +So when an object should be value-initialized (according to the C++ Standard), +it may in practice still be left uninitialized, because of those +compiler issues! It's hard to make a general statement on what those issues +are like, because they depend on the compiler you are using, its version number, +and the type of object you would like to have value-initialized. +Compilers usually support value-initialization for built-in types properly. +But objects of user-defined types that involve aggregates may in some cases +be partially, or even entirely left uninitialized, when they should be value-initialized. +

    +

    +We have encountered issues regarding value-initialization on compilers by +Microsoft, Sun, Borland, and GNU. Here is a list of bug reports on those issues: + +
    + +Microsoft Feedback ID 100744 - Value-initialization in new-expression +
    Reported by Pavel Kuznetsov (MetaCommunications Engineering), 2005-07-28 +
    + +GCC Bug 30111 - Value-initialization of POD base class doesn't initialize members +
    Reported by Jonathan Wakely, 2006-12-07 +
    + +GCC Bug 33916 - Default constructor fails to initialize array members +
    Reported by Michael Elizabeth Chastain, 2007-10-26 +
    + +Borland Report 51854 - Value-initialization: POD struct should be zero-initialized +
    Reported by Niels Dekker (LKEB, Leiden University Medical Center), 2007-11-09 +
    +
    +

    +New versions of value_initialized +(Boost release version 1.35 or higher) +offer a workaround to these issues: value_initialized will now clear +its internal data, prior to constructing the object that it contains. +

    Types

    @@ -191,23 +299,36 @@ the wrapped object is always performed with the get() idiom:

    value_initialized<int> x ;
    get(x) = 1 ; // OK

    value_initialized<int const> cx ;
    get(x) = 1 ; // ERROR: Cannot modify a const object

    value_initialized<int> const x_c ;
    get(x_c) = 1 ; // ERROR: Cannot modify a const object

    value_initialized<int const> const cx_c ;
    get(cx_c) = 1 ; // ERROR: Cannot modify a const object

    References

    - [1] The C++ Standard, ISO/IEC 14882:98
    - [2] Plain Old Data + [1] The C++ Standard, Second edition (2003), ISO/IEC 14882:2003
    + [2] POD stands for "Plain Old Data"
    + [3] Bjarne Stroustrup, Gabriel Dos Reis, and J. Stephen Adamczyk wrote + various papers, proposing to extend the support for brace-enclosed initializer lists + in the next version of C++. + This would allow a variable var of any DefaultConstructible type + T to be value-initialized by doing T var = {}. + The papers are listed at Bjarne's web page, + My C++ Standards committee papers
    + [4] Scott Meyers, Effective C++, Third Edition, item 6, + Explicitly disallow the use of compiler-generated functions you do not want, + Scott Meyers: Books and CDs +

    Acknowledgements

    value_initialized was developed by Fernando Cacciola, with help and suggestions from David Abrahams and Darin Adler.
    Special thanks to Björn Karlsson who carefully edited and completed this documentation. - + +

    value_initialized was reimplemented by Fernando Cacciola and Niels Dekker +for Boost release version 1.35 (2008), offering a workaround to various compiler issues. +

    Developed by Fernando Cacciola, the latest version of this file can be found at www.boost.org, and the boost discussion list -at www.yahoogroups.com/list/boost. + href="http://www.boost.org">www.boost.org.


    -

    Revised 19 September 2002

    +

    Revised January 2008

    -

    © Copyright Fernando Cacciola, 2002.

    +

    © Copyright Fernando Cacciola, 2002, 2008.

    Distributed under the Boost Software License, Version 1.0. See www.boost.org/LICENSE_1_0.txt

    From 79bbf71d0d9ef537659b79d732634b0001a0545b Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Mon, 14 Jan 2008 21:46:20 +0000 Subject: [PATCH 046/164] Minor "beautifications" of value_init documentation, inc. placing references in order of appearance [SVN r42779] --- value_init.htm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/value_init.htm b/value_init.htm index 7cf9e9b..578eed3 100644 --- a/value_init.htm +++ b/value_init.htm @@ -32,7 +32,7 @@ Acknowledgements
    @@ -46,7 +46,7 @@ for initialization. Depending on the type, the value of a newly constructed object can be zero-initialized (logically 0), default-constructed (using the default constructor), or indeterminate. When writing generic code, -this problem must be addressed. value_initialized provides +this problem must be addressed. The template value_initialized provides a solution with consistent syntax for value initialization of scalar, union and class types. Moreover, value_initialized offers a workaround to various @@ -84,7 +84,7 @@ initialized that way). The third form, T3 var3 = {} initializes an aggregate, typically a "C-style" struct or a "C-style" array. However, the syntax is not allowed for a class that has an explicitly declared constructor. (But watch out for an upcoming C++ language change, -by Bjarne Stroustrup et al [3]!) +by Bjarne Stroustrup et al [1]!) The fourth form is the most generic form of them, as it can be used to initialize arithmetic types, class types, aggregates, pointers, and other types. The declaration, T4 var4 = T4(), should be read @@ -98,7 +98,7 @@ be optimized away, C++ still requires the type T4 to be A class may not be CopyConstructible, for example because it may have a private and undefined copy constructor, or because it may be derived from boost::noncopyable. -Scott Meyers [4] explains why a class would be defined like that. +Scott Meyers [2] explains why a class would be defined like that.

    There is another, less obvious disadvantage to the fourth form, T4 var4 = T4(): @@ -120,11 +120,11 @@ constructed by the following declaration:

    Details

    -

    The C++ standard [1] contains the definitions +

    The C++ standard [3] contains the definitions of zero-initialization and default-initialization. Informally, zero-initialization means that the object is given the initial value 0 (converted to the type) and default-initialization means that - POD [2] types are zero-initialized, while non-POD class + POD [4] types are zero-initialized, while non-POD class types are initialized with their corresponding default constructors. A declaration can contain an initializer, which specifies the object's initial value. The initializer can be just '()', which states that @@ -225,7 +225,7 @@ GCC Bug 33916 - Default constructor fails to initialize array members
    Borland Report 51854 - Value-initialization: POD struct should be zero-initialized -
    Reported by Niels Dekker (LKEB, Leiden University Medical Center), 2007-11-09 +
    Reported by Niels Dekker (LKEB, Leiden University Medical Center), 2007-09-11

    @@ -299,23 +299,23 @@ the wrapped object is always performed with the get() idiom:

    value_initialized<int> x ;
    get(x) = 1 ; // OK

    value_initialized<int const> cx ;
    get(x) = 1 ; // ERROR: Cannot modify a const object

    value_initialized<int> const x_c ;
    get(x_c) = 1 ; // ERROR: Cannot modify a const object

    value_initialized<int const> const cx_c ;
    get(cx_c) = 1 ; // ERROR: Cannot modify a const object

    References

    - [1] The C++ Standard, Second edition (2003), ISO/IEC 14882:2003
    - [2] POD stands for "Plain Old Data"
    - [3] Bjarne Stroustrup, Gabriel Dos Reis, and J. Stephen Adamczyk wrote + [1] Bjarne Stroustrup, Gabriel Dos Reis, and J. Stephen Adamczyk wrote various papers, proposing to extend the support for brace-enclosed initializer lists in the next version of C++. This would allow a variable var of any DefaultConstructible type T to be value-initialized by doing T var = {}. The papers are listed at Bjarne's web page, My C++ Standards committee papers
    - [4] Scott Meyers, Effective C++, Third Edition, item 6, + [2] Scott Meyers, Effective C++, Third Edition, item 6, Explicitly disallow the use of compiler-generated functions you do not want, - Scott Meyers: Books and CDs + Scott Meyers: Books and CDs
    + [3] The C++ Standard, Second edition (2003), ISO/IEC 14882:2003
    + [4] POD stands for "Plain Old Data"

    Acknowledgements

    value_initialized was developed by Fernando Cacciola, with help and suggestions from David Abrahams and Darin Adler.
    -Special thanks to Björn Karlsson who carefully edited and completed this documentation. +Special thanks to Björn Karlsson who carefully edited and completed this documentation.

    value_initialized was reimplemented by Fernando Cacciola and Niels Dekker for Boost release version 1.35 (2008), offering a workaround to various compiler issues. From 9ed68b832123c2c1d2d459ec89826f8d2fa77800 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Tue, 15 Jan 2008 19:53:28 +0000 Subject: [PATCH 047/164] value_init doc + test: Added revision date. [SVN r42798] --- value_init.htm | 2 +- value_init_test.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/value_init.htm b/value_init.htm index 578eed3..405f0b6 100644 --- a/value_init.htm +++ b/value_init.htm @@ -326,7 +326,7 @@ for Boost release version 1.35 (2008), offering a workaround to various compiler


    -

    Revised January 2008

    +

    Revised 15 January 2008

    © Copyright Fernando Cacciola, 2002, 2008.

    diff --git a/value_init_test.cpp b/value_init_test.cpp index 6dc8e27..7b332d7 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -1,4 +1,4 @@ -// Copyright 2002, Fernando Luis Cacciola Carballal. +// Copyright 2002-2008, Fernando Luis Cacciola Carballal. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -6,7 +6,8 @@ // // Test program for "boost/utility/value_init.hpp" // -// Initial: 21 Agu 2002 +// 21 Agu 2002 (Created) Fernando Cacciola +// 15 Jan 2008 (Added tests regarding compiler issues) Fernando Cacciola, Niels Dekker #include // For memcmp. #include From 8ce58b1675e81a5249bed6101d4b6186f8be641b Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 16 Jan 2008 09:35:12 +0000 Subject: [PATCH 048/164] Added convenience class initialized_value, as announced at http://article.gmane.org/gmane.comp.lib.boost.devel/169833 [SVN r42815] --- include/boost/utility/value_init.hpp | 35 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index 097f21a..4e2ab85 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -1,31 +1,20 @@ -// (C) Copyright 2002-2007, Fernando Luis Cacciola Carballal. +// (C) Copyright 2002-2008, Fernando Luis Cacciola Carballal. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // 21 Ago 2002 (Created) Fernando Cacciola -// 24 Dec 2007 (Refactored and worked around various compiler bugs) Fernando Cacciola, Niels Dekker +// 16 Jan 2008 (Worked around compiler bugs, added initialized_value) Fernando Cacciola, Niels Dekker // #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP // Note: The implementation of boost::value_initialized had to deal with the -// fact that various compilers haven't fully implemented value-initialization: -// Microsoft Feedback ID 100744 - Value-initialization in new-expression -// Reported by Pavel Kuznetsov (MetaCommunications Engineering), 2005-07-28 -// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744 -// GCC Bug 30111 - Value-initialization of POD base class doesn't initialize members -// Reported by Jonathan Wakely, 2006-12-07 -// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111 -// GCC Bug 33916 - Default constructor fails to initialize array members -// Reported by Michael Elizabeth Chastain, 2007-10-26 -// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916 -// Borland Report 51854 - Value-initialization: POD struct should be zero-initialized -// Reported by Niels Dekker (LKEB, Leiden University Medical Center), 2007-11-09 -// http://qc.codegear.com/wc/qcmain.aspx?d=51854 -// The constructor of boost::value_initialized works around these issues, by -// clearing the bytes of T, before constructing the T object it contains. +// fact that various compilers haven't fully implemented value-initialization. +// The constructor of boost::value_initialized works around these compiler +// issues, by clearing the bytes of T, before constructing the T object it +// contains. More details on these issues are at libs/utility/value_init.htm #include #include @@ -110,6 +99,18 @@ T& get ( value_initialized& x ) return x.data() ; } + +class initialized_value +{ + public : + + template operator T() const + { + return get( value_initialized() ); + } +}; + + } // namespace boost From a511007d0f160a540f8e6e70596eb458889b9491 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 16 Jan 2008 09:37:25 +0000 Subject: [PATCH 049/164] Added test and documentation for convenience class initialized_value, that was added with changeset [42815] [SVN r42816] --- value_init.htm | 52 +++++++++++++++++++++++++++++++++++++++++++-- value_init_test.cpp | 8 +++++-- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/value_init.htm b/value_init.htm index 405f0b6..c97a0eb 100644 --- a/value_init.htm +++ b/value_init.htm @@ -32,7 +32,8 @@ Acknowledgements
    @@ -52,6 +53,9 @@ union and class types. Moreover, value_initialized offers a workaround to various compiler issues regarding value-initialization. +Furthermore a convenience class, initialized_value is provided, +to avoid repeating the type name when retrieving the value from a +value_initialized<T> object.

    @@ -117,6 +121,16 @@ constructed by the following declaration:
       value_initialized<T> var;
     
    +

    +

    +The convenience class initialized_value +allows value-initializing a variable as follows: +

    +  T var = initialized_value();
    +
    +This form of initialization is also very similar to T4 var4 = T4(), +but robust against the aforementioned compiler issues. +

    Details

    @@ -297,6 +311,40 @@ wrapped object from within a constant wrapper can be avoided if access to the wrapped object is always performed with the get() idiom:

    value_initialized<int> x ;
    get(x) = 1 ; // OK

    value_initialized<int const> cx ;
    get(x) = 1 ; // ERROR: Cannot modify a const object

    value_initialized<int> const x_c ;
    get(x_c) = 1 ; // ERROR: Cannot modify a const object

    value_initialized<int const> const cx_c ;
    get(cx_c) = 1 ; // ERROR: Cannot modify a const object
    + +

    class initialized_value

    + +
    +namespace boost {
    +class initialized_value
    +{
    +  public :
    +    template <class T> operator T() const ;
    +};
    +} // namespace boost
    +
    + +The class initialized_value provides a convenient way to get +an initialized value: its conversion operator provides an appropriate +value-initialized object for any CopyConstructible type. + +Suppose you need to have an initialized variable of type T. +You could do it as follows: +
    +  T var = T();
    +
    +But as mentioned before, this form suffers from various compiler issues. +The template value_initialized offers a workaround: +
    +  T var = get( value_initialized<T>() );
    +
    +Unfortunately both forms repeat the type name, which +is rather short now (T), but could of course be +more like Namespace::Template<Arg>::Type. +Instead, one could use initialized_value as follows: +
    +  T var = initialized_value();
    +

    References

    [1] Bjarne Stroustrup, Gabriel Dos Reis, and J. Stephen Adamczyk wrote @@ -326,7 +374,7 @@ for Boost release version 1.35 (2008), offering a workaround to various compiler


    -

    Revised 15 January 2008

    +

    Revised 16 January 2008

    © Copyright Fernando Cacciola, 2002, 2008.

    diff --git a/value_init_test.cpp b/value_init_test.cpp index 7b332d7..70cd998 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -7,7 +7,7 @@ // Test program for "boost/utility/value_init.hpp" // // 21 Agu 2002 (Created) Fernando Cacciola -// 15 Jan 2008 (Added tests regarding compiler issues) Fernando Cacciola, Niels Dekker +// 16 Jan 2008 (Added tests regarding compiler issues and initialized_value) Fernando Cacciola, Niels Dekker #include // For memcmp. #include @@ -52,7 +52,7 @@ struct NonPODBase struct NonPOD : NonPODBase { NonPOD () : id() {} - NonPOD ( std::string const& id_) : id(id_) {} + explicit NonPOD ( std::string const& id_) : id(id_) {} friend std::ostream& operator << ( std::ostream& os, NonPOD const& npod ) { return os << '(' << npod.id << ')' ; } @@ -192,6 +192,10 @@ bool test ( T const& y, T const& z ) boost::value_initialized x ; BOOST_CHECK ( y == x ) ; BOOST_CHECK ( y == boost::get(x) ) ; + + T initializedValue = boost::initialized_value() ; + BOOST_CHECK ( y == initializedValue ) ; + static_cast(x) = z ; boost::get(x) = z ; BOOST_CHECK ( x == z ) ; From 721764937f7b41971561d025c562e1727aa2ead5 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sat, 19 Jan 2008 20:21:18 +0000 Subject: [PATCH 050/164] value_init_test now works around Borland 5.82 bug ("Error E2015: Ambiguity..." when using initialized_value), that is fixed with a newer compiler version [SVN r42868] --- value_init_test.cpp | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/value_init_test.cpp b/value_init_test.cpp index 70cd998..175d30c 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -6,8 +6,8 @@ // // Test program for "boost/utility/value_init.hpp" // -// 21 Agu 2002 (Created) Fernando Cacciola -// 16 Jan 2008 (Added tests regarding compiler issues and initialized_value) Fernando Cacciola, Niels Dekker +// 21 Ago 2002 (Created) Fernando Cacciola +// 19 Jan 2008 (Added tests regarding compiler issues and initialized_value) Fernando Cacciola, Niels Dekker #include // For memcmp. #include @@ -180,6 +180,32 @@ struct CopyFunctionCallTester }; +template +void check_initialized_value ( T const& y ) +{ + T initializedValue = boost::initialized_value() ; + BOOST_CHECK ( y == initializedValue ) ; +} + +#ifdef __BORLANDC__ +#if __BORLANDC__ == 0x582 +void check_initialized_value( NonPOD const& ) +{ + // The initialized_value check is skipped for Borland 5.82 + // and this type (NonPOD), because the following statement + // won't compile on this particular compiler version: + // NonPOD initializedValue = boost::initialized_value() ; + // + // This is caused by a compiler bug, that is fixed with a newer version + // of the Borland compiler. The Release Notes for Delphi(R) 2007 for + // Win32(R) and C++Builder(R) 2007 (http://dn.codegear.com/article/36575) + // say about similar statements: + // both of these statements now compile but under 5.82 got the error: + // Error E2015: Ambiguity between 'V::V(const A &)' and 'V::V(const V &)' +} +#endif +#endif + // // This test function tests boost::value_initialized for a specific type T. // The first argument (y) is assumed have the value of a value-initialized object. @@ -189,13 +215,13 @@ template bool test ( T const& y, T const& z ) { const boost::unit_test::counter_t counter_before_test = boost::minimal_test::errors_counter(); + + check_initialized_value(y); + boost::value_initialized x ; BOOST_CHECK ( y == x ) ; BOOST_CHECK ( y == boost::get(x) ) ; - T initializedValue = boost::initialized_value() ; - BOOST_CHECK ( y == initializedValue ) ; - static_cast(x) = z ; boost::get(x) = z ; BOOST_CHECK ( x == z ) ; From 1beca24dd8c34d2dc476891d403c5d57f6a5d9e2 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sat, 19 Jan 2008 20:52:04 +0000 Subject: [PATCH 051/164] Removed local named variable from value_initialized::operator=, as Fernando Cacciola suggested me to avoid unnecessary named variables. [SVN r42869] --- include/boost/utility/value_init.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index 4e2ab85..a4e0034 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -5,7 +5,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // // 21 Ago 2002 (Created) Fernando Cacciola -// 16 Jan 2008 (Worked around compiler bugs, added initialized_value) Fernando Cacciola, Niels Dekker +// 19 Jan 2008 (Worked around compiler bugs, added initialized_value) Fernando Cacciola, Niels Dekker // #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP @@ -49,7 +49,7 @@ class value_initialized #if _MSC_VER >= 1310 // When using MSVC 7.1 or higher, the following placement new expression may trigger warning C4345: // "behavior change: an object of POD type constructed with an initializer of the form () -// will be default-initialized". There is no need to worry about this, though. +// will be default-initialized". It is safe to ignore this warning when using value_initialized. #pragma warning(disable: 4345) #endif #endif @@ -66,9 +66,8 @@ class value_initialized value_initialized & operator=(value_initialized const & arg) { - T & this_data = this->data(); T const & arg_data = arg.data(); - this_data = arg_data; + this->data() = arg_data; return *this; } From 28596e678d2f59b64484d087f2a9258ba712d667 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 30 Jan 2008 22:42:23 +0000 Subject: [PATCH 052/164] value_init: Removed aligned_storage::address() calls, to improve TR1 compatibility, as confirmed by John Maddock. Added internal helper function, wrapper_address(), as discussed with Fernando. [SVN r43025] --- include/boost/utility/value_init.hpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index a4e0034..4845cfb 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -5,7 +5,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // // 21 Ago 2002 (Created) Fernando Cacciola -// 19 Jan 2008 (Worked around compiler bugs, added initialized_value) Fernando Cacciola, Niels Dekker +// 30 Jan 2008 (Worked around compiler bugs, added initialized_value) Fernando Cacciola, Niels Dekker // #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP @@ -37,13 +37,22 @@ class value_initialized remove_const::type data; }; - mutable aligned_storage::value> x; + mutable +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) + typename +#endif + aligned_storage::value>::type x; + + wrapper * wrapper_address() const + { + return static_cast( static_cast(&x)); + } public : value_initialized() { - std::memset(x.address(), 0, sizeof(x)); + std::memset(&x, 0, sizeof(x)); #ifdef BOOST_MSVC #pragma warning(push) #if _MSC_VER >= 1310 @@ -53,7 +62,7 @@ class value_initialized #pragma warning(disable: 4345) #endif #endif - new (x.address()) wrapper(); + new (wrapper_address()) wrapper(); #ifdef BOOST_MSVC #pragma warning(pop) #endif @@ -61,24 +70,23 @@ class value_initialized value_initialized(value_initialized const & arg) { - new (x.address()) wrapper( *static_cast(arg.x.address()) ); + new (wrapper_address()) wrapper( static_cast(*(arg.wrapper_address()))); } value_initialized & operator=(value_initialized const & arg) { - T const & arg_data = arg.data(); - this->data() = arg_data; + this->data() = static_cast( arg.data() ); return *this; } ~value_initialized() { - static_cast(x.address())->wrapper::~wrapper(); + wrapper_address()->wrapper::~wrapper(); } T& data() const { - return static_cast(x.address())->data; + return wrapper_address()->data; } operator T&() const { return this->data(); } From 691e4b6c347bf9b926bfd6af22c9418435eabf69 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 10 Feb 2008 14:56:22 +0000 Subject: [PATCH 053/164] Link to people pages on the website, as they've been removed from the download. [SVN r43209] --- base_from_member.html | 6 +++--- generator_iterator.htm | 2 +- operators.htm | 10 +++++----- utility.htm | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/base_from_member.html b/base_from_member.html index 4dd70f4..21ee6d2 100644 --- a/base_from_member.html +++ b/base_from_member.html @@ -334,7 +334,7 @@ with the exact pointer type used in switcher's constructor.

    Contributors

    -
    Ed Brey +
    Ed Brey
    Suggested some interface changes.
    R. Samuel Klatchko (switcher's constructor.

    Invented the idiom of how to use a class member for initializing a base class. -
    Dietmar Kuehl +
    Dietmar Kuehl
    Popularized the base-from-member idiom in his IOStream example classes. @@ -353,7 +353,7 @@ with the exact pointer type used in switcher's constructor.

    can be controlled and automated with macros. The implementation uses the Preprocessor library. -
    Daryle Walker +
    Daryle Walker
    Started the library. Contributed the test file base_from_member_test.cpp.
    diff --git a/generator_iterator.htm b/generator_iterator.htm index c81d3d1..6070522 100644 --- a/generator_iterator.htm +++ b/generator_iterator.htm @@ -153,7 +153,7 @@ int main() 05 December, 2006

    Copyright © 2001 Jens Maurer

    + "http://www.boost.org/people/jens_maurer.htm">Jens Maurer

    Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or diff --git a/operators.htm b/operators.htm index fca90e5..13d0d0b 100644 --- a/operators.htm +++ b/operators.htm @@ -2029,13 +2029,13 @@ public:

    Contributors

    -
    Dave Abrahams
    +
    Dave Abrahams
    Started the library and contributed the arithmetic operators in boost/operators.hpp.
    -
    Jeremy Siek
    +
    Jeremy Siek
    Contributed the dereference operators and iterator helpers in iterators_test.cpp.
    -
    Aleksey +
    Aleksey Gurtovoy
    Contributed the code to support base class chaining while remaining backward-compatible with old versions of the library.
    -
    Beman Dawes
    +
    Beman Dawes
    Contributed operators_test.cpp.
    -
    Daryle Walker
    +
    Daryle Walker
    Contributed classes for the shift operators, equivalence, partial ordering, and arithmetic conversions. Added the grouped operator diff --git a/utility.htm b/utility.htm index 937a8a3..9514188 100644 --- a/utility.htm +++ b/utility.htm @@ -68,7 +68,7 @@ const std::list<T>::iterator next = boost::next(prev, 2);

    The distance from the given iterator should be supplied as an absolute value. For example, the iterator four iterators prior to the given iterator p may be obtained by prior(p, 4).

    -

    Contributed by Dave Abrahams. Two-argument versions by Daniel Walker.

    +

    Contributed by Dave Abrahams. Two-argument versions by Daniel Walker.

    Class noncopyable

    Class noncopyable is a base class.  Derive your own class from noncopyable when you want to prohibit copy construction @@ -89,7 +89,7 @@ const std::list<T>::iterator next = boost::next(prev, 2);

    to verify class noncopyable works as expected. It has have been run successfully under GCC 2.95, Metrowerks CodeWarrior 5.0, and Microsoft Visual C++ 6.0 sp 3.

    -

    Contributed by Dave Abrahams.

    +

    Contributed by Dave Abrahams.

    Example

    // inside one of your own headers ...
    
    From ad9108c1dce16740d1ae172a7cbd9181ecbbbefd Mon Sep 17 00:00:00 2001
    From: Niels Dekker 
    Date: Mon, 18 Feb 2008 22:11:19 +0000
    Subject: [PATCH 054/164] Fixed the assignment of value_initialized for T
     being a C-style array. (The previous version would trigger a compile error in
     this case.)
    
    [SVN r43308]
    ---
     include/boost/utility/value_init.hpp | 7 +++++--
     1 file changed, 5 insertions(+), 2 deletions(-)
    
    diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp
    index 4845cfb..60879cf 100644
    --- a/include/boost/utility/value_init.hpp
    +++ b/include/boost/utility/value_init.hpp
    @@ -5,7 +5,7 @@
     // http://www.boost.org/LICENSE_1_0.txt)
     //
     // 21 Ago 2002 (Created) Fernando Cacciola
    -// 30 Jan 2008 (Worked around compiler bugs, added initialized_value) Fernando Cacciola, Niels Dekker
    +// 18 Feb 2008 (Worked around compiler bugs, added initialized_value) Fernando Cacciola, Niels Dekker
     //
     #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
     #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
    @@ -18,6 +18,7 @@
     
     #include 
     #include 
    +#include 
     #include 
     #include 
     #include 
    @@ -75,7 +76,9 @@ class value_initialized
     
         value_initialized & operator=(value_initialized const & arg)
         {
    -      this->data() = static_cast( arg.data() );
    +      // Assignment is only allowed when T is non-const.
    +      BOOST_STATIC_ASSERT( ! is_const::value );
    +      *wrapper_address() = static_cast(*(arg.wrapper_address()));
           return *this;
         }
     
    
    From 50268d1b2998e84e5e53e3b80832fbbbc1e4e0a5 Mon Sep 17 00:00:00 2001
    From: Niels Dekker 
    Date: Mon, 18 Feb 2008 22:13:21 +0000
    Subject: [PATCH 055/164] Tested the assignment of value_initialized, for T
     being a C-style array. Related to the fix of changeset [43308]
    
    [SVN r43309]
    ---
     value_init_test.cpp | 6 +++++-
     1 file changed, 5 insertions(+), 1 deletion(-)
    
    diff --git a/value_init_test.cpp b/value_init_test.cpp
    index 175d30c..b7dd956 100644
    --- a/value_init_test.cpp
    +++ b/value_init_test.cpp
    @@ -7,7 +7,7 @@
     // Test program for "boost/utility/value_init.hpp"
     //
     // 21 Ago 2002 (Created) Fernando Cacciola
    -// 19 Jan 2008 (Added tests regarding compiler issues and initialized_value) Fernando Cacciola, Niels Dekker
    +// 18 Feb 2008 (Added tests regarding compiler issues and initialized_value) Fernando Cacciola, Niels Dekker
     
     #include   // For memcmp.
     #include 
    @@ -305,6 +305,10 @@ int test_main(int, char **)
       boost::value_initialized valueInitializedArrayOfBytes;
       BOOST_CHECK (std::memcmp(get(valueInitializedArrayOfBytes), zeroInitializedArrayOfBytes, sizeof(ArrayOfBytes)) == 0);
     
    +  boost::value_initialized valueInitializedArrayOfBytes2;
    +  valueInitializedArrayOfBytes2 = valueInitializedArrayOfBytes;
    +  BOOST_CHECK (std::memcmp(get(valueInitializedArrayOfBytes), get(valueInitializedArrayOfBytes2), sizeof(ArrayOfBytes)) == 0);
    +
       boost::value_initialized copyFunctionCallTester1;
       BOOST_CHECK ( ! get(copyFunctionCallTester1).is_copy_constructed);
       BOOST_CHECK ( ! get(copyFunctionCallTester1).is_assignment_called);
    
    From 94865eabe6c79bf92e2dcb93daa57ff29e8cc658 Mon Sep 17 00:00:00 2001
    From: Emil Dotchevski 
    Date: Tue, 4 Mar 2008 01:41:17 +0000
    Subject: [PATCH 056/164] boost exception
    
    [SVN r43485]
    ---
     include/boost/exception.hpp | 13 +++++++++++++
     1 file changed, 13 insertions(+)
     create mode 100644 include/boost/exception.hpp
    
    diff --git a/include/boost/exception.hpp b/include/boost/exception.hpp
    new file mode 100644
    index 0000000..6a49ab8
    --- /dev/null
    +++ b/include/boost/exception.hpp
    @@ -0,0 +1,13 @@
    +//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
    +
    +//Distributed under the Boost Software License, Version 1.0. (See accompanying
    +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
    +
    +#ifndef UUID_1D94A7C6054E11DB9804B622A1EF5492
    +#define UUID_1D94A7C6054E11DB9804B622A1EF5492
    +
    +#include 
    +#include 
    +#include 
    +
    +#endif
    
    From 2412b864d684a713f6d869a0813a01cd7fb68699 Mon Sep 17 00:00:00 2001
    From: John Maddock 
    Date: Sat, 15 Mar 2008 18:41:51 +0000
    Subject: [PATCH 057/164] Fix some inspection report issues.
    
    [SVN r43633]
    ---
     call_traits.htm | 30 ++++++++++--------------------
     enable_if.html  | 19 ++++++++++---------
     index.html      |  5 +++--
     3 files changed, 23 insertions(+), 31 deletions(-)
    
    diff --git a/call_traits.htm b/call_traits.htm
    index 6d9bddf..a69c1de 100644
    --- a/call_traits.htm
    +++ b/call_traits.htm
    @@ -740,26 +740,16 @@ specialisation).

    Revised 01 September 2000

    -

    © Copyright boost.org 2000. Permission to copy, use, modify, -sell and distribute this document is granted provided this -copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with -no claim as to its suitability for any purpose.

    - -

    Based on contributions by Steve Cleary, Beman Dawes, Howard -Hinnant and John Maddock.

    - -

    Maintained by John -Maddock, the latest version of this file can be found at www.boost.org, and the boost -discussion list at www.yahoogroups.com/list/boost.

    - -

    .

    - -

     

    - -

     

    +

    + Copyright 2000 Steve Cleary, Beman Dawes, Howard + Hinnant and John Maddock.
    + Use, modification and distribution are subject to the + Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt + or copy at + http://www.boost.org/LICENSE_1_0.txt + ). +

    diff --git a/enable_if.html b/enable_if.html index 2b6ac0a..a17a290 100644 --- a/enable_if.html +++ b/enable_if.html @@ -366,17 +366,18 @@ David Vandevoorde and Nicolai M. Josuttis. C++ Templates: The Complete Guide. Addison-Wesley, 2002. - - - - -
    - -Contributed by:
    -Jaakko Järvi, Jeremiah Willcock and Andrew Lumsdaine
    +
    +

    Copyright Jaakko Järvi, Jeremiah Willcock and Andrew Lumsdaine
    {jajarvi|jewillco|lums}@osl.iu.edu
    Indiana University
    -Open Systems Lab +Open Systems Lab
    +Use, modification and distribution are subject to the +Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt +or copy at + http://www.boost.org/LICENSE_1_0.txt +). +

    diff --git a/index.html b/index.html index b08822b..7605aef 100644 --- a/index.html +++ b/index.html @@ -21,14 +21,15 @@ compressed_pair
    current_function
    enable_if
    - iterator_adaptors
    + iterator_adaptors
    + generator iterator adaptors
    operators
    throw_exception
    utility
    value_init


    -

    © Copyright Beman Dawes, 2001

    +

    © Copyright Beman Dawes, 2001

    Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at From 96d573d6ca8637f2d28c23baf9caca59b380310a Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Wed, 2 Apr 2008 01:42:32 +0000 Subject: [PATCH 058/164] Replaced all occurrences of non-ASCII copyright symbol with '(c)' for people using non-ASCII code pages [SVN r43992] --- enable_if/test/constructors.cpp | 2 +- enable_if/test/dummy_arg_disambiguation.cpp | 2 +- enable_if/test/lazy.cpp | 2 +- enable_if/test/lazy_test.cpp | 2 +- enable_if/test/member_templates.cpp | 2 +- enable_if/test/namespace_disambiguation.cpp | 2 +- enable_if/test/no_disambiguation.cpp | 2 +- enable_if/test/partial_specializations.cpp | 2 +- include/boost/utility/enable_if.hpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/enable_if/test/constructors.cpp b/enable_if/test/constructors.cpp index 557b2f0..889133d 100644 --- a/enable_if/test/constructors.cpp +++ b/enable_if/test/constructors.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/dummy_arg_disambiguation.cpp b/enable_if/test/dummy_arg_disambiguation.cpp index bb9f733..90275e9 100644 --- a/enable_if/test/dummy_arg_disambiguation.cpp +++ b/enable_if/test/dummy_arg_disambiguation.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/lazy.cpp b/enable_if/test/lazy.cpp index d766fc9..117ec41 100644 --- a/enable_if/test/lazy.cpp +++ b/enable_if/test/lazy.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/lazy_test.cpp b/enable_if/test/lazy_test.cpp index d52d01e..10bb60c 100644 --- a/enable_if/test/lazy_test.cpp +++ b/enable_if/test/lazy_test.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/member_templates.cpp b/enable_if/test/member_templates.cpp index 23dd173..f7c00a0 100644 --- a/enable_if/test/member_templates.cpp +++ b/enable_if/test/member_templates.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/namespace_disambiguation.cpp b/enable_if/test/namespace_disambiguation.cpp index 90a98a1..a53d3a7 100644 --- a/enable_if/test/namespace_disambiguation.cpp +++ b/enable_if/test/namespace_disambiguation.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/no_disambiguation.cpp b/enable_if/test/no_disambiguation.cpp index f4936e8..122d600 100644 --- a/enable_if/test/no_disambiguation.cpp +++ b/enable_if/test/no_disambiguation.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/partial_specializations.cpp b/enable_if/test/partial_specializations.cpp index 3dce799..5c322ae 100644 --- a/enable_if/test/partial_specializations.cpp +++ b/enable_if/test/partial_specializations.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/include/boost/utility/enable_if.hpp b/include/boost/utility/enable_if.hpp index c8b54c4..d77d108 100644 --- a/include/boost/utility/enable_if.hpp +++ b/include/boost/utility/enable_if.hpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at From be50b9550803fe946dbc15d5cedd417259b257e4 Mon Sep 17 00:00:00 2001 From: Daniel Frey Date: Thu, 10 Apr 2008 14:38:14 +0000 Subject: [PATCH 059/164] Added test and fix for "convertible to bool" requirement [SVN r44151] --- include/boost/operators.hpp | 36 ++-- operators_test.cpp | 404 ++++++++++++++++++++---------------- 2 files changed, 243 insertions(+), 197 deletions(-) diff --git a/include/boost/operators.hpp b/include/boost/operators.hpp index b3b1bd7..3443cb5 100644 --- a/include/boost/operators.hpp +++ b/include/boost/operators.hpp @@ -8,6 +8,8 @@ // See http://www.boost.org/libs/utility/operators.htm for documentation. // Revision History +// 03 Apr 08 Make sure "convertible to bool" is sufficient +// for T::operator<, etc. (Daniel Frey) // 24 May 07 Changed empty_base to depend on T, see // http://svn.boost.org/trac/boost/ticket/979 // 21 Oct 02 Modified implementation of operators to allow compilers with a @@ -124,34 +126,34 @@ namespace boost template > struct less_than_comparable2 : B { - friend bool operator<=(const T& x, const U& y) { return !(x > y); } - friend bool operator>=(const T& x, const U& y) { return !(x < y); } + friend bool operator<=(const T& x, const U& y) { return !static_cast(x > y); } + friend bool operator>=(const T& x, const U& y) { return !static_cast(x < y); } friend bool operator>(const U& x, const T& y) { return y < x; } friend bool operator<(const U& x, const T& y) { return y > x; } - friend bool operator<=(const U& x, const T& y) { return !(y < x); } - friend bool operator>=(const U& x, const T& y) { return !(y > x); } + friend bool operator<=(const U& x, const T& y) { return !static_cast(y < x); } + friend bool operator>=(const U& x, const T& y) { return !static_cast(y > x); } }; template > struct less_than_comparable1 : B { friend bool operator>(const T& x, const T& y) { return y < x; } - friend bool operator<=(const T& x, const T& y) { return !(y < x); } - friend bool operator>=(const T& x, const T& y) { return !(x < y); } + friend bool operator<=(const T& x, const T& y) { return !static_cast(y < x); } + friend bool operator>=(const T& x, const T& y) { return !static_cast(x < y); } }; template > struct equality_comparable2 : B { friend bool operator==(const U& y, const T& x) { return x == y; } - friend bool operator!=(const U& y, const T& x) { return !(x == y); } - friend bool operator!=(const T& y, const U& x) { return !(y == x); } + friend bool operator!=(const U& y, const T& x) { return !static_cast(x == y); } + friend bool operator!=(const T& y, const U& x) { return !static_cast(y == x); } }; template > struct equality_comparable1 : B { - friend bool operator!=(const T& x, const T& y) { return !(x == y); } + friend bool operator!=(const T& x, const T& y) { return !static_cast(x == y); } }; // A macro which produces "name_2left" from "name". @@ -356,7 +358,7 @@ struct equivalent2 : B { friend bool operator==(const T& x, const U& y) { - return !(x < y) && !(x > y); + return !static_cast(x < y) && !static_cast(x > y); } }; @@ -365,7 +367,7 @@ struct equivalent1 : B { friend bool operator==(const T&x, const T&y) { - return !(x < y) && !(y < x); + return !static_cast(x < y) && !static_cast(y < x); } }; @@ -373,17 +375,17 @@ template > struct partially_ordered2 : B { friend bool operator<=(const T& x, const U& y) - { return (x < y) || (x == y); } + { return static_cast(x < y) || static_cast(x == y); } friend bool operator>=(const T& x, const U& y) - { return (x > y) || (x == y); } + { return static_cast(x > y) || static_cast(x == y); } friend bool operator>(const U& x, const T& y) { return y < x; } friend bool operator<(const U& x, const T& y) { return y > x; } friend bool operator<=(const U& x, const T& y) - { return (y > x) || (y == x); } + { return static_cast(y > x) || static_cast(y == x); } friend bool operator>=(const U& x, const T& y) - { return (y < x) || (y == x); } + { return static_cast(y < x) || static_cast(y == x); } }; template > @@ -392,9 +394,9 @@ struct partially_ordered1 : B friend bool operator>(const T& x, const T& y) { return y < x; } friend bool operator<=(const T& x, const T& y) - { return (x < y) || (x == y); } + { return static_cast(x < y) || static_cast(x == y); } friend bool operator>=(const T& x, const T& y) - { return (y < x) || (x == y); } + { return static_cast(y < x) || static_cast(x == y); } }; // Combined operator classes (contributed by Daryle Walker) ----------------// diff --git a/operators_test.cpp b/operators_test.cpp index d42cb6a..dd40fbc 100644 --- a/operators_test.cpp +++ b/operators_test.cpp @@ -7,6 +7,7 @@ // See http://www.boost.org/libs/utility for documentation. // Revision History +// 03 Apr 08 Added convertible_to_bool (Daniel Frey) // 01 Oct 01 Added tests for "left" operators // and new grouped operators. (Helmut Zeisel) // 20 May 01 Output progress messages. Added tests for new operator @@ -43,6 +44,23 @@ namespace unsigned char true_value(unsigned char x) { return x; } unsigned short true_value(unsigned short x) { return x; } + // verify the minimum requirements for some operators + class convertible_to_bool + { + private: + bool _value; + + typedef bool convertible_to_bool::*unspecified_bool_type; + + void operator!() const; + + public: + convertible_to_bool( const bool value ) : _value( value ) {} + + operator unspecified_bool_type() const + { return _value ? &convertible_to_bool::_value : 0; } + }; + // The use of operators<> here tended to obscure // interactions with certain compiler bugs template @@ -54,8 +72,10 @@ namespace explicit Wrapped1( T v = T() ) : _value(v) {} T value() const { return _value; } - bool operator<(const Wrapped1& x) const { return _value < x._value; } - bool operator==(const Wrapped1& x) const { return _value == x._value; } + convertible_to_bool operator<(const Wrapped1& x) const + { return _value < x._value; } + convertible_to_bool operator==(const Wrapped1& x) const + { return _value == x._value; } Wrapped1& operator+=(const Wrapped1& x) { _value += x._value; return *this; } @@ -97,8 +117,10 @@ namespace explicit Wrapped2( T v = T() ) : _value(v) {} T value() const { return _value; } - bool operator<(const Wrapped2& x) const { return _value < x._value; } - bool operator==(const Wrapped2& x) const { return _value == x._value; } + convertible_to_bool operator<(const Wrapped2& x) const + { return _value < x._value; } + convertible_to_bool operator==(const Wrapped2& x) const + { return _value == x._value; } Wrapped2& operator+=(const Wrapped2& x) { _value += x._value; return *this; } @@ -123,9 +145,13 @@ namespace Wrapped2& operator++() { ++_value; return *this; } Wrapped2& operator--() { --_value; return *this; } - bool operator<(U u) const { return _value < u; } - bool operator>(U u) const { return _value > u; } - bool operator==(U u) const { return _value == u; } + convertible_to_bool operator<(U u) const + { return _value < u; } + convertible_to_bool operator>(U u) const + { return _value > u; } + convertible_to_bool operator==(U u) const + { return _value == u; } + Wrapped2& operator+=(U u) { _value += u; return *this; } Wrapped2& operator-=(U u) { _value -= u; return *this; } Wrapped2& operator*=(U u) { _value *= u; return *this; } @@ -153,7 +179,8 @@ namespace explicit Wrapped3( T v = T() ) : _value(v) {} T value() const { return _value; } - bool operator<(const Wrapped3& x) const { return _value < x._value; } + convertible_to_bool operator<(const Wrapped3& x) const + { return _value < x._value; } private: T _value; @@ -174,10 +201,13 @@ namespace explicit Wrapped4( T v = T() ) : _value(v) {} T value() const { return _value; } - bool operator<(const Wrapped4& x) const { return _value < x._value; } + convertible_to_bool operator<(const Wrapped4& x) const + { return _value < x._value; } - bool operator<(U u) const { return _value < u; } - bool operator>(U u) const { return _value > u; } + convertible_to_bool operator<(U u) const + { return _value < u; } + convertible_to_bool operator>(U u) const + { return _value > u; } private: T _value; @@ -198,11 +228,18 @@ namespace Wrapped5(U u) : _value(u) {} T value() const { return _value; } - bool operator<(const Wrapped5& x) const { return _value < x._value; } - bool operator<(U u) const { return _value < u; } - bool operator>(U u) const { return _value > u; } - bool operator==(const Wrapped5& u) const { return _value == u._value; } - bool operator==(U u) const { return _value == u; } + + convertible_to_bool operator<(const Wrapped5& x) const + { return _value < x._value; } + convertible_to_bool operator<(U u) const + { return _value < u; } + convertible_to_bool operator>(U u) const + { return _value > u; } + convertible_to_bool operator==(const Wrapped5& u) const + { return _value == u._value; } + convertible_to_bool operator==(U u) const + { return _value == u; } + Wrapped5& operator/=(const Wrapped5& u) { _value /= u._value; return *this;} Wrapped5& operator/=(U u) { _value /= u; return *this;} Wrapped5& operator*=(const Wrapped5& u) { _value *= u._value; return *this;} @@ -231,11 +268,18 @@ namespace Wrapped6(U u) : _value(u) {} T value() const { return _value; } - bool operator<(const Wrapped6& x) const { return _value < x._value; } - bool operator<(U u) const { return _value < u; } - bool operator>(U u) const { return _value > u; } - bool operator==(const Wrapped6& u) const { return _value == u._value; } - bool operator==(U u) const { return _value == u; } + + convertible_to_bool operator<(const Wrapped6& x) const + { return _value < x._value; } + convertible_to_bool operator<(U u) const + { return _value < u; } + convertible_to_bool operator>(U u) const + { return _value > u; } + convertible_to_bool operator==(const Wrapped6& u) const + { return _value == u._value; } + convertible_to_bool operator==(U u) const + { return _value == u; } + Wrapped6& operator%=(const Wrapped6& u) { _value %= u._value; return *this;} Wrapped6& operator%=(U u) { _value %= u; return *this;} Wrapped6& operator/=(const Wrapped6& u) { _value /= u._value; return *this;} @@ -276,10 +320,10 @@ namespace template void test_less_than_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2) { - BOOST_CHECK( (x1 < y1) == (x2 < y2) ); - BOOST_CHECK( (x1 <= y1) == (x2 <= y2) ); - BOOST_CHECK( (x1 >= y1) == (x2 >= y2) ); - BOOST_CHECK( (x1 > y1) == (x2 > y2) ); + BOOST_CHECK( static_cast(x1 < y1) == static_cast(x2 < y2) ); + BOOST_CHECK( static_cast(x1 <= y1) == static_cast(x2 <= y2) ); + BOOST_CHECK( static_cast(x1 >= y1) == static_cast(x2 >= y2) ); + BOOST_CHECK( static_cast(x1 > y1) == static_cast(x2 > y2) ); } template @@ -293,8 +337,8 @@ namespace template void test_equality_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2) { - BOOST_CHECK( (x1 == y1) == (x2 == y2) ); - BOOST_CHECK( (x1 != y1) == (x2 != y2) ); + BOOST_CHECK( static_cast(x1 == y1) == static_cast(x2 == y2) ); + BOOST_CHECK( static_cast(x1 != y1) == static_cast(x2 != y2) ); } template @@ -614,14 +658,14 @@ test_main( int , char * [] ) PRIVATE_EXPR_TEST( (i = i2), (i.value() == 2) ); - BOOST_CHECK( i2 == i ); - BOOST_CHECK( i1 != i2 ); - BOOST_CHECK( i1 < i2 ); - BOOST_CHECK( i1 <= i2 ); - BOOST_CHECK( i <= i2 ); - BOOST_CHECK( i2 > i1 ); - BOOST_CHECK( i2 >= i1 ); - BOOST_CHECK( i2 >= i ); + BOOST_CHECK( static_cast(i2 == i) ); + BOOST_CHECK( static_cast(i1 != i2) ); + BOOST_CHECK( static_cast(i1 < i2) ); + BOOST_CHECK( static_cast(i1 <= i2) ); + BOOST_CHECK( static_cast(i <= i2) ); + BOOST_CHECK( static_cast(i2 > i1) ); + BOOST_CHECK( static_cast(i2 >= i1) ); + BOOST_CHECK( static_cast(i2 >= i) ); PRIVATE_EXPR_TEST( (i = i1 + i2), (i.value() == 3) ); PRIVATE_EXPR_TEST( (i = i + i2), (i.value() == 5) ); @@ -653,78 +697,78 @@ test_main( int , char * [] ) PRIVATE_EXPR_TEST( (j = j2), (j.value() == 2) ); - BOOST_CHECK( j2 == j ); - BOOST_CHECK( 2 == j ); - BOOST_CHECK( j2 == 2 ); - BOOST_CHECK( j == j2 ); - BOOST_CHECK( j1 != j2 ); - BOOST_CHECK( j1 != 2 ); - BOOST_CHECK( 1 != j2 ); - BOOST_CHECK( j1 < j2 ); - BOOST_CHECK( 1 < j2 ); - BOOST_CHECK( j1 < 2 ); - BOOST_CHECK( j1 <= j2 ); - BOOST_CHECK( 1 <= j2 ); - BOOST_CHECK( j1 <= j ); - BOOST_CHECK( j <= j2 ); - BOOST_CHECK( 2 <= j2 ); - BOOST_CHECK( j <= 2 ); - BOOST_CHECK( j2 > j1 ); - BOOST_CHECK( 2 > j1 ); - BOOST_CHECK( j2 > 1 ); - BOOST_CHECK( j2 >= j1 ); - BOOST_CHECK( 2 >= j1 ); - BOOST_CHECK( j2 >= 1 ); - BOOST_CHECK( j2 >= j ); - BOOST_CHECK( 2 >= j ); - BOOST_CHECK( j2 >= 2 ); + BOOST_CHECK( static_cast(j2 == j) ); + BOOST_CHECK( static_cast(2 == j) ); + BOOST_CHECK( static_cast(j2 == 2) ); + BOOST_CHECK( static_cast(j == j2) ); + BOOST_CHECK( static_cast(j1 != j2) ); + BOOST_CHECK( static_cast(j1 != 2) ); + BOOST_CHECK( static_cast(1 != j2) ); + BOOST_CHECK( static_cast(j1 < j2) ); + BOOST_CHECK( static_cast(1 < j2) ); + BOOST_CHECK( static_cast(j1 < 2) ); + BOOST_CHECK( static_cast(j1 <= j2) ); + BOOST_CHECK( static_cast(1 <= j2) ); + BOOST_CHECK( static_cast(j1 <= j) ); + BOOST_CHECK( static_cast(j <= j2) ); + BOOST_CHECK( static_cast(2 <= j2) ); + BOOST_CHECK( static_cast(j <= 2) ); + BOOST_CHECK( static_cast(j2 > j1) ); + BOOST_CHECK( static_cast(2 > j1) ); + BOOST_CHECK( static_cast(j2 > 1) ); + BOOST_CHECK( static_cast(j2 >= j1) ); + BOOST_CHECK( static_cast(2 >= j1) ); + BOOST_CHECK( static_cast(j2 >= 1) ); + BOOST_CHECK( static_cast(j2 >= j) ); + BOOST_CHECK( static_cast(2 >= j) ); + BOOST_CHECK( static_cast(j2 >= 2) ); - BOOST_CHECK( (j1 + 2) == 3 ); - BOOST_CHECK( (1 + j2) == 3 ); + BOOST_CHECK( static_cast((j1 + 2) == 3) ); + BOOST_CHECK( static_cast((1 + j2) == 3) ); PRIVATE_EXPR_TEST( (j = j1 + j2), (j.value() == 3) ); - BOOST_CHECK( (j + 2) == 5 ); - BOOST_CHECK( (3 + j2) == 5 ); + BOOST_CHECK( static_cast((j + 2) == 5) ); + BOOST_CHECK( static_cast((3 + j2) == 5) ); PRIVATE_EXPR_TEST( (j = j + j2), (j.value() == 5) ); - BOOST_CHECK( (j - 1) == 4 ); + BOOST_CHECK( static_cast((j - 1) == 4) ); PRIVATE_EXPR_TEST( (j = j - j1), (j.value() == 4) ); - BOOST_CHECK( (j * 2) == 8 ); - BOOST_CHECK( (4 * j2) == 8 ); + BOOST_CHECK( static_cast((j * 2) == 8) ); + BOOST_CHECK( static_cast((4 * j2) == 8) ); PRIVATE_EXPR_TEST( (j = j * j2), (j.value() == 8) ); - BOOST_CHECK( (j / 2) == 4 ); + BOOST_CHECK( static_cast((j / 2) == 4) ); PRIVATE_EXPR_TEST( (j = j / j2), (j.value() == 4) ); - BOOST_CHECK( (j % 3) == 1 ); + BOOST_CHECK( static_cast((j % 3) == 1) ); PRIVATE_EXPR_TEST( (j = j % ( j - j1 )), (j.value() == 1) ); PRIVATE_EXPR_TEST( (j = j2 + j2), (j.value() == 4) ); - BOOST_CHECK( (1 | j2 | j) == 7 ); - BOOST_CHECK( (j1 | 2 | j) == 7 ); - BOOST_CHECK( (j1 | j2 | 4) == 7 ); + BOOST_CHECK( static_cast((1 | j2 | j) == 7) ); + BOOST_CHECK( static_cast((j1 | 2 | j) == 7) ); + BOOST_CHECK( static_cast((j1 | j2 | 4) == 7) ); PRIVATE_EXPR_TEST( (j = j1 | j2 | j), (j.value() == 7) ); - BOOST_CHECK( (7 & j2) == 2 ); - BOOST_CHECK( (j & 2) == 2 ); + BOOST_CHECK( static_cast((7 & j2) == 2) ); + BOOST_CHECK( static_cast((j & 2) == 2) ); PRIVATE_EXPR_TEST( (j = j & j2), (j.value() == 2) ); PRIVATE_EXPR_TEST( (j = j | j1), (j.value() == 3) ); - BOOST_CHECK( (3 ^ j1) == 2 ); - BOOST_CHECK( (j ^ 1) == 2 ); + BOOST_CHECK( static_cast((3 ^ j1) == 2) ); + BOOST_CHECK( static_cast((j ^ 1) == 2) ); PRIVATE_EXPR_TEST( (j = j ^ j1), (j.value() == 2) ); PRIVATE_EXPR_TEST( (j = ( j + j1 ) * ( j2 | j1 )), (j.value() == 9) ); - BOOST_CHECK( (j1 << 2) == 4 ); - BOOST_CHECK( (j2 << 1) == 4 ); + BOOST_CHECK( static_cast((j1 << 2) == 4) ); + BOOST_CHECK( static_cast((j2 << 1) == 4) ); PRIVATE_EXPR_TEST( (j = j1 << j2), (j.value() == 4) ); - BOOST_CHECK( (j >> 2) == 1 ); - BOOST_CHECK( (j2 >> 1) == 1 ); + BOOST_CHECK( static_cast((j >> 2) == 1) ); + BOOST_CHECK( static_cast((j2 >> 1) == 1) ); PRIVATE_EXPR_TEST( (j = j2 >> j1), (j.value() == 1) ); cout << "Performed tests on MyLong objects.\n"; @@ -741,14 +785,14 @@ test_main( int , char * [] ) PRIVATE_EXPR_TEST( (k = k2), (k.value() == 2) ); - BOOST_CHECK( k2 == k ); - BOOST_CHECK( k1 != k2 ); - BOOST_CHECK( k1 < k2 ); - BOOST_CHECK( k1 <= k2 ); - BOOST_CHECK( k <= k2 ); - BOOST_CHECK( k2 > k1 ); - BOOST_CHECK( k2 >= k1 ); - BOOST_CHECK( k2 >= k ); + BOOST_CHECK( static_cast(k2 == k) ); + BOOST_CHECK( static_cast(k1 != k2) ); + BOOST_CHECK( static_cast(k1 < k2) ); + BOOST_CHECK( static_cast(k1 <= k2) ); + BOOST_CHECK( static_cast(k <= k2) ); + BOOST_CHECK( static_cast(k2 > k1) ); + BOOST_CHECK( static_cast(k2 >= k1) ); + BOOST_CHECK( static_cast(k2 >= k) ); cout << "Performed tests on MyChar objects.\n"; @@ -764,31 +808,31 @@ test_main( int , char * [] ) PRIVATE_EXPR_TEST( (l = l2), (l.value() == 2) ); - BOOST_CHECK( l2 == l ); - BOOST_CHECK( 2 == l ); - BOOST_CHECK( l2 == 2 ); - BOOST_CHECK( l == l2 ); - BOOST_CHECK( l1 != l2 ); - BOOST_CHECK( l1 != 2 ); - BOOST_CHECK( 1 != l2 ); - BOOST_CHECK( l1 < l2 ); - BOOST_CHECK( 1 < l2 ); - BOOST_CHECK( l1 < 2 ); - BOOST_CHECK( l1 <= l2 ); - BOOST_CHECK( 1 <= l2 ); - BOOST_CHECK( l1 <= l ); - BOOST_CHECK( l <= l2 ); - BOOST_CHECK( 2 <= l2 ); - BOOST_CHECK( l <= 2 ); - BOOST_CHECK( l2 > l1 ); - BOOST_CHECK( 2 > l1 ); - BOOST_CHECK( l2 > 1 ); - BOOST_CHECK( l2 >= l1 ); - BOOST_CHECK( 2 >= l1 ); - BOOST_CHECK( l2 >= 1 ); - BOOST_CHECK( l2 >= l ); - BOOST_CHECK( 2 >= l ); - BOOST_CHECK( l2 >= 2 ); + BOOST_CHECK( static_cast(l2 == l) ); + BOOST_CHECK( static_cast(2 == l) ); + BOOST_CHECK( static_cast(l2 == 2) ); + BOOST_CHECK( static_cast(l == l2) ); + BOOST_CHECK( static_cast(l1 != l2) ); + BOOST_CHECK( static_cast(l1 != 2) ); + BOOST_CHECK( static_cast(1 != l2) ); + BOOST_CHECK( static_cast(l1 < l2) ); + BOOST_CHECK( static_cast(1 < l2) ); + BOOST_CHECK( static_cast(l1 < 2) ); + BOOST_CHECK( static_cast(l1 <= l2) ); + BOOST_CHECK( static_cast(1 <= l2) ); + BOOST_CHECK( static_cast(l1 <= l) ); + BOOST_CHECK( static_cast(l <= l2) ); + BOOST_CHECK( static_cast(2 <= l2) ); + BOOST_CHECK( static_cast(l <= 2) ); + BOOST_CHECK( static_cast(l2 > l1) ); + BOOST_CHECK( static_cast(2 > l1) ); + BOOST_CHECK( static_cast(l2 > 1) ); + BOOST_CHECK( static_cast(l2 >= l1) ); + BOOST_CHECK( static_cast(2 >= l1) ); + BOOST_CHECK( static_cast(l2 >= 1) ); + BOOST_CHECK( static_cast(l2 >= l) ); + BOOST_CHECK( static_cast(2 >= l) ); + BOOST_CHECK( static_cast(l2 >= 2) ); cout << "Performed tests on MyShort objects.\n"; @@ -807,37 +851,37 @@ test_main( int , char * [] ) PRIVATE_EXPR_TEST( (di = di2), (di.value() == 2) ); - BOOST_CHECK( di2 == di ); - BOOST_CHECK( 2 == di ); - BOOST_CHECK( di == 2 ); - BOOST_CHECK( di1 < di2 ); - BOOST_CHECK( 1 < di2 ); - BOOST_CHECK( di1 <= di2 ); - BOOST_CHECK( 1 <= di2 ); - BOOST_CHECK( di2 > di1 ); - BOOST_CHECK( di2 > 1 ); - BOOST_CHECK( di2 >= di1 ); - BOOST_CHECK( di2 >= 1 ); - BOOST_CHECK( di1 / di2 == half ); - BOOST_CHECK( di1 / 2 == half ); - BOOST_CHECK( 1 / di2 == half ); - PRIVATE_EXPR_TEST( (tmp=di1), ((tmp/=2) == half) ); - PRIVATE_EXPR_TEST( (tmp=di1), ((tmp/=di2) == half) ); - BOOST_CHECK( di1 * di2 == di2 ); - BOOST_CHECK( di1 * 2 == di2 ); - BOOST_CHECK( 1 * di2 == di2 ); - PRIVATE_EXPR_TEST( (tmp=di1), ((tmp*=2) == di2) ); - PRIVATE_EXPR_TEST( (tmp=di1), ((tmp*=di2) == di2) ); - BOOST_CHECK( di2 - di1 == di1 ); - BOOST_CHECK( di2 - 1 == di1 ); - BOOST_CHECK( 2 - di1 == di1 ); - PRIVATE_EXPR_TEST( (tmp=di2), ((tmp-=1) == di1) ); - PRIVATE_EXPR_TEST( (tmp=di2), ((tmp-=di1) == di1) ); - BOOST_CHECK( di1 + di1 == di2 ); - BOOST_CHECK( di1 + 1 == di2 ); - BOOST_CHECK( 1 + di1 == di2 ); - PRIVATE_EXPR_TEST( (tmp=di1), ((tmp+=1) == di2) ); - PRIVATE_EXPR_TEST( (tmp=di1), ((tmp+=di1) == di2) ); + BOOST_CHECK( static_cast(di2 == di) ); + BOOST_CHECK( static_cast(2 == di) ); + BOOST_CHECK( static_cast(di == 2) ); + BOOST_CHECK( static_cast(di1 < di2) ); + BOOST_CHECK( static_cast(1 < di2) ); + BOOST_CHECK( static_cast(di1 <= di2) ); + BOOST_CHECK( static_cast(1 <= di2) ); + BOOST_CHECK( static_cast(di2 > di1) ); + BOOST_CHECK( static_cast(di2 > 1) ); + BOOST_CHECK( static_cast(di2 >= di1) ); + BOOST_CHECK( static_cast(di2 >= 1) ); + BOOST_CHECK( static_cast(di1 / di2 == half) ); + BOOST_CHECK( static_cast(di1 / 2 == half) ); + BOOST_CHECK( static_cast(1 / di2 == half) ); + PRIVATE_EXPR_TEST( (tmp=di1), static_cast((tmp/=2) == half) ); + PRIVATE_EXPR_TEST( (tmp=di1), static_cast((tmp/=di2) == half) ); + BOOST_CHECK( static_cast(di1 * di2 == di2) ); + BOOST_CHECK( static_cast(di1 * 2 == di2) ); + BOOST_CHECK( static_cast(1 * di2 == di2) ); + PRIVATE_EXPR_TEST( (tmp=di1), static_cast((tmp*=2) == di2) ); + PRIVATE_EXPR_TEST( (tmp=di1), static_cast((tmp*=di2) == di2) ); + BOOST_CHECK( static_cast(di2 - di1 == di1) ); + BOOST_CHECK( static_cast(di2 - 1 == di1) ); + BOOST_CHECK( static_cast(2 - di1 == di1) ); + PRIVATE_EXPR_TEST( (tmp=di2), static_cast((tmp-=1) == di1) ); + PRIVATE_EXPR_TEST( (tmp=di2), static_cast((tmp-=di1) == di1) ); + BOOST_CHECK( static_cast(di1 + di1 == di2) ); + BOOST_CHECK( static_cast(di1 + 1 == di2) ); + BOOST_CHECK( static_cast(1 + di1 == di2) ); + PRIVATE_EXPR_TEST( (tmp=di1), static_cast((tmp+=1) == di2) ); + PRIVATE_EXPR_TEST( (tmp=di1), static_cast((tmp+=di1) == di2) ); cout << "Performed tests on MyDoubleInt objects.\n"; @@ -854,42 +898,42 @@ test_main( int , char * [] ) PRIVATE_EXPR_TEST( (li = li2), (li.value() == 2) ); - BOOST_CHECK( li2 == li ); - BOOST_CHECK( 2 == li ); - BOOST_CHECK( li == 2 ); - BOOST_CHECK( li1 < li2 ); - BOOST_CHECK( 1 < li2 ); - BOOST_CHECK( li1 <= li2 ); - BOOST_CHECK( 1 <= li2 ); - BOOST_CHECK( li2 > li1 ); - BOOST_CHECK( li2 > 1 ); - BOOST_CHECK( li2 >= li1 ); - BOOST_CHECK( li2 >= 1 ); - BOOST_CHECK( li1 % li2 == li1 ); - BOOST_CHECK( li1 % 2 == li1 ); - BOOST_CHECK( 1 % li2 == li1 ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2%=2) == li1) ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2%=li2) == li1) ); - BOOST_CHECK( li1 / li2 == 0 ); - BOOST_CHECK( li1 / 2 == 0 ); - BOOST_CHECK( 1 / li2 == 0 ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2/=2) == 0) ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2/=li2) == 0) ); - BOOST_CHECK( li1 * li2 == li2 ); - BOOST_CHECK( li1 * 2 == li2 ); - BOOST_CHECK( 1 * li2 == li2 ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2*=2) == li2) ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2*=li2) == li2) ); - BOOST_CHECK( li2 - li1 == li1 ); - BOOST_CHECK( li2 - 1 == li1 ); - BOOST_CHECK( 2 - li1 == li1 ); - PRIVATE_EXPR_TEST( (tmp2=li2), ((tmp2-=1) == li1) ); - PRIVATE_EXPR_TEST( (tmp2=li2), ((tmp2-=li1) == li1) ); - BOOST_CHECK( li1 + li1 == li2 ); - BOOST_CHECK( li1 + 1 == li2 ); - BOOST_CHECK( 1 + li1 == li2 ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2+=1) == li2) ); - PRIVATE_EXPR_TEST( (tmp2=li1), ((tmp2+=li1) == li2) ); + BOOST_CHECK( static_cast(li2 == li) ); + BOOST_CHECK( static_cast(2 == li) ); + BOOST_CHECK( static_cast(li == 2) ); + BOOST_CHECK( static_cast(li1 < li2) ); + BOOST_CHECK( static_cast(1 < li2) ); + BOOST_CHECK( static_cast(li1 <= li2) ); + BOOST_CHECK( static_cast(1 <= li2) ); + BOOST_CHECK( static_cast(li2 > li1) ); + BOOST_CHECK( static_cast(li2 > 1) ); + BOOST_CHECK( static_cast(li2 >= li1) ); + BOOST_CHECK( static_cast(li2 >= 1) ); + BOOST_CHECK( static_cast(li1 % li2 == li1) ); + BOOST_CHECK( static_cast(li1 % 2 == li1) ); + BOOST_CHECK( static_cast(1 % li2 == li1) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2%=2) == li1) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2%=li2) == li1) ); + BOOST_CHECK( static_cast(li1 / li2 == 0) ); + BOOST_CHECK( static_cast(li1 / 2 == 0) ); + BOOST_CHECK( static_cast(1 / li2 == 0) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2/=2) == 0) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2/=li2) == 0) ); + BOOST_CHECK( static_cast(li1 * li2 == li2) ); + BOOST_CHECK( static_cast(li1 * 2 == li2) ); + BOOST_CHECK( static_cast(1 * li2 == li2) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2*=2) == li2) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2*=li2) == li2) ); + BOOST_CHECK( static_cast(li2 - li1 == li1) ); + BOOST_CHECK( static_cast(li2 - 1 == li1) ); + BOOST_CHECK( static_cast(2 - li1 == li1) ); + PRIVATE_EXPR_TEST( (tmp2=li2), static_cast((tmp2-=1) == li1) ); + PRIVATE_EXPR_TEST( (tmp2=li2), static_cast((tmp2-=li1) == li1) ); + BOOST_CHECK( static_cast(li1 + li1 == li2) ); + BOOST_CHECK( static_cast(li1 + 1 == li2) ); + BOOST_CHECK( static_cast(1 + li1 == li2) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2+=1) == li2) ); + PRIVATE_EXPR_TEST( (tmp2=li1), static_cast((tmp2+=li1) == li2) ); cout << "Performed tests on MyLongInt objects.\n"; From bafe37fdab1a22f552728f59fc6c00105057ba2f Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 15 Apr 2008 21:13:24 +0000 Subject: [PATCH 060/164] Boost Exception header compilation tests added. [SVN r44442] --- include/boost/exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/exception.hpp b/include/boost/exception.hpp index 6a49ab8..aca1409 100644 --- a/include/boost/exception.hpp +++ b/include/boost/exception.hpp @@ -7,7 +7,7 @@ #define UUID_1D94A7C6054E11DB9804B622A1EF5492 #include -#include +#include #include #endif From a5b85eda07d936b497dd519a8dbfe8339f6d9d2d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 21 Apr 2008 21:42:29 +0000 Subject: [PATCH 061/164] Fix #1846. [SVN r44705] --- include/boost/utility/addressof.hpp | 43 ++++++++++++++++------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index 7629488..8e0a586 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -1,6 +1,7 @@ // Copyright (C) 2002 Brad King (brad.king@kitware.com) // Douglas Gregor (gregod@cs.rpi.edu) -// Peter Dimov +// +// Copyright (C) 2002, 2008 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -14,27 +15,31 @@ # include # include -namespace boost { - -// Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov) - -// VC7 strips const from nested classes unless we add indirection here -# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) - -template struct _addp +namespace boost { - typedef T * type; + +namespace detail +{ + +template struct addressof_impl +{ + static inline T * f( T & v, long ) + { + return reinterpret_cast( + &const_cast(reinterpret_cast(v))); + } + + static inline T * f( T * v, int ) + { + return v; + } }; - -template typename _addp::type -# else -template T* -# endif -addressof(T& v) +} // namespace detail + +template T * addressof( T & v ) { - return reinterpret_cast( - &const_cast(reinterpret_cast(v))); + return boost::detail::addressof_impl::f( v, 0 ); } // Borland doesn't like casting an array reference to a char reference @@ -53,6 +58,6 @@ const T (*addressof(const T (&t)[N]))[N] } # endif -} +} // namespace boost #endif // BOOST_UTILITY_ADDRESSOF_HPP From f1c86c35c43c6a625c2fbd0fe350fec39ab4d829 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 27 Apr 2008 07:39:49 +0000 Subject: [PATCH 062/164] Merge in documentation fixes. Apart from the change to optional's documenation Jamfile, which I included by mistake. Fixes #1659, #1661, #1684, #1685, 1687, #1690, #1801 I wrote about this at: http://lists.boost.org/Archives/boost/2008/04/136405.php Merged revisions 44585-44806 via svnmerge from https://svn.boost.org/svn/boost/branches/doc ........ r44585 | danieljames | 2008-04-19 16:25:27 +0100 (Sat, 19 Apr 2008) | 2 lines Fix broken link to vacpp in bjam docs. Refs #1512 ........ r44586 | danieljames | 2008-04-19 16:27:36 +0100 (Sat, 19 Apr 2008) | 2 lines Fix broken link to bcpp in bjam docs. Refs #1513 ........ r44587 | danieljames | 2008-04-19 16:33:58 +0100 (Sat, 19 Apr 2008) | 2 lines DateTime documentation - Fix a link to the serialization library. Refs #1659 ........ r44588 | danieljames | 2008-04-19 16:35:36 +0100 (Sat, 19 Apr 2008) | 2 lines Fix some links in interprocess & intrusive. Refs #1661 ........ r44589 | danieljames | 2008-04-19 16:37:39 +0100 (Sat, 19 Apr 2008) | 2 lines Fix some links in the python docs. Refs #1684. ........ r44590 | danieljames | 2008-04-19 16:38:29 +0100 (Sat, 19 Apr 2008) | 2 lines Work around a quickbook bug which is affecting the python docs. Refs #1684. ........ r44591 | danieljames | 2008-04-19 16:39:34 +0100 (Sat, 19 Apr 2008) | 2 lines Fix a broken link in the numeric conversion docs. Refs #1685 ........ r44592 | danieljames | 2008-04-19 16:40:45 +0100 (Sat, 19 Apr 2008) | 2 lines Fix some links in the optional docs. Refs #1687 ........ r44593 | danieljames | 2008-04-19 16:42:09 +0100 (Sat, 19 Apr 2008) | 2 lines Fix link to the hash documentation from bimap. Refs #1690 ........ r44599 | danieljames | 2008-04-19 18:07:33 +0100 (Sat, 19 Apr 2008) | 2 lines Fix a typo in the format library. Refs #1801 ........ r44600 | danieljames | 2008-04-19 19:20:59 +0100 (Sat, 19 Apr 2008) | 1 line Initialise svnmerge. ........ r44641 | danieljames | 2008-04-20 18:59:47 +0100 (Sun, 20 Apr 2008) | 2 lines Fix the lincense url in shared container iterator documentation. ........ r44642 | danieljames | 2008-04-20 19:00:00 +0100 (Sun, 20 Apr 2008) | 2 lines Fix image link in the mpi documentation. ........ r44643 | danieljames | 2008-04-20 19:00:11 +0100 (Sun, 20 Apr 2008) | 2 lines Fix a typo in the spirit docs. ........ r44644 | danieljames | 2008-04-20 19:00:23 +0100 (Sun, 20 Apr 2008) | 2 lines Escape the slash so that quickbook doesn't think it the start of an italic section, and mess up the link. Refs #1844 ........ r44647 | danieljames | 2008-04-20 19:39:47 +0100 (Sun, 20 Apr 2008) | 2 lines Fix another typo in spirit docs. ........ [SVN r44807] --- shared_container_iterator.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared_container_iterator.html b/shared_container_iterator.html index dfef648..ed149b5 100644 --- a/shared_container_iterator.html +++ b/shared_container_iterator.html @@ -315,7 +315,7 @@ Last modified: Mon Aug 11 11:27:03 EST 2003

    © Copyright 2003 The Trustees of Indiana University. Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http:www.boost.org/LICENSE_1_0.txt)

    + http://www.boost.org/LICENSE_1_0.txt)

    From ad0bcf4a00670df71a2ed0e10d98a51c954863ea Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 9 May 2008 22:08:46 +0000 Subject: [PATCH 063/164] result_of implementation that makes use of C++0x decltype, from Daniel Walker. Fixes #862. [SVN r45256] --- .../utility/detail/result_of_iterate.hpp | 42 ++++++ include/boost/utility/result_of.hpp | 4 + test/result_of_test.cpp | 127 ++++++++++++++++-- utility.htm | 8 +- 4 files changed, 169 insertions(+), 12 deletions(-) diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index 41616c3..6f1b2b1 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -10,6 +10,46 @@ # error Boost result_of - do not include this file! #endif +#if defined(BOOST_HAS_DECLTYPE) + +// As of N2588, C++0x result_of only supports function call +// expressions of the form f(x). This precludes support for member +// function pointers, which are invoked with expressions of the form +// o->*f(x). This implementation supports both. +template +struct result_of + : mpl::if_< + mpl::or_< is_pointer, is_member_function_pointer > + , detail::result_of_impl< + F, F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false + > + , detail::result_of_decltype_impl< + F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)) + > + >::type +{}; + +namespace detail { + +# define BOOST_RESULT_OF_STATIC_MEMBERS(z, n, _) \ + static T ## n t ## n; \ + /**/ + +template +class result_of_decltype_impl +{ + static F f; + BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_RESULT_OF_STATIC_MEMBERS, _) +public: + typedef decltype(f(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),t))) type; +}; + +} // namespace detail + +#else // defined(BOOST_HAS_DECLTYPE) + // CWPro8 requires an argument in a function type specialization #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0 # define BOOST_RESULT_OF_ARGS void @@ -26,6 +66,8 @@ struct result_of #undef BOOST_RESULT_OF_ARGS +#endif // defined(BOOST_HAS_DECLTYPE) + #if BOOST_PP_ITERATION() >= 1 namespace detail { diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp index a5bac6f..07306d6 100644 --- a/include/boost/utility/result_of.hpp +++ b/include/boost/utility/result_of.hpp @@ -18,6 +18,9 @@ #include #include #include +#include +#include +#include #ifndef BOOST_RESULT_OF_NUM_ARGS # define BOOST_RESULT_OF_NUM_ARGS 10 @@ -33,6 +36,7 @@ namespace detail { BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) template struct result_of_impl; +template struct result_of_decltype_impl; template struct result_of_void_impl diff --git a/test/result_of_test.cpp b/test/result_of_test.cpp index 10f3410..c6e91ea 100644 --- a/test/result_of_test.cpp +++ b/test/result_of_test.cpp @@ -11,35 +11,101 @@ #include #include -struct int_result_type { typedef int result_type; }; +struct int_result_type +{ + typedef int result_type; + result_type operator()(float); +}; struct int_result_of { template struct result { typedef int type; }; + result::type operator()(double); + result::type operator()(double) const; + result::type operator()(); + result::type operator()() volatile; }; -struct int_result_type_and_float_result_of +struct int_result_type_and_float_result_of_and_char_return { typedef int result_type; template struct result { typedef float type; }; + char operator()(char); }; template -struct int_result_type_template { typedef int result_type; }; +struct int_result_type_template +{ + typedef int result_type; + result_type operator()(float); +}; template struct int_result_of_template { template struct result; template struct result { typedef int type; }; + typename result(double)>::type operator()(double); + typename result(double)>::type operator()(double) const; + typename result(double)>::type operator()(); + typename result(double)>::type operator()() volatile; }; template -struct int_result_type_and_float_result_of_template +struct int_result_type_and_float_result_of_and_char_return_template { typedef int result_type; template struct result; template struct result { typedef float type; }; + char operator()(char); +}; + +struct result_of_member_function_template +{ + template struct result; + + template struct result { typedef That type; }; + template typename result::type operator()(T); + + template struct result { typedef const That type; }; + template typename result::type operator()(T) const; + + template struct result { typedef volatile That type; }; + template typename result::type operator()(T) volatile; + + template struct result { typedef const volatile That type; }; + template typename result::type operator()(T) const volatile; + + template struct result { typedef That & type; }; + template typename result::type operator()(T &, T); + + template struct result { typedef That const & type; }; + template typename result::type operator()(T const &, T); + + template struct result { typedef That volatile & type; }; + template typename result::type operator()(T volatile &, T); + + template struct result { typedef That const volatile & type; }; + template typename result::type operator()(T const volatile &, T); +}; + +struct no_result_type_or_result_of +{ + int operator()(double); + short operator()(double) const; + unsigned int operator()(); + unsigned short operator()() volatile; + const unsigned short operator()() const volatile; +}; + +template +struct no_result_type_or_result_of_template +{ + int operator()(double); + short operator()(double) const; + unsigned int operator()(); + unsigned short operator()() volatile; + const unsigned short operator()() const volatile; }; struct X {}; @@ -60,16 +126,37 @@ int main() BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); - BOOST_STATIC_ASSERT((is_same::type, void>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); - BOOST_STATIC_ASSERT((is_same::type, void>::value)); - BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same(float)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); - BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value)); BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); + + // Prior to decltype, result_of could not deduce the return type + // nullary function objects unless they exposed a result_type. +#if defined(BOOST_HAS_DECLTYPE) + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(void)>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(void)>::type, int>::value)); +#else + BOOST_STATIC_ASSERT((is_same::type, void>::value)); + BOOST_STATIC_ASSERT((is_same::type, void>::value)); + BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value)); BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value)); - BOOST_STATIC_ASSERT((is_same(char)>::type, int>::value)); +#endif + + // Prior to decltype, result_of ignored a nested result<> if + // result_type was defined. After decltype, result_of deduces the + // actual return type of the function object, ignoring both + // result<> and result_type. +#if defined(BOOST_HAS_DECLTYPE) + BOOST_STATIC_ASSERT((is_same::type, char>::value)); + BOOST_STATIC_ASSERT((is_same(char)>::type, char>::value)); +#else + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(char)>::type, int>::value)); +#endif + BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); @@ -81,5 +168,27 @@ int main() BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, double>::value)); + BOOST_STATIC_ASSERT((is_same::type, const double>::value)); + BOOST_STATIC_ASSERT((is_same::type, volatile double>::value)); + BOOST_STATIC_ASSERT((is_same::type, const volatile double>::value)); + BOOST_STATIC_ASSERT((is_same::type, int &>::value)); + BOOST_STATIC_ASSERT((is_same::type, int const &>::value)); + BOOST_STATIC_ASSERT((is_same::type, int volatile &>::value)); + BOOST_STATIC_ASSERT((is_same::type, int const volatile &>::value)); + +#if defined(BOOST_HAS_DECLTYPE) + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, unsigned int>::value)); + BOOST_STATIC_ASSERT((is_same::type, short>::value)); + BOOST_STATIC_ASSERT((is_same::type, unsigned short>::value)); + BOOST_STATIC_ASSERT((is_same::type, const unsigned short>::value)); + BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(void)>::type, unsigned int>::value)); + BOOST_STATIC_ASSERT((is_same(double)>::type, short>::value)); + BOOST_STATIC_ASSERT((is_same(void)>::type, unsigned short>::value)); + BOOST_STATIC_ASSERT((is_same(void)>::type, const unsigned short>::value)); +#endif + return 0; } diff --git a/utility.htm b/utility.htm index 9514188..1102d47 100644 --- a/utility.htm +++ b/utility.htm @@ -152,11 +152,13 @@ void f() { ...,tN). The implementation permits the type F to be a function pointer, function reference, member function pointer, or class - type. When F is a class type with a - member type result_type, + type.

    If your compiler does not support + decltype, then when F is a + class type with a member type result_type, result_of<F(T1, T2, ..., TN)> is - F::result_type. Otherwise, + F::result_type. When F + does not contain result_type, result_of<F(T1, T2, ..., TN)> is F::result<F(T1, T2, ..., TN)>::type when From 8efae71f4aa6f6721daa0fc7084869129305463b Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Fri, 23 May 2008 16:46:43 +0000 Subject: [PATCH 064/164] Changed boost::initialized_value from a class to an instance, to make its use more convenient, as discussed with Fernando. [SVN r45685] --- include/boost/utility/value_init.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index 60879cf..67127c0 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -5,7 +5,8 @@ // http://www.boost.org/LICENSE_1_0.txt) // // 21 Ago 2002 (Created) Fernando Cacciola -// 18 Feb 2008 (Worked around compiler bugs, added initialized_value) Fernando Cacciola, Niels Dekker +// 24 Dec 2007 (Refactored and worked around various compiler bugs) Fernando Cacciola, Niels Dekker +// 23 May 2008 (Fixed operator= const issue, added initialized_value) Niels Dekker, Fernando Cacciola // #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP @@ -110,7 +111,7 @@ T& get ( value_initialized& x ) } -class initialized_value +class initialized_value_t { public : @@ -120,6 +121,8 @@ class initialized_value } }; +initialized_value_t const initialized_value = {} ; + } // namespace boost From 67f3ca090aeea6fae4b41aa06c4838e4dca5e131 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Fri, 23 May 2008 16:48:10 +0000 Subject: [PATCH 065/164] Fixed value_init test + doc, according to change of boost::initialized_value, revision [45685] [SVN r45686] --- value_init.htm | 29 +++++++++++++++++------------ value_init_test.cpp | 5 +++-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/value_init.htm b/value_init.htm index c97a0eb..6bbfcbc 100644 --- a/value_init.htm +++ b/value_init.htm @@ -28,12 +28,12 @@

    -
    Types
    +
    Types and objects
    Acknowledgements
    @@ -53,7 +53,7 @@ union and class types. Moreover, value_initialized offers a workaround to various compiler issues regarding value-initialization. -Furthermore a convenience class, initialized_value is provided, +Furthermore, a const object, initialized_value is provided, to avoid repeating the type name when retrieving the value from a value_initialized<T> object.
    @@ -123,12 +123,12 @@ constructed by the following declaration:

    -The convenience class initialized_value +The const object initialized_value allows value-initializing a variable as follows:

    -  T var = initialized_value();
    +  T var = initialized_value ;
     
    -This form of initialization is also very similar to T4 var4 = T4(), +This form of initialization is semantically equivalent to T4 var4 = T4(), but robust against the aforementioned compiler issues.

    @@ -249,7 +249,7 @@ offer a workaround to these issues: value_initialized will now clea its internal data, prior to constructing the object that it contains.

    -

    Types

    +

    Types and objects

    template class value_initialized<T>

    @@ -312,19 +312,22 @@ the wrapped object is always performed with the get() idiom:

    value_initialized<int> x ;
    get(x) = 1 ; // OK

    value_initialized<int const> cx ;
    get(x) = 1 ; // ERROR: Cannot modify a const object

    value_initialized<int> const x_c ;
    get(x_c) = 1 ; // ERROR: Cannot modify a const object

    value_initialized<int const> const cx_c ;
    get(cx_c) = 1 ; // ERROR: Cannot modify a const object
    -

    class initialized_value

    +

    initialized_value

     namespace boost {
    -class initialized_value
    +class initialized_value_t
     {
       public :
         template <class T> operator T() const ;
     };
    +
    +initialized_value_t const initialized_value = {} ;
    +
     } // namespace boost
     
    -The class initialized_value provides a convenient way to get +initialized_value provides a convenient way to get an initialized value: its conversion operator provides an appropriate value-initialized object for any CopyConstructible type. @@ -343,7 +346,7 @@ is rather short now (T), but could of course be more like Namespace::Template<Arg>::Type. Instead, one could use initialized_value as follows:
    -  T var = initialized_value();
    +  T var = initialized_value ;
     

    References

    @@ -368,13 +371,15 @@ Special thanks to Björn Karlsson who carefully edited and completed this do

    value_initialized was reimplemented by Fernando Cacciola and Niels Dekker for Boost release version 1.35 (2008), offering a workaround to various compiler issues.

    +

    initialized_value was written by Niels Dekker, and added to Boost release version 1.36 (2008). +

    Developed by Fernando Cacciola, the latest version of this file can be found at www.boost.org.


    -

    Revised 16 January 2008

    +

    Revised 23 May 2008

    © Copyright Fernando Cacciola, 2002, 2008.

    diff --git a/value_init_test.cpp b/value_init_test.cpp index b7dd956..7b07b22 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -7,7 +7,8 @@ // Test program for "boost/utility/value_init.hpp" // // 21 Ago 2002 (Created) Fernando Cacciola -// 18 Feb 2008 (Added tests regarding compiler issues and initialized_value) Fernando Cacciola, Niels Dekker +// 15 Jan 2008 (Added tests regarding compiler issues) Fernando Cacciola, Niels Dekker +// 23 May 2008 (Added tests regarding initialized_value) Niels Dekker #include // For memcmp. #include @@ -183,7 +184,7 @@ struct CopyFunctionCallTester template void check_initialized_value ( T const& y ) { - T initializedValue = boost::initialized_value() ; + T initializedValue = boost::initialized_value ; BOOST_CHECK ( y == initializedValue ) ; } From 4a564744fe9dcbf87c85c60b89f372de63cc99f3 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 25 Jun 2008 23:27:56 +0000 Subject: [PATCH 066/164] documentation update, added function exception::diagnostic_information, added std::exception to_string overload, removed tabs from source files [SVN r46697] --- include/boost/exception.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/boost/exception.hpp b/include/boost/exception.hpp index aca1409..d805002 100644 --- a/include/boost/exception.hpp +++ b/include/boost/exception.hpp @@ -6,6 +6,12 @@ #ifndef UUID_1D94A7C6054E11DB9804B622A1EF5492 #define UUID_1D94A7C6054E11DB9804B622A1EF5492 +#include +#include +#include +#include +#include +#include #include #include #include From f1ec0c4d04d593a58e95833c13a571e08da3bf5b Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 26 Jun 2008 19:20:56 +0000 Subject: [PATCH 067/164] Fix a character encoding error. [SVN r46740] --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 7605aef..ff22fb4 100644 --- a/index.html +++ b/index.html @@ -29,7 +29,7 @@ value_init


    -

    © Copyright Beman Dawes, 2001

    +

    © Copyright Beman Dawes, 2001

    Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at From 177ee78bbb5e1283f914e77c936ac586a15a5abc Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sat, 28 Jun 2008 13:45:21 +0000 Subject: [PATCH 068/164] =?UTF-8?q?With=20his=20kind=20permission,=20chang?= =?UTF-8?q?e=20Jaakko=20"J=C3=A4rvi"=20to=20"Jarvi"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [SVN r46808] --- enable_if/test/constructors.cpp | 2 +- enable_if/test/dummy_arg_disambiguation.cpp | 2 +- enable_if/test/lazy.cpp | 2 +- enable_if/test/lazy_test.cpp | 2 +- enable_if/test/member_templates.cpp | 2 +- enable_if/test/namespace_disambiguation.cpp | 2 +- enable_if/test/no_disambiguation.cpp | 2 +- enable_if/test/partial_specializations.cpp | 2 +- include/boost/ref.hpp | 2 +- include/boost/utility/enable_if.hpp | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/enable_if/test/constructors.cpp b/enable_if/test/constructors.cpp index 889133d..0d465de 100644 --- a/enable_if/test/constructors.cpp +++ b/enable_if/test/constructors.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/dummy_arg_disambiguation.cpp b/enable_if/test/dummy_arg_disambiguation.cpp index 90275e9..60dfdfd 100644 --- a/enable_if/test/dummy_arg_disambiguation.cpp +++ b/enable_if/test/dummy_arg_disambiguation.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/lazy.cpp b/enable_if/test/lazy.cpp index 117ec41..f04111e 100644 --- a/enable_if/test/lazy.cpp +++ b/enable_if/test/lazy.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/lazy_test.cpp b/enable_if/test/lazy_test.cpp index 10bb60c..9ec5324 100644 --- a/enable_if/test/lazy_test.cpp +++ b/enable_if/test/lazy_test.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/member_templates.cpp b/enable_if/test/member_templates.cpp index f7c00a0..55e2d80 100644 --- a/enable_if/test/member_templates.cpp +++ b/enable_if/test/member_templates.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/namespace_disambiguation.cpp b/enable_if/test/namespace_disambiguation.cpp index a53d3a7..45d4f0a 100644 --- a/enable_if/test/namespace_disambiguation.cpp +++ b/enable_if/test/namespace_disambiguation.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/no_disambiguation.cpp b/enable_if/test/no_disambiguation.cpp index 122d600..e2416ed 100644 --- a/enable_if/test/no_disambiguation.cpp +++ b/enable_if/test/no_disambiguation.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/partial_specializations.cpp b/enable_if/test/partial_specializations.cpp index 5c322ae..1d4db99 100644 --- a/enable_if/test/partial_specializations.cpp +++ b/enable_if/test/partial_specializations.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index ab09ae7..330ca65 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -15,7 +15,7 @@ // // ref.hpp - ref/cref, useful helper functions // -// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2001, 2002 Peter Dimov // Copyright (C) 2002 David Abrahams // diff --git a/include/boost/utility/enable_if.hpp b/include/boost/utility/enable_if.hpp index d77d108..d292c6a 100644 --- a/include/boost/utility/enable_if.hpp +++ b/include/boost/utility/enable_if.hpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) From 3c5c2bc107790c476e4523d3ab9e27173fc24327 Mon Sep 17 00:00:00 2001 From: Joseph Gauterin Date: Sat, 5 Jul 2008 11:16:38 +0000 Subject: [PATCH 069/164] Moved utility\swap to the trunk, as discussed in trac issue #2056. [SVN r47093] --- include/boost/swap.hpp | 12 ++ include/boost/utility/swap.hpp | 51 +++++++++ index.html | 1 + swap.html | 94 +++++++++++++++ swap/test/Jamfile.v2 | 53 +++++++++ swap/test/lib_header_1.cpp | 18 +++ swap/test/lib_header_2.cpp | 20 ++++ swap/test/mixed_headers_1.cpp | 20 ++++ swap/test/mixed_headers_2.cpp | 20 ++++ swap/test/primitive.cpp | 44 +++++++ swap/test/root_header_1.cpp | 18 +++ swap/test/root_header_2.cpp | 20 ++++ swap/test/specialized_in_boost.cpp | 72 ++++++++++++ swap/test/specialized_in_global.cpp | 60 ++++++++++ swap/test/specialized_in_other.cpp | 72 ++++++++++++ swap/test/specialized_in_std.cpp | 70 ++++++++++++ swap/test/swap_arrays.cpp | 78 +++++++++++++ swap/test/swap_test_class.hpp | 171 ++++++++++++++++++++++++++++ 18 files changed, 894 insertions(+) create mode 100644 include/boost/swap.hpp create mode 100644 include/boost/utility/swap.hpp create mode 100644 swap.html create mode 100644 swap/test/Jamfile.v2 create mode 100644 swap/test/lib_header_1.cpp create mode 100644 swap/test/lib_header_2.cpp create mode 100644 swap/test/mixed_headers_1.cpp create mode 100644 swap/test/mixed_headers_2.cpp create mode 100644 swap/test/primitive.cpp create mode 100644 swap/test/root_header_1.cpp create mode 100644 swap/test/root_header_2.cpp create mode 100644 swap/test/specialized_in_boost.cpp create mode 100644 swap/test/specialized_in_global.cpp create mode 100644 swap/test/specialized_in_other.cpp create mode 100644 swap/test/specialized_in_std.cpp create mode 100644 swap/test/swap_arrays.cpp create mode 100644 swap/test/swap_test_class.hpp diff --git a/include/boost/swap.hpp b/include/boost/swap.hpp new file mode 100644 index 0000000..2d8b44c --- /dev/null +++ b/include/boost/swap.hpp @@ -0,0 +1,12 @@ +// Copyright (C) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_SWAP_HPP +#define BOOST_SWAP_HPP + +#include "./utility/swap.hpp" + +#endif diff --git a/include/boost/utility/swap.hpp b/include/boost/utility/swap.hpp new file mode 100644 index 0000000..952adf5 --- /dev/null +++ b/include/boost/utility/swap.hpp @@ -0,0 +1,51 @@ +// Copyright (C) 2007, 2008 Steven Watanabe, Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// For more information, see http://www.boost.org +// +// Update: +// 29 June 2008 (Added support for built-in arrays.) Niels Dekker + + +#ifndef BOOST_UTILITY_SWAP_HPP +#define BOOST_UTILITY_SWAP_HPP + +#include //for std::swap +#include //for std::size_t + +namespace boost_swap_impl +{ + template + void swap_impl(T& left, T& right) + { + using std::swap;//use std::swap if argument dependent lookup fails + swap(left,right); + } + + template + void swap_impl(T (& left)[N], T (& right)[N]) + { + for (std::size_t i = 0; i < N; ++i) + { + ::boost_swap_impl::swap_impl(left[i], right[i]); + } + } +} + +namespace boost +{ + namespace swap_adl_barrier + { + template + void swap(T& left, T& right) + { + ::boost_swap_impl::swap_impl(left, right); + } + } + + using swap_adl_barrier::swap; +} + +#endif diff --git a/index.html b/index.html index ff22fb4..5af6f75 100644 --- a/index.html +++ b/index.html @@ -24,6 +24,7 @@ iterator_adaptors
    generator iterator adaptors
    operators
    + swap
    throw_exception
    utility
    value_init

    diff --git a/swap.html b/swap.html new file mode 100644 index 0000000..e317b11 --- /dev/null +++ b/swap.html @@ -0,0 +1,94 @@ +? + + + + + Boost: Swap Documentation + + + + C++ Boost +

    Swap

    + +

    + template<class T> void swap(T& left, T& right); +

    + + +

    + The template function boost::swap allows the values of two variables to be swapped, using argument dependent lookup to select a specialized swap function if available. If no specialized swap function is available, std::swap is used. +

    + + +

    Rationale

    +

    + The generic std::swap function requires that the elements to be swapped are assignable and copy constructible. It is usually implemented using one copy construction and two assignments - this is often both unnecessarily restrictive and unnecessarily slow. In addition, where the generic swap implementation provides only the basic guarantee, specialized swap functions are often able to provide the no-throw exception guarantee (and it is considered best practice to do so where possible1).

    +

    + The alternative to using argument dependent lookup in this situation is to provide a template specialization of std::swap for every type that requires a specialized swap. Although this is legal C++, no Boost libraries use this method, whereas many Boost libraries provide specialized swap functions in their own namespaces. +

    +

    + boost::swap also supports swapping built-in arrays. Note that std::swap doesn't yet do so, but a request to add an overload of std::swap for built-in arrays has been well-received by the Library Working Group of the C++ Standards Committee2. +

    + + +

    Exception Safety

    +

    + boost::swap provides the same exception guarantee as the underlying swap function used, with one exception; for an array of type T[n], where n > 1 and the underlying swap function for T provides the strong exception guarantee, boost::swap provides only the basic exception guarantee. +

    + + +

    Requirements

    +

    Either:

    +
      +
    • T must be assignable
    • +
    • T must be copy constructible
    • +
    +

    Or:

    +
      +
    • A function with the signature swap(T&,T&) is available via argument dependent lookup
    • +
    +

    Or:

    +
      +
    • A template specialization of std::swap exists for T
    • +
    +

    Or:

    +
      +
    • T is a built-in array of swappable elements
    • +
    + + + +

    Portability

    +

    + Several older compilers do not support argument dependent lookup – on these compilers boost::swap will call std::swap, ignoring any specialized swap functions that could be found as a result of argument dependent lookup. +

    + + +

    Credits

    +
      +
    • + Niels Dekker - for implementing and documenting support for built-in arrays +
    • +
    • + Joseph Gauterin - for the initial idea, implementation, tests, and documentation +
    • +
    • + Steven Wanatabe - for the idea to use a barrier namespace, enabling the function to have the name 'swap' without introducing ambiguity or infinite recursion +
    • +
    + + +
    +

    [1]Scott Meyers, Effective C++ Third Edition, Item 25: "Consider support for a non-throwing swap"

    +

    [2]LWG issue 809 (std::swap should be overloaded for array types)

    + + +
    +

    Revised: 3 July 2008

    +

    + Copyright 2007, 2008 Joseph Gauterin. Use, modification, and distribution are subject to the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.) +

    + + + diff --git a/swap/test/Jamfile.v2 b/swap/test/Jamfile.v2 new file mode 100644 index 0000000..758bdaa --- /dev/null +++ b/swap/test/Jamfile.v2 @@ -0,0 +1,53 @@ +# Copyright (c) 2007, 2008 Joseph Gauterin +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# bring in rules for testing +import testing ; + +test-suite utility/swap + : + [ compile root_header_1.cpp ] + [ compile root_header_2.cpp ] + [ compile lib_header_1.cpp ] + [ compile lib_header_2.cpp ] + [ compile mixed_headers_1.cpp ] + [ compile mixed_headers_2.cpp ] + [ run primitive.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run specialized_in_boost.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run specialized_in_global.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run specialized_in_other.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run specialized_in_std.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/static ] + ; + + +# Copyright (c) 2007, 2008 Joseph Gauterin +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# bring in rules for testing +import testing ; + +test-suite utility/swap + : + [ compile root_header_1.cpp ] + [ compile root_header_2.cpp ] + [ compile lib_header_1.cpp ] + [ compile lib_header_2.cpp ] + [ compile mixed_headers_1.cpp ] + [ compile mixed_headers_2.cpp ] + [ run primitive.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run specialized_in_boost.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run specialized_in_global.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run specialized_in_other.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run specialized_in_std.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/static ] + ; + + + diff --git a/swap/test/lib_header_1.cpp b/swap/test/lib_header_1.cpp new file mode 100644 index 0000000..ea7c99a --- /dev/null +++ b/swap/test/lib_header_1.cpp @@ -0,0 +1,18 @@ +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap header compiles as a standalone translation unit + +#include +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap header compiles as a standalone translation unit + +#include diff --git a/swap/test/lib_header_2.cpp b/swap/test/lib_header_2.cpp new file mode 100644 index 0000000..0c9e409 --- /dev/null +++ b/swap/test/lib_header_2.cpp @@ -0,0 +1,20 @@ +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap header include guards work correctly + +#include +#include +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap header include guards work correctly + +#include +#include diff --git a/swap/test/mixed_headers_1.cpp b/swap/test/mixed_headers_1.cpp new file mode 100644 index 0000000..0c7571e --- /dev/null +++ b/swap/test/mixed_headers_1.cpp @@ -0,0 +1,20 @@ +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap headers work when both are included + +#include +#include +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap headers work when both are included + +#include +#include diff --git a/swap/test/mixed_headers_2.cpp b/swap/test/mixed_headers_2.cpp new file mode 100644 index 0000000..217873a --- /dev/null +++ b/swap/test/mixed_headers_2.cpp @@ -0,0 +1,20 @@ +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap headers work when both are included + +#include +#include +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap headers work when both are included + +#include +#include diff --git a/swap/test/primitive.cpp b/swap/test/primitive.cpp new file mode 100644 index 0000000..76cd7b0 --- /dev/null +++ b/swap/test/primitive.cpp @@ -0,0 +1,44 @@ +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +int test_main(int, char*[]) +{ + int object1 = 1; + int object2 = 2; + + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(object1,2); + BOOST_CHECK_EQUAL(object2,1); + + return 0; +} +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +int test_main(int, char*[]) +{ + int object1 = 1; + int object2 = 2; + + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(object1,2); + BOOST_CHECK_EQUAL(object2,1); + + return 0; +} diff --git a/swap/test/root_header_1.cpp b/swap/test/root_header_1.cpp new file mode 100644 index 0000000..efa0028 --- /dev/null +++ b/swap/test/root_header_1.cpp @@ -0,0 +1,18 @@ +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap header compiles as a standalone translation unit + +#include +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap header compiles as a standalone translation unit + +#include diff --git a/swap/test/root_header_2.cpp b/swap/test/root_header_2.cpp new file mode 100644 index 0000000..d7e00f3 --- /dev/null +++ b/swap/test/root_header_2.cpp @@ -0,0 +1,20 @@ +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap header include guards work correctly + +#include +#include +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap header include guards work correctly + +#include +#include diff --git a/swap/test/specialized_in_boost.cpp b/swap/test/specialized_in_boost.cpp new file mode 100644 index 0000000..bc3840f --- /dev/null +++ b/swap/test/specialized_in_boost.cpp @@ -0,0 +1,72 @@ +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in namespace boost +namespace boost +{ + #include "./swap_test_class.hpp" +} + +//Provide swap function in namespace boost +namespace boost +{ + void swap(swap_test_class& left, swap_test_class& right) + { + left.swap(right); + } +} + +int test_main(int, char*[]) +{ + boost::swap_test_class object1; + boost::swap_test_class object2; + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(boost::swap_test_class::swap_count(),1); + BOOST_CHECK_EQUAL(boost::swap_test_class::copy_count(),0); + + return 0; +} +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in namespace boost +namespace boost +{ + #include "./swap_test_class.hpp" +} + +//Provide swap function in namespace boost +namespace boost +{ + void swap(swap_test_class& left, swap_test_class& right) + { + left.swap(right); + } +} + +int test_main(int, char*[]) +{ + boost::swap_test_class object1; + boost::swap_test_class object2; + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(boost::swap_test_class::swap_count(),1); + BOOST_CHECK_EQUAL(boost::swap_test_class::copy_count(),0); + + return 0; +} diff --git a/swap/test/specialized_in_global.cpp b/swap/test/specialized_in_global.cpp new file mode 100644 index 0000000..7f46187 --- /dev/null +++ b/swap/test/specialized_in_global.cpp @@ -0,0 +1,60 @@ +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in the global namespace +#include "./swap_test_class.hpp" + +//Provide swap function in gloabl namespace +void swap(swap_test_class& left, swap_test_class& right) +{ + left.swap(right); +} + +int test_main(int, char*[]) +{ + swap_test_class object1; + swap_test_class object2; + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1); + BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0); + + return 0; +} +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in the global namespace +#include "./swap_test_class.hpp" + +//Provide swap function in gloabl namespace +void swap(swap_test_class& left, swap_test_class& right) +{ + left.swap(right); +} + +int test_main(int, char*[]) +{ + swap_test_class object1; + swap_test_class object2; + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1); + BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0); + + return 0; +} diff --git a/swap/test/specialized_in_other.cpp b/swap/test/specialized_in_other.cpp new file mode 100644 index 0000000..7dccab4 --- /dev/null +++ b/swap/test/specialized_in_other.cpp @@ -0,0 +1,72 @@ +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in namespace other +namespace other +{ + #include "./swap_test_class.hpp" +} + +//Provide swap function in namespace other +namespace other +{ + void swap(swap_test_class& left, swap_test_class& right) + { + left.swap(right); + } +} + +int test_main(int, char*[]) +{ + other::swap_test_class object1; + other::swap_test_class object2; + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(other::swap_test_class::swap_count(),1); + BOOST_CHECK_EQUAL(other::swap_test_class::copy_count(),0); + + return 0; +} +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in namespace other +namespace other +{ + #include "./swap_test_class.hpp" +} + +//Provide swap function in namespace other +namespace other +{ + void swap(swap_test_class& left, swap_test_class& right) + { + left.swap(right); + } +} + +int test_main(int, char*[]) +{ + other::swap_test_class object1; + other::swap_test_class object2; + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(other::swap_test_class::swap_count(),1); + BOOST_CHECK_EQUAL(other::swap_test_class::copy_count(),0); + + return 0; +} diff --git a/swap/test/specialized_in_std.cpp b/swap/test/specialized_in_std.cpp new file mode 100644 index 0000000..c6effb0 --- /dev/null +++ b/swap/test/specialized_in_std.cpp @@ -0,0 +1,70 @@ +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in the global namespace +#include "./swap_test_class.hpp" + + +//Provide swap function in namespace std +namespace std +{ + template <> + void swap(swap_test_class& left, swap_test_class& right) + { + left.swap(right); + } +} + +int test_main(int, char*[]) +{ + swap_test_class object1; + swap_test_class object2; + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1); + BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0); + + return 0; +} +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in the global namespace +#include "./swap_test_class.hpp" + + +//Provide swap function in namespace std +namespace std +{ + template <> + void swap(swap_test_class& left, swap_test_class& right) + { + left.swap(right); + } +} + +int test_main(int, char*[]) +{ + swap_test_class object1; + swap_test_class object2; + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1); + BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0); + + return 0; +} diff --git a/swap/test/swap_arrays.cpp b/swap/test/swap_arrays.cpp new file mode 100644 index 0000000..f032f5b --- /dev/null +++ b/swap/test/swap_arrays.cpp @@ -0,0 +1,78 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in the global namespace +#include "./swap_test_class.hpp" + + +int test_main(int, char*[]) +{ + const std::size_t dimension = 7; + + swap_test_class array1[dimension]; + swap_test_class array2[dimension]; + boost::swap(array1, array2); + + BOOST_CHECK_EQUAL(swap_test_class::swap_count(), dimension); + BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); + + swap_test_class::reset(); + + const std::size_t firstDimension = 3; + const std::size_t secondDimension = 4; + + swap_test_class two_d_array1[firstDimension][secondDimension]; + swap_test_class two_d_array2[firstDimension][secondDimension]; + boost::swap(two_d_array1, two_d_array1); + + BOOST_CHECK_EQUAL(swap_test_class::swap_count(), firstDimension*secondDimension); + BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); + + return 0; +} +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in the global namespace +#include "./swap_test_class.hpp" + + +int test_main(int, char*[]) +{ + const std::size_t dimension = 7; + + swap_test_class array1[dimension]; + swap_test_class array2[dimension]; + boost::swap(array1, array2); + + BOOST_CHECK_EQUAL(swap_test_class::swap_count(), dimension); + BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); + + swap_test_class::reset(); + + const std::size_t firstDimension = 3; + const std::size_t secondDimension = 4; + + swap_test_class two_d_array1[firstDimension][secondDimension]; + swap_test_class two_d_array2[firstDimension][secondDimension]; + boost::swap(two_d_array1, two_d_array1); + + BOOST_CHECK_EQUAL(swap_test_class::swap_count(), firstDimension*secondDimension); + BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); + + return 0; +} diff --git a/swap/test/swap_test_class.hpp b/swap/test/swap_test_class.hpp new file mode 100644 index 0000000..2b23f20 --- /dev/null +++ b/swap/test/swap_test_class.hpp @@ -0,0 +1,171 @@ +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap header compiles as a standalone translation unit + +#ifndef BOOST_UTILITY_SWAP_TEST_CLASS_HPP +#define BOOST_UTILITY_SWAP_TEST_CLASS_HPP + + +class swap_test_class +{ +public: + swap_test_class() + { + ++constructCount(); + } + + ~swap_test_class() + { + ++destructCount(); + } + + swap_test_class(const swap_test_class&) + { + ++copyCount(); + ++destructCount(); + } + + swap_test_class& operator=(const swap_test_class&) + { + ++copyCount(); + return *this; + } + + void swap(swap_test_class& other) + { + ++swapCount(); + } + + + static unsigned int swap_count(){ return swapCount(); } + static unsigned int copy_count(){ return copyCount(); } + static unsigned int construct_count(){ return constructCount(); } + static unsigned int destruct_count(){ return destructCount(); } + + static void reset() + { + swapCount() = 0; + copyCount() = 0; + constructCount() = 0; + destructCount() = 0; + } + +private: + static unsigned int& swapCount() + { + static unsigned int value = 0; + return value; + } + + static unsigned int& copyCount() + { + static unsigned int value = 0; + return value; + } + + static unsigned int& constructCount() + { + static unsigned int value = 0; + return value; + } + + static unsigned int& destructCount() + { + static unsigned int value = 0; + return value; + } + +}; + +#endif + +// Copyright (c) 2007 Joseph Gauterin +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests that the swap header compiles as a standalone translation unit + +#ifndef BOOST_UTILITY_SWAP_TEST_CLASS_HPP +#define BOOST_UTILITY_SWAP_TEST_CLASS_HPP + + +class swap_test_class +{ +public: + swap_test_class() + { + ++constructCount(); + } + + ~swap_test_class() + { + ++destructCount(); + } + + swap_test_class(const swap_test_class&) + { + ++copyCount(); + ++destructCount(); + } + + swap_test_class& operator=(const swap_test_class&) + { + ++copyCount(); + return *this; + } + + void swap(swap_test_class& other) + { + ++swapCount(); + } + + + static unsigned int swap_count(){ return swapCount(); } + static unsigned int copy_count(){ return copyCount(); } + static unsigned int construct_count(){ return constructCount(); } + static unsigned int destruct_count(){ return destructCount(); } + + static void reset() + { + swapCount() = 0; + copyCount() = 0; + constructCount() = 0; + destructCount() = 0; + } + +private: + static unsigned int& swapCount() + { + static unsigned int value = 0; + return value; + } + + static unsigned int& copyCount() + { + static unsigned int value = 0; + return value; + } + + static unsigned int& constructCount() + { + static unsigned int value = 0; + return value; + } + + static unsigned int& destructCount() + { + static unsigned int value = 0; + return value; + } + +}; + +#endif + + From cce5d77d2bf28740f56c15b2cc5d7d43e72145d8 Mon Sep 17 00:00:00 2001 From: Ronald Garcia Date: Thu, 10 Jul 2008 19:28:49 +0000 Subject: [PATCH 070/164] Added unwrap_ref. [SVN r47295] --- include/boost/ref.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 330ca65..9c996ab 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -173,6 +173,12 @@ class unwrap_reference # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +template inline typename unwrap_reference::type& +unwrap_ref(T& t) +{ + return t; +} + } // namespace boost #endif // #ifndef BOOST_REF_HPP_INCLUDED From 1823481d9610a5922998f2c1abe0823239353f4e Mon Sep 17 00:00:00 2001 From: Ronald Garcia Date: Thu, 10 Jul 2008 19:29:02 +0000 Subject: [PATCH 071/164] Added tests for unwrap_ref. [SVN r47296] --- ref_test.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/ref_test.cpp b/ref_test.cpp index 63fc9e5..93468ee 100644 --- a/ref_test.cpp +++ b/ref_test.cpp @@ -68,11 +68,53 @@ 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 +template +void do_unwrap(T t) { + + /* typename unwrap_reference::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); +} + int test_main(int, char * []) { ref_wrapper::test(1); ref_wrapper::test(1); + unwrap_test(); return 0; } From 0ce3885d59c7ffd129ae36331883f02d9c280068 Mon Sep 17 00:00:00 2001 From: Ronald Garcia Date: Thu, 10 Jul 2008 23:01:26 +0000 Subject: [PATCH 072/164] Added an anonymous unwrapping test. [SVN r47297] --- ref_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ref_test.cpp b/ref_test.cpp index 93468ee..d4237b4 100644 --- a/ref_test.cpp +++ b/ref_test.cpp @@ -109,6 +109,7 @@ void unwrap_test() { do_unwrap(cref(cc)); BOOST_CHECK(cc.count() == 1); + BOOST_CHECK(unwrap_ref(ref(cc)).count() == 1); } int test_main(int, char * []) From 28fff2d8210e3967984511fcfb7f811915e4c907 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 12 Jul 2008 17:56:01 +0000 Subject: [PATCH 073/164] Remove duplicate content. [SVN r47360] --- swap/test/Jamfile.v2 | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/swap/test/Jamfile.v2 b/swap/test/Jamfile.v2 index 758bdaa..a13cbd0 100644 --- a/swap/test/Jamfile.v2 +++ b/swap/test/Jamfile.v2 @@ -22,32 +22,5 @@ test-suite utility/swap [ run specialized_in_std.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/static ] ; - - -# Copyright (c) 2007, 2008 Joseph Gauterin -# -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -# bring in rules for testing -import testing ; - -test-suite utility/swap - : - [ compile root_header_1.cpp ] - [ compile root_header_2.cpp ] - [ compile lib_header_1.cpp ] - [ compile lib_header_2.cpp ] - [ compile mixed_headers_1.cpp ] - [ compile mixed_headers_2.cpp ] - [ run primitive.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run specialized_in_boost.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run specialized_in_global.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run specialized_in_other.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run specialized_in_std.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/static ] - ; - From 6098304ea806deb6d8b5fec14c268050829ffa67 Mon Sep 17 00:00:00 2001 From: Joseph Gauterin Date: Sat, 19 Jul 2008 19:40:12 +0000 Subject: [PATCH 074/164] Corrected duplicated file contents [SVN r47607] --- swap/test/lib_header_1.cpp | 11 +--- swap/test/lib_header_2.cpp | 9 --- swap/test/mixed_headers_1.cpp | 9 --- swap/test/mixed_headers_2.cpp | 8 --- swap/test/primitive.cpp | 21 ------- swap/test/root_header_1.cpp | 8 --- swap/test/root_header_2.cpp | 9 --- swap/test/specialized_in_boost.cpp | 35 ----------- swap/test/specialized_in_global.cpp | 29 --------- swap/test/specialized_in_other.cpp | 35 ----------- swap/test/specialized_in_std.cpp | 34 ----------- swap/test/swap_arrays.cpp | 38 ------------ swap/test/swap_test_class.hpp | 91 +---------------------------- 13 files changed, 3 insertions(+), 334 deletions(-) diff --git a/swap/test/lib_header_1.cpp b/swap/test/lib_header_1.cpp index ea7c99a..d3efc63 100644 --- a/swap/test/lib_header_1.cpp +++ b/swap/test/lib_header_1.cpp @@ -6,13 +6,4 @@ // Tests that the swap header compiles as a standalone translation unit -#include -// Copyright (c) 2007 Joseph Gauterin -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// Tests that the swap header compiles as a standalone translation unit - -#include +#include \ No newline at end of file diff --git a/swap/test/lib_header_2.cpp b/swap/test/lib_header_2.cpp index 0c9e409..e88909d 100644 --- a/swap/test/lib_header_2.cpp +++ b/swap/test/lib_header_2.cpp @@ -8,13 +8,4 @@ #include #include -// Copyright (c) 2007 Joseph Gauterin -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// Tests that the swap header include guards work correctly - -#include -#include diff --git a/swap/test/mixed_headers_1.cpp b/swap/test/mixed_headers_1.cpp index 0c7571e..cdb9fe5 100644 --- a/swap/test/mixed_headers_1.cpp +++ b/swap/test/mixed_headers_1.cpp @@ -8,13 +8,4 @@ #include #include -// Copyright (c) 2007 Joseph Gauterin -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// Tests that the swap headers work when both are included - -#include -#include diff --git a/swap/test/mixed_headers_2.cpp b/swap/test/mixed_headers_2.cpp index 217873a..94e9d87 100644 --- a/swap/test/mixed_headers_2.cpp +++ b/swap/test/mixed_headers_2.cpp @@ -8,13 +8,5 @@ #include #include -// Copyright (c) 2007 Joseph Gauterin -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// Tests that the swap headers work when both are included -#include -#include diff --git a/swap/test/primitive.cpp b/swap/test/primitive.cpp index 76cd7b0..380edb3 100644 --- a/swap/test/primitive.cpp +++ b/swap/test/primitive.cpp @@ -20,25 +20,4 @@ int test_main(int, char*[]) return 0; } -// Copyright (c) 2007 Joseph Gauterin -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#include -#define BOOST_INCLUDE_MAIN -#include - -int test_main(int, char*[]) -{ - int object1 = 1; - int object2 = 2; - - boost::swap(object1,object2); - - BOOST_CHECK_EQUAL(object1,2); - BOOST_CHECK_EQUAL(object2,1); - - return 0; -} diff --git a/swap/test/root_header_1.cpp b/swap/test/root_header_1.cpp index efa0028..575d2cb 100644 --- a/swap/test/root_header_1.cpp +++ b/swap/test/root_header_1.cpp @@ -7,12 +7,4 @@ // Tests that the swap header compiles as a standalone translation unit #include -// Copyright (c) 2007 Joseph Gauterin -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// Tests that the swap header compiles as a standalone translation unit - -#include diff --git a/swap/test/root_header_2.cpp b/swap/test/root_header_2.cpp index d7e00f3..d26b3a6 100644 --- a/swap/test/root_header_2.cpp +++ b/swap/test/root_header_2.cpp @@ -8,13 +8,4 @@ #include #include -// Copyright (c) 2007 Joseph Gauterin -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// Tests that the swap header include guards work correctly - -#include -#include diff --git a/swap/test/specialized_in_boost.cpp b/swap/test/specialized_in_boost.cpp index bc3840f..55ac390 100644 --- a/swap/test/specialized_in_boost.cpp +++ b/swap/test/specialized_in_boost.cpp @@ -34,39 +34,4 @@ int test_main(int, char*[]) return 0; } -// Copyright (c) 2007 Joseph Gauterin -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#include -#define BOOST_INCLUDE_MAIN -#include - -//Put test class in namespace boost -namespace boost -{ - #include "./swap_test_class.hpp" -} - -//Provide swap function in namespace boost -namespace boost -{ - void swap(swap_test_class& left, swap_test_class& right) - { - left.swap(right); - } -} - -int test_main(int, char*[]) -{ - boost::swap_test_class object1; - boost::swap_test_class object2; - boost::swap(object1,object2); - - BOOST_CHECK_EQUAL(boost::swap_test_class::swap_count(),1); - BOOST_CHECK_EQUAL(boost::swap_test_class::copy_count(),0); - - return 0; -} diff --git a/swap/test/specialized_in_global.cpp b/swap/test/specialized_in_global.cpp index 7f46187..f76754f 100644 --- a/swap/test/specialized_in_global.cpp +++ b/swap/test/specialized_in_global.cpp @@ -28,33 +28,4 @@ int test_main(int, char*[]) return 0; } -// Copyright (c) 2007 Joseph Gauterin -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#include -#define BOOST_INCLUDE_MAIN -#include - -//Put test class in the global namespace -#include "./swap_test_class.hpp" - -//Provide swap function in gloabl namespace -void swap(swap_test_class& left, swap_test_class& right) -{ - left.swap(right); -} - -int test_main(int, char*[]) -{ - swap_test_class object1; - swap_test_class object2; - boost::swap(object1,object2); - - BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1); - BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0); - - return 0; -} diff --git a/swap/test/specialized_in_other.cpp b/swap/test/specialized_in_other.cpp index 7dccab4..c3071f5 100644 --- a/swap/test/specialized_in_other.cpp +++ b/swap/test/specialized_in_other.cpp @@ -34,39 +34,4 @@ int test_main(int, char*[]) return 0; } -// Copyright (c) 2007 Joseph Gauterin -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#include -#define BOOST_INCLUDE_MAIN -#include - -//Put test class in namespace other -namespace other -{ - #include "./swap_test_class.hpp" -} - -//Provide swap function in namespace other -namespace other -{ - void swap(swap_test_class& left, swap_test_class& right) - { - left.swap(right); - } -} - -int test_main(int, char*[]) -{ - other::swap_test_class object1; - other::swap_test_class object2; - boost::swap(object1,object2); - - BOOST_CHECK_EQUAL(other::swap_test_class::swap_count(),1); - BOOST_CHECK_EQUAL(other::swap_test_class::copy_count(),0); - - return 0; -} diff --git a/swap/test/specialized_in_std.cpp b/swap/test/specialized_in_std.cpp index c6effb0..641aa82 100644 --- a/swap/test/specialized_in_std.cpp +++ b/swap/test/specialized_in_std.cpp @@ -33,38 +33,4 @@ int test_main(int, char*[]) return 0; } -// Copyright (c) 2007 Joseph Gauterin -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#include -#define BOOST_INCLUDE_MAIN -#include - -//Put test class in the global namespace -#include "./swap_test_class.hpp" - - -//Provide swap function in namespace std -namespace std -{ - template <> - void swap(swap_test_class& left, swap_test_class& right) - { - left.swap(right); - } -} - -int test_main(int, char*[]) -{ - swap_test_class object1; - swap_test_class object2; - boost::swap(object1,object2); - - BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1); - BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0); - - return 0; -} diff --git a/swap/test/swap_arrays.cpp b/swap/test/swap_arrays.cpp index f032f5b..96b7939 100644 --- a/swap/test/swap_arrays.cpp +++ b/swap/test/swap_arrays.cpp @@ -37,42 +37,4 @@ int test_main(int, char*[]) return 0; } -// Copyright (c) 2008 Joseph Gauterin, Niels Dekker -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#include -#define BOOST_INCLUDE_MAIN -#include - -//Put test class in the global namespace -#include "./swap_test_class.hpp" - - -int test_main(int, char*[]) -{ - const std::size_t dimension = 7; - - swap_test_class array1[dimension]; - swap_test_class array2[dimension]; - boost::swap(array1, array2); - - BOOST_CHECK_EQUAL(swap_test_class::swap_count(), dimension); - BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); - - swap_test_class::reset(); - - const std::size_t firstDimension = 3; - const std::size_t secondDimension = 4; - - swap_test_class two_d_array1[firstDimension][secondDimension]; - swap_test_class two_d_array2[firstDimension][secondDimension]; - boost::swap(two_d_array1, two_d_array1); - - BOOST_CHECK_EQUAL(swap_test_class::swap_count(), firstDimension*secondDimension); - BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); - - return 0; -} diff --git a/swap/test/swap_test_class.hpp b/swap/test/swap_test_class.hpp index 2b23f20..aa68444 100644 --- a/swap/test/swap_test_class.hpp +++ b/swap/test/swap_test_class.hpp @@ -1,10 +1,10 @@ -// Copyright (c) 2007 Joseph Gauterin +// Copyright (c) 2007-2008 Joseph Gauterin // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Tests that the swap header compiles as a standalone translation unit +// Tests class used by the Boost.Swap tests #ifndef BOOST_UTILITY_SWAP_TEST_CLASS_HPP #define BOOST_UTILITY_SWAP_TEST_CLASS_HPP @@ -82,90 +82,3 @@ private: }; #endif - -// Copyright (c) 2007 Joseph Gauterin -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// Tests that the swap header compiles as a standalone translation unit - -#ifndef BOOST_UTILITY_SWAP_TEST_CLASS_HPP -#define BOOST_UTILITY_SWAP_TEST_CLASS_HPP - - -class swap_test_class -{ -public: - swap_test_class() - { - ++constructCount(); - } - - ~swap_test_class() - { - ++destructCount(); - } - - swap_test_class(const swap_test_class&) - { - ++copyCount(); - ++destructCount(); - } - - swap_test_class& operator=(const swap_test_class&) - { - ++copyCount(); - return *this; - } - - void swap(swap_test_class& other) - { - ++swapCount(); - } - - - static unsigned int swap_count(){ return swapCount(); } - static unsigned int copy_count(){ return copyCount(); } - static unsigned int construct_count(){ return constructCount(); } - static unsigned int destruct_count(){ return destructCount(); } - - static void reset() - { - swapCount() = 0; - copyCount() = 0; - constructCount() = 0; - destructCount() = 0; - } - -private: - static unsigned int& swapCount() - { - static unsigned int value = 0; - return value; - } - - static unsigned int& copyCount() - { - static unsigned int value = 0; - return value; - } - - static unsigned int& constructCount() - { - static unsigned int value = 0; - return value; - } - - static unsigned int& destructCount() - { - static unsigned int value = 0; - return value; - } - -}; - -#endif - - From ece69925403cc9a6e0a29faf2df2518da47d91f7 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 20 Jul 2008 11:05:49 +0000 Subject: [PATCH 075/164] Fixed silly little bug of mine in swap/test/swap_arrays.cpp [SVN r47626] --- swap/test/swap_arrays.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swap/test/swap_arrays.cpp b/swap/test/swap_arrays.cpp index 96b7939..6689db7 100644 --- a/swap/test/swap_arrays.cpp +++ b/swap/test/swap_arrays.cpp @@ -30,7 +30,7 @@ int test_main(int, char*[]) swap_test_class two_d_array1[firstDimension][secondDimension]; swap_test_class two_d_array2[firstDimension][secondDimension]; - boost::swap(two_d_array1, two_d_array1); + boost::swap(two_d_array1, two_d_array2); BOOST_CHECK_EQUAL(swap_test_class::swap_count(), firstDimension*secondDimension); BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); From 64a0e0cb205cb12abb3f608f31c548706790511a Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 20 Jul 2008 12:13:33 +0000 Subject: [PATCH 076/164] Added swap_test_class swap functions to test/swap_arrays.cpp. My fault, they should have been there already! [SVN r47628] --- swap/test/swap_arrays.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/swap/test/swap_arrays.cpp b/swap/test/swap_arrays.cpp index 6689db7..154ae30 100644 --- a/swap/test/swap_arrays.cpp +++ b/swap/test/swap_arrays.cpp @@ -11,6 +11,25 @@ //Put test class in the global namespace #include "./swap_test_class.hpp" +//Provide swap function in both the namespace of swap_test_class +//(which is the global namespace), and the std namespace. +//It's common to provide a swap function for a class in both +//namespaces. Scott Meyers recommends doing so: Effectice C++, +//Third Edition, item 25, "Consider support for a non-throwing swap". +void swap(swap_test_class& left, swap_test_class& right) +{ + left.swap(right); +} + +namespace std +{ + template <> + void swap(swap_test_class& left, swap_test_class& right) + { + left.swap(right); + } +} + int test_main(int, char*[]) { From 899c92420c526c7ed85bcd8587a0948c955111eb Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 20 Jul 2008 12:18:25 +0000 Subject: [PATCH 077/164] Fixed silly little typo of mine, in test/swap_arrays.cpp [SVN r47629] --- swap/test/swap_arrays.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swap/test/swap_arrays.cpp b/swap/test/swap_arrays.cpp index 154ae30..79c6d68 100644 --- a/swap/test/swap_arrays.cpp +++ b/swap/test/swap_arrays.cpp @@ -14,7 +14,7 @@ //Provide swap function in both the namespace of swap_test_class //(which is the global namespace), and the std namespace. //It's common to provide a swap function for a class in both -//namespaces. Scott Meyers recommends doing so: Effectice C++, +//namespaces. Scott Meyers recommends doing so: Effective C++, //Third Edition, item 25, "Consider support for a non-throwing swap". void swap(swap_test_class& left, swap_test_class& right) { From b311fcefb2478bbe3aea776f9686c188bd053fa9 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Fri, 25 Jul 2008 18:48:09 +0000 Subject: [PATCH 078/164] Added test_adl_barrier to swap/test, as discussed with Joseph Gauterin. [SVN r47808] --- swap/test/Jamfile.v2 | 5 ++--- swap/test/test_adl_barrier.cpp | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 swap/test/test_adl_barrier.cpp diff --git a/swap/test/Jamfile.v2 b/swap/test/Jamfile.v2 index a13cbd0..d648de2 100644 --- a/swap/test/Jamfile.v2 +++ b/swap/test/Jamfile.v2 @@ -20,7 +20,6 @@ test-suite utility/swap [ run specialized_in_global.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run specialized_in_other.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run specialized_in_std.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run test_adl_barrier.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/static ] ; - - diff --git a/swap/test/test_adl_barrier.cpp b/swap/test/test_adl_barrier.cpp new file mode 100644 index 0000000..e30a1b6 --- /dev/null +++ b/swap/test/test_adl_barrier.cpp @@ -0,0 +1,36 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// boost::swap internally does an unqualified function call to swap. +// This could have led to ambiguity or infinite recursion, when the +// objects to be swapped would themselves be from the boost namespace. +// If so, boost::swap itself might be found by argument dependent lookup +// (ADL). The implementation of boost::swap resolves this issue by +// using a barrier namespace. The following test checks this "ADL barrier". + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in namespace boost +namespace boost +{ + #include "./swap_test_class.hpp" +} + + +int test_main(int, char*[]) +{ + boost::swap_test_class object1; + boost::swap_test_class object2; + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(boost::swap_test_class::swap_count(),0); + BOOST_CHECK_EQUAL(boost::swap_test_class::copy_count(),3); + + return 0; +} + From b050431638e51abdcca52f0309cfde1f8c7e96f5 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sat, 26 Jul 2008 17:47:59 +0000 Subject: [PATCH 079/164] Added a newline to swap/test/lib_header_1.cpp, hoping to fix Sun 5.x compile issue, "Error: There is extra text on this line" [SVN r47829] --- swap/test/lib_header_1.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/swap/test/lib_header_1.cpp b/swap/test/lib_header_1.cpp index d3efc63..923dea6 100644 --- a/swap/test/lib_header_1.cpp +++ b/swap/test/lib_header_1.cpp @@ -6,4 +6,5 @@ // Tests that the swap header compiles as a standalone translation unit -#include \ No newline at end of file +#include + From 3fd0ea6e7527118e0ea948b56f54140ed85422ba Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 27 Jul 2008 11:35:33 +0000 Subject: [PATCH 080/164] Added specialized_in_boost_and_other to swap/test, as discussed at "[boost] [swap] End-user allowed to add overloads to boost namespace?", http://lists.boost.org/Archives/boost/2008/07/140327.php [SVN r47839] --- swap/test/Jamfile.v2 | 15 +++--- swap/test/specialized_in_boost_and_other.cpp | 56 ++++++++++++++++++++ 2 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 swap/test/specialized_in_boost_and_other.cpp diff --git a/swap/test/Jamfile.v2 b/swap/test/Jamfile.v2 index d648de2..abce519 100644 --- a/swap/test/Jamfile.v2 +++ b/swap/test/Jamfile.v2 @@ -15,11 +15,12 @@ test-suite utility/swap [ compile lib_header_2.cpp ] [ compile mixed_headers_1.cpp ] [ compile mixed_headers_2.cpp ] - [ run primitive.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run specialized_in_boost.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run specialized_in_global.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run specialized_in_other.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run specialized_in_std.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run test_adl_barrier.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run primitive.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run specialized_in_boost.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run specialized_in_global.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run specialized_in_other.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run specialized_in_std.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run specialized_in_boost_and_other.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run test_adl_barrier.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/static ] ; diff --git a/swap/test/specialized_in_boost_and_other.cpp b/swap/test/specialized_in_boost_and_other.cpp new file mode 100644 index 0000000..fc76251 --- /dev/null +++ b/swap/test/specialized_in_boost_and_other.cpp @@ -0,0 +1,56 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests whether two object in a namespace other than boost are properly +// swapped, when both boost and the other namespace have a custom swap function +// for their class. Note that it shouldn't be necessary for a class in an other +// namespace to have a custom swap function in boost, because the boost::swap +// utility should find the swap function in the other namespace, by argument +// dependent lookup (ADL). Unfortunately ADL isn't fully implemented by some +// specific compilers, including Intel C++ 8.1, MSVC 7.1, and Borland 5.9.3. +// Users of those compilers might consider adding a swap overload to the boost +// namespace. + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in namespace other +namespace other +{ + #include "./swap_test_class.hpp" +} + +//Provide swap function in namespace boost +namespace boost +{ + void swap(::other::swap_test_class& left, ::other::swap_test_class& right) + { + left.swap(right); + } +} + +//Provide swap function in namespace other +namespace other +{ + void swap(swap_test_class& left, swap_test_class& right) + { + left.swap(right); + } +} + +int test_main(int, char*[]) +{ + other::swap_test_class object1; + other::swap_test_class object2; + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(other::swap_test_class::swap_count(),1); + BOOST_CHECK_EQUAL(other::swap_test_class::copy_count(),0); + + return 0; +} + From c286d6222302d99cabfe9cabd87df8ab11e1c124 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 27 Jul 2008 12:46:45 +0000 Subject: [PATCH 081/164] Fixed comment in swap/test/specialized_in_boost_and_other.cpp [SVN r47840] --- swap/test/specialized_in_boost_and_other.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/swap/test/specialized_in_boost_and_other.cpp b/swap/test/specialized_in_boost_and_other.cpp index fc76251..9adc5c0 100644 --- a/swap/test/specialized_in_boost_and_other.cpp +++ b/swap/test/specialized_in_boost_and_other.cpp @@ -4,15 +4,15 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Tests whether two object in a namespace other than boost are properly -// swapped, when both boost and the other namespace have a custom swap function -// for their class. Note that it shouldn't be necessary for a class in an other -// namespace to have a custom swap function in boost, because the boost::swap -// utility should find the swap function in the other namespace, by argument -// dependent lookup (ADL). Unfortunately ADL isn't fully implemented by some -// specific compilers, including Intel C++ 8.1, MSVC 7.1, and Borland 5.9.3. -// Users of those compilers might consider adding a swap overload to the boost -// namespace. +// Tests whether instances of a class from a namespace other than boost are +// properly swapped, when both boost and the other namespace have a custom +// swap function for that class. Note that it shouldn't be necessary for a class +// in an other namespace to have a custom swap function in boost, because the +// boost::swap utility should find the swap function in the other namespace, by +// argument dependent lookup (ADL). Unfortunately ADL isn't fully implemented +// by some specific compiler versions, including Intel C++ 8.1, MSVC 7.1, and +// Borland 5.9.3. Users of those compilers might consider adding a swap overload +// to the boost namespace. #include #define BOOST_INCLUDE_MAIN From d215f2176c21b5e126f1fbeca988ba3de8a2bcfe Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 30 Jul 2008 08:04:34 +0000 Subject: [PATCH 082/164] Applied "swap.hpp.patch" by Steven Watanabe, "Re: [boost] [swap] How to fix ADL barrier for XL, Intel, GCC, Sun and Como?", http://lists.boost.org/Archives/boost/2008/07/140482.php [SVN r47877] --- include/boost/utility/swap.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/utility/swap.hpp b/include/boost/utility/swap.hpp index 952adf5..16750c8 100644 --- a/include/boost/utility/swap.hpp +++ b/include/boost/utility/swap.hpp @@ -38,8 +38,8 @@ namespace boost { namespace swap_adl_barrier { - template - void swap(T& left, T& right) + template + void swap(T1& left, T2& right) { ::boost_swap_impl::swap_impl(left, right); } From 2aa48414c9c9151fdc627b23d14b062d3eade753 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Thu, 31 Jul 2008 20:18:04 +0000 Subject: [PATCH 083/164] Removed swap_adl_barrier namespace, as discussed at "Re: [boost] [swap] How to fix ADL barrier for XL, Intel, GCC, Sun and Como?", http://lists.boost.org/Archives/boost/2008/07/140511.php [SVN r47920] --- include/boost/utility/swap.hpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/include/boost/utility/swap.hpp b/include/boost/utility/swap.hpp index 16750c8..da293ee 100644 --- a/include/boost/utility/swap.hpp +++ b/include/boost/utility/swap.hpp @@ -36,16 +36,11 @@ namespace boost_swap_impl namespace boost { - namespace swap_adl_barrier + template + void swap(T1& left, T2& right) { - template - void swap(T1& left, T2& right) - { - ::boost_swap_impl::swap_impl(left, right); - } + ::boost_swap_impl::swap_impl(left, right); } - - using swap_adl_barrier::swap; } #endif From 1ecf3ceb74980b9a4975edc67fecb1563ac8271c Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sat, 2 Aug 2008 11:41:47 +0000 Subject: [PATCH 084/164] Added swap tests for std types, as discussed at "Re: [boost] [swap] Workaround for ADL failures of MSVC 7.1 and Borland okay?", http://lists.boost.org/Archives/boost/2008/08/140589.php [SVN r47943] --- swap/test/Jamfile.v2 | 7 ++++ swap/test/std_bitset.cpp | 33 ++++++++++++++++++ swap/test/std_dateorder.cpp | 32 ++++++++++++++++++ swap/test/std_string.cpp | 31 +++++++++++++++++ swap/test/std_typeinfo_ptr.cpp | 32 ++++++++++++++++++ swap/test/std_vector_of_boost.cpp | 54 ++++++++++++++++++++++++++++++ swap/test/std_vector_of_global.cpp | 47 ++++++++++++++++++++++++++ swap/test/std_vector_of_other.cpp | 54 ++++++++++++++++++++++++++++++ 8 files changed, 290 insertions(+) create mode 100644 swap/test/std_bitset.cpp create mode 100644 swap/test/std_dateorder.cpp create mode 100644 swap/test/std_string.cpp create mode 100644 swap/test/std_typeinfo_ptr.cpp create mode 100644 swap/test/std_vector_of_boost.cpp create mode 100644 swap/test/std_vector_of_global.cpp create mode 100644 swap/test/std_vector_of_other.cpp diff --git a/swap/test/Jamfile.v2 b/swap/test/Jamfile.v2 index abce519..d08a47a 100644 --- a/swap/test/Jamfile.v2 +++ b/swap/test/Jamfile.v2 @@ -21,6 +21,13 @@ test-suite utility/swap [ run specialized_in_other.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run specialized_in_std.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run specialized_in_boost_and_other.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run std_bitset.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run std_dateorder.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run std_string.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run std_typeinfo_ptr.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run std_vector_of_boost.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run std_vector_of_global.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run std_vector_of_other.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run test_adl_barrier.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/static ] ; diff --git a/swap/test/std_bitset.cpp b/swap/test/std_bitset.cpp new file mode 100644 index 0000000..4b9fbae --- /dev/null +++ b/swap/test/std_bitset.cpp @@ -0,0 +1,33 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests swapping std::bitset objects by means of boost::swap. +// Unlike most other Standard C++ Library template classes, +// std::bitset does not have its own std::swap overload. + +#include +#define BOOST_INCLUDE_MAIN +#include + +#include + +int test_main(int, char*[]) +{ + typedef std::bitset<8> bitset_type; + const bitset_type initial_value1 = 1ul; + const bitset_type initial_value2 = 2ul; + + bitset_type object1 = initial_value1; + bitset_type object2 = initial_value2; + + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(object1,initial_value2); + BOOST_CHECK_EQUAL(object2,initial_value1); + + return 0; +} + diff --git a/swap/test/std_dateorder.cpp b/swap/test/std_dateorder.cpp new file mode 100644 index 0000000..b593f6f --- /dev/null +++ b/swap/test/std_dateorder.cpp @@ -0,0 +1,32 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests swapping std::time_base::dateorder objects by means of boost::swap. +// std::time_base::dateorder is an enumerated type. It does not have an +// std::swap overload or template specialization. + +#include +#define BOOST_INCLUDE_MAIN +#include + +#include + +int test_main(int, char*[]) +{ + const std::time_base::dateorder initial_value1 = std::time_base::dmy; + const std::time_base::dateorder initial_value2 = std::time_base::mdy; + + std::time_base::dateorder object1 = initial_value1; + std::time_base::dateorder object2 = initial_value2; + + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(object1,initial_value2); + BOOST_CHECK_EQUAL(object2,initial_value1); + + return 0; +} + diff --git a/swap/test/std_string.cpp b/swap/test/std_string.cpp new file mode 100644 index 0000000..b7d3d4d --- /dev/null +++ b/swap/test/std_string.cpp @@ -0,0 +1,31 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests swapping std::string objects by means of boost::swap. +// std::string has its own std::swap overload. + +#include +#define BOOST_INCLUDE_MAIN +#include + +#include + +int test_main(int, char*[]) +{ + const std::string initial_value1 = "one"; + const std::string initial_value2 = "two"; + + std::string object1 = initial_value1; + std::string object2 = initial_value2; + + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(object1,initial_value2); + BOOST_CHECK_EQUAL(object2,initial_value1); + + return 0; +} + diff --git a/swap/test/std_typeinfo_ptr.cpp b/swap/test/std_typeinfo_ptr.cpp new file mode 100644 index 0000000..38e293a --- /dev/null +++ b/swap/test/std_typeinfo_ptr.cpp @@ -0,0 +1,32 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests swapping std::type_info pointers by means of boost::swap. +// There is no std::swap overload or template specialization +// for std::type_info pointers. + +#include +#define BOOST_INCLUDE_MAIN +#include + +#include + +int test_main(int, char*[]) +{ + const std::type_info * const initial_value1 = 0; + const std::type_info * const initial_value2 = &typeid(double); + + const std::type_info * ptr1 = initial_value1; + const std::type_info * ptr2 = initial_value2; + + boost::swap(ptr1,ptr2); + + BOOST_CHECK_EQUAL(ptr1,initial_value2); + BOOST_CHECK_EQUAL(ptr2,initial_value1); + + return 0; +} + diff --git a/swap/test/std_vector_of_boost.cpp b/swap/test/std_vector_of_boost.cpp new file mode 100644 index 0000000..f9c3888 --- /dev/null +++ b/swap/test/std_vector_of_boost.cpp @@ -0,0 +1,54 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests swapping std::vector objects by means of boost::swap, +// having boost::swap_test_class as vector element type. + +#include +#define BOOST_INCLUDE_MAIN +#include + +#include + +//Put test class in namespace boost +namespace boost +{ + #include "./swap_test_class.hpp" +} + +//Provide swap function in namespace boost +namespace boost +{ + void swap(swap_test_class& left, swap_test_class& right) + { + left.swap(right); + } +} + +int test_main(int, char*[]) +{ + typedef boost::swap_test_class swap_test_class_type; + typedef std::vector vector_type; + + const vector_type::size_type initial_size1 = 1; + const vector_type::size_type initial_size2 = 2; + + vector_type object1(initial_size1); + vector_type object2(initial_size2); + + swap_test_class_type::reset(); + + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(object1.size(),initial_size2); + BOOST_CHECK_EQUAL(object2.size(),initial_size1); + + BOOST_CHECK_EQUAL(swap_test_class_type::swap_count(),0); + BOOST_CHECK_EQUAL(swap_test_class_type::copy_count(),0); + + return 0; +} + diff --git a/swap/test/std_vector_of_global.cpp b/swap/test/std_vector_of_global.cpp new file mode 100644 index 0000000..ef6b52b --- /dev/null +++ b/swap/test/std_vector_of_global.cpp @@ -0,0 +1,47 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests swapping std::vector objects by means of boost::swap, +// having ::swap_test_class as vector element type. + +#include +#define BOOST_INCLUDE_MAIN +#include + +#include + +//Put test class in the global namespace +#include "./swap_test_class.hpp" + +//Provide swap function in the global namespace +void swap(swap_test_class& left, swap_test_class& right) +{ + left.swap(right); +} + +int test_main(int, char*[]) +{ + typedef std::vector vector_type; + + const vector_type::size_type initial_size1 = 1; + const vector_type::size_type initial_size2 = 2; + + vector_type object1(initial_size1); + vector_type object2(initial_size2); + + swap_test_class::reset(); + + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(object1.size(),initial_size2); + BOOST_CHECK_EQUAL(object2.size(),initial_size1); + + BOOST_CHECK_EQUAL(swap_test_class::swap_count(),0); + BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0); + + return 0; +} + diff --git a/swap/test/std_vector_of_other.cpp b/swap/test/std_vector_of_other.cpp new file mode 100644 index 0000000..3834269 --- /dev/null +++ b/swap/test/std_vector_of_other.cpp @@ -0,0 +1,54 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests swapping std::vector objects by means of boost::swap, +// having other::swap_test_class as vector element type. + +#include +#define BOOST_INCLUDE_MAIN +#include + +#include + +//Put test class in namespace other +namespace other +{ + #include "./swap_test_class.hpp" +} + +//Provide swap function in namespace other +namespace other +{ + void swap(swap_test_class& left, swap_test_class& right) + { + left.swap(right); + } +} + +int test_main(int, char*[]) +{ + typedef other::swap_test_class swap_test_class_type; + typedef std::vector vector_type; + + const vector_type::size_type initial_size1 = 1; + const vector_type::size_type initial_size2 = 2; + + vector_type object1(initial_size1); + vector_type object2(initial_size2); + + swap_test_class_type::reset(); + + boost::swap(object1,object2); + + BOOST_CHECK_EQUAL(object1.size(),initial_size2); + BOOST_CHECK_EQUAL(object2.size(),initial_size1); + + BOOST_CHECK_EQUAL(swap_test_class_type::swap_count(),0); + BOOST_CHECK_EQUAL(swap_test_class_type::copy_count(),0); + + return 0; +} + From 62836f29285d4553a22bafd938e4b88781e8b7e5 Mon Sep 17 00:00:00 2001 From: Joseph Gauterin Date: Mon, 4 Aug 2008 11:21:02 +0000 Subject: [PATCH 085/164] Changed 'using std::swap;' to 'using namesapce std;' in swap_impl function to work around ADL bugs in some compilers. [SVN r47967] --- include/boost/utility/swap.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/utility/swap.hpp b/include/boost/utility/swap.hpp index da293ee..71cc454 100644 --- a/include/boost/utility/swap.hpp +++ b/include/boost/utility/swap.hpp @@ -20,7 +20,7 @@ namespace boost_swap_impl template void swap_impl(T& left, T& right) { - using std::swap;//use std::swap if argument dependent lookup fails + using namespace std;//use std::swap if argument dependent lookup fails swap(left,right); } From 49faf23433c14abdd068e82f21125401ca8c820a Mon Sep 17 00:00:00 2001 From: Joseph Gauterin Date: Mon, 4 Aug 2008 18:16:16 +0000 Subject: [PATCH 086/164] Updated copyright info. [SVN r47971] --- include/boost/utility/swap.hpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/boost/utility/swap.hpp b/include/boost/utility/swap.hpp index 71cc454..f42264c 100644 --- a/include/boost/utility/swap.hpp +++ b/include/boost/utility/swap.hpp @@ -1,12 +1,9 @@ -// Copyright (C) 2007, 2008 Steven Watanabe, Joseph Gauterin +// Copyright (C) 2007, 2008 Steven Watanabe, Joseph Gauterin, Niels Dekker // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // For more information, see http://www.boost.org -// -// Update: -// 29 June 2008 (Added support for built-in arrays.) Niels Dekker #ifndef BOOST_UTILITY_SWAP_HPP From 7019e18149e7df70c6c4e403d6ad648d86b4d810 Mon Sep 17 00:00:00 2001 From: Joseph Gauterin Date: Mon, 4 Aug 2008 18:22:10 +0000 Subject: [PATCH 087/164] Renamed 'test_adl_barrier.cpp' to 'no_ambiguity_in_boost.cpp' and altered comments to reflect new disambiguation technique. [SVN r47972] --- swap/test/Jamfile.v2 | 2 +- .../{test_adl_barrier.cpp => no_ambiguity_in_boost.cpp} | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) rename swap/test/{test_adl_barrier.cpp => no_ambiguity_in_boost.cpp} (84%) diff --git a/swap/test/Jamfile.v2 b/swap/test/Jamfile.v2 index d08a47a..7071837 100644 --- a/swap/test/Jamfile.v2 +++ b/swap/test/Jamfile.v2 @@ -28,6 +28,6 @@ test-suite utility/swap [ run std_vector_of_boost.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run std_vector_of_global.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run std_vector_of_other.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run test_adl_barrier.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run no_ambiguity_in_boost.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/static ] ; diff --git a/swap/test/test_adl_barrier.cpp b/swap/test/no_ambiguity_in_boost.cpp similarity index 84% rename from swap/test/test_adl_barrier.cpp rename to swap/test/no_ambiguity_in_boost.cpp index e30a1b6..17fe9d6 100644 --- a/swap/test/test_adl_barrier.cpp +++ b/swap/test/no_ambiguity_in_boost.cpp @@ -7,9 +7,10 @@ // boost::swap internally does an unqualified function call to swap. // This could have led to ambiguity or infinite recursion, when the // objects to be swapped would themselves be from the boost namespace. -// If so, boost::swap itself might be found by argument dependent lookup -// (ADL). The implementation of boost::swap resolves this issue by -// using a barrier namespace. The following test checks this "ADL barrier". +// If so, boost::swap itself might be found by argument dependent lookup. +// The implementation of boost::swap resolves this issue by giving +// boost::swap two template argumetns, thereby making it less specialized +// than std::swap. #include #define BOOST_INCLUDE_MAIN From 7e3e326faf306478a83045f9803996286e02e596 Mon Sep 17 00:00:00 2001 From: Joseph Gauterin Date: Mon, 4 Aug 2008 18:25:45 +0000 Subject: [PATCH 088/164] Updated documentation to remove references to the 'ADL barrier' [SVN r47973] --- swap.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/swap.html b/swap.html index e317b11..dfe9b84 100644 --- a/swap.html +++ b/swap.html @@ -1,4 +1,4 @@ -? + @@ -73,7 +73,7 @@ Joseph Gauterin - for the initial idea, implementation, tests, and documentation
  • - Steven Wanatabe - for the idea to use a barrier namespace, enabling the function to have the name 'swap' without introducing ambiguity or infinite recursion + Steven Wanatabe - for the idea to make boost::swap less specialized than std::swap, thereby allowing the function to have the name 'swap' without introducing ambiguity
  • @@ -84,7 +84,7 @@
    -

    Revised: 3 July 2008

    +

    Revised: 4 August 2008

    Copyright 2007, 2008 Joseph Gauterin. Use, modification, and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.) From 36899afa3f20c25d4358e79bff13dd1cfffe578a Mon Sep 17 00:00:00 2001 From: Daniel Frey Date: Thu, 7 Aug 2008 20:47:58 +0000 Subject: [PATCH 089/164] added/switched "euclidean" spelling [SVN r48025] --- include/boost/operators.hpp | 33 +++++++++++++++++++++++++++++++- operators.htm | 38 ++++++++++++++++++++++--------------- operators_test.cpp | 4 ++-- 3 files changed, 57 insertions(+), 18 deletions(-) diff --git a/include/boost/operators.hpp b/include/boost/operators.hpp index 3443cb5..4b47ba4 100644 --- a/include/boost/operators.hpp +++ b/include/boost/operators.hpp @@ -8,6 +8,7 @@ // See http://www.boost.org/libs/utility/operators.htm for documentation. // Revision History +// 07 Aug 08 Added "euclidean" spelling. (Daniel Frey) // 03 Apr 08 Make sure "convertible to bool" is sufficient // for T::operator<, etc. (Daniel Frey) // 24 May 07 Changed empty_base to depend on T, see @@ -582,7 +583,35 @@ struct ordered_euclidian_ring_operators1 : totally_ordered1 > {}; - + +template > +struct euclidean_ring_operators2 + : ring_operators2 > > > > {}; + +template > +struct euclidean_ring_operators1 + : ring_operators1 > > {}; + +template > +struct ordered_euclidean_ring_operators2 + : totally_ordered2 > {}; + +template > +struct ordered_euclidean_ring_operators1 + : totally_ordered1 > {}; + template > struct input_iteratable : equality_comparable1 euclidian_ring_operators<T>
    + "euclidean_ring_operators1">euclidean_ring_operators<T>
    - euclidian_ring_operators1<T> + euclidean_ring_operators1<T>

      @@ -1439,9 +1439,9 @@ T operator+( T lhs, const T& rhs ) euclidian_ring_operators<T, + "euclidean_ring_operators2">euclidean_ring_operators<T, U>
      - euclidian_ring_operators2<T, U> + euclidean_ring_operators2<T, U>
        @@ -1464,14 +1464,14 @@ T operator+( T lhs, const T& rhs ) ordered_euclidian_ring_operators<T>
        + "ordered_euclidean_ring_operators1">ordered_euclidean_ring_operators<T>
        - ordered_euclidian_ring_operators1<T> + ordered_euclidean_ring_operators1<T>
        • euclidian_ring_operators<T>
        • + "#euclidean_ring_operators1">euclidean_ring_operators<T>
        • totally_ordered<T>
        • @@ -1481,14 +1481,14 @@ T operator+( T lhs, const T& rhs ) ordered_euclidian_ring_operators<T, + "ordered_euclidean_ring_operators2">ordered_euclidean_ring_operators<T, U>
          - ordered_euclidian_ring_operators2<T, U> + ordered_euclidean_ring_operators2<T, U>
          • euclidian_ring_operators<T, + "#euclidean_ring_operators2">euclidean_ring_operators<T, U>
          • totally_ordered<T, @@ -1498,6 +1498,15 @@ T operator+( T lhs, const T& rhs ) +

            Spelling: euclidean vs. euclidian

            + +

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

            +

            Example Templates

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

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

            Dereference Operators and Iterator Helpers

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


            -

            Revised: 29 Oct 2004

            +

            Revised: 7 Aug 2008

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

            -

            Copyright © Daniel Frey, 2002-2004.

            +

            Copyright © Daniel Frey, 2002-2008.

            Use, modification, and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/operators_test.cpp b/operators_test.cpp index dd40fbc..5b71f3a 100644 --- a/operators_test.cpp +++ b/operators_test.cpp @@ -258,8 +258,8 @@ namespace // U must be convertible to T template class Wrapped6 - : boost::ordered_euclidian_ring_operators2, U> - , boost::ordered_euclidian_ring_operators1 > + : boost::ordered_euclidean_ring_operators2, U> + , boost::ordered_euclidean_ring_operators1 > { public: explicit Wrapped6( T v = T() ) : _value(v) {} From 782c132d99a1e46a5810cda69a7af9050ae14cd3 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 13 Aug 2008 22:00:35 +0000 Subject: [PATCH 090/164] Fix Windows-1252 dash in UTF-8 document. [SVN r48133] --- swap.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swap.html b/swap.html index dfe9b84..2af5a88 100644 --- a/swap.html +++ b/swap.html @@ -60,7 +60,7 @@

            Portability

            - Several older compilers do not support argument dependent lookup – on these compilers boost::swap will call std::swap, ignoring any specialized swap functions that could be found as a result of argument dependent lookup. + Several older compilers do not support argument dependent lookup ‒ on these compilers boost::swap will call std::swap, ignoring any specialized swap functions that could be found as a result of argument dependent lookup.

            From 5c423972440523f505a6f904c42173ff6ff0e92e Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sat, 16 Aug 2008 08:56:19 +0000 Subject: [PATCH 091/164] Added explanatory comments, requested by Isaac Dupree, "Re: [boost] [swap] Renaming boost_swap_impl::swap_impl and/or its namespace?", http://lists.boost.org/Archives/boost/2008/08/141007.php [SVN r48171] --- include/boost/utility/swap.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/boost/utility/swap.hpp b/include/boost/utility/swap.hpp index f42264c..6845e79 100644 --- a/include/boost/utility/swap.hpp +++ b/include/boost/utility/swap.hpp @@ -9,6 +9,18 @@ #ifndef BOOST_UTILITY_SWAP_HPP #define BOOST_UTILITY_SWAP_HPP +// Note: the implementation of this utility contains various workarounds: +// - swap_impl is put outside the boost namespace, to avoid infinite +// recursion (causing stack overflow) when swapping objects of a primitive +// type. +// - swap_impl has a using-directive, rather than a using-declaration, +// because some compilers (including MSVC 7.1, Borland 5.9.3, and +// Intel 8.1) don't do argument-dependent lookup when it has a +// using-declaration instead. +// - boost::swap has two template arguments, instead of one, to +// avoid ambiguity when swapping objects of a Boost type that does +// not have its own boost::swap overload. + #include //for std::swap #include //for std::size_t From 7bfb7c8a6160a43bf9f830395d6fc54b1831d867 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 20 Aug 2008 08:25:23 +0000 Subject: [PATCH 092/164] Added a data member to swap_test_class and made it EqualityComparable, as I mentioned at "Re: [boost] [swap] Renaming boost_swap_impl::swap_impl and/or its namespace?", http://lists.boost.org/Archives/boost/2008/08/141027.php [SVN r48245] --- swap/test/swap_test_class.hpp | 36 ++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/swap/test/swap_test_class.hpp b/swap/test/swap_test_class.hpp index aa68444..8cf1fe9 100644 --- a/swap/test/swap_test_class.hpp +++ b/swap/test/swap_test_class.hpp @@ -12,8 +12,11 @@ class swap_test_class { + int m_data; public: - swap_test_class() + explicit swap_test_class(int arg = 0) + : + m_data(arg) { ++constructCount(); } @@ -23,24 +26,40 @@ public: ++destructCount(); } - swap_test_class(const swap_test_class&) + swap_test_class(const swap_test_class& arg) + : + m_data(arg.m_data) { ++copyCount(); ++destructCount(); } - swap_test_class& operator=(const swap_test_class&) + swap_test_class& operator=(const swap_test_class& arg) { + m_data = arg.m_data; ++copyCount(); return *this; } void swap(swap_test_class& other) { + const int temp = m_data; + m_data = other.m_data; + other.m_data = temp; + ++swapCount(); } + int get_data() const + { + return m_data; + } + void set_data(int arg) + { + m_data = arg; + } + static unsigned int swap_count(){ return swapCount(); } static unsigned int copy_count(){ return copyCount(); } static unsigned int construct_count(){ return constructCount(); } @@ -81,4 +100,15 @@ private: }; + +inline bool operator==(const swap_test_class & lhs, const swap_test_class & rhs) +{ + return lhs.get_data() == rhs.get_data(); +} + +inline bool operator!=(const swap_test_class & lhs, const swap_test_class & rhs) +{ + return !(lhs == rhs); +} + #endif From 2cde009bb1f8ff0c130b30da8157c8012b0eb98a Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 20 Aug 2008 08:28:35 +0000 Subject: [PATCH 093/164] Added extra checks, checking that boost::swap does correctly exchange the values of its arguments, as I mentioned at "Re: [boost] [swap] Renaming boost_swap_impl::swap_impl and/or its namespace?", http://lists.boost.org/Archives/boost/2008/08/141027.php [SVN r48246] --- swap/test/no_ambiguity_in_boost.cpp | 11 +++++++++-- swap/test/specialized_in_boost.cpp | 12 ++++++++++-- swap/test/specialized_in_boost_and_other.cpp | 12 ++++++++++-- swap/test/specialized_in_global.cpp | 12 ++++++++++-- swap/test/specialized_in_other.cpp | 12 ++++++++++-- swap/test/specialized_in_std.cpp | 12 ++++++++++-- swap/test/std_vector_of_boost.cpp | 10 ++++++++-- swap/test/std_vector_of_global.cpp | 10 ++++++++-- swap/test/std_vector_of_other.cpp | 10 ++++++++-- 9 files changed, 83 insertions(+), 18 deletions(-) diff --git a/swap/test/no_ambiguity_in_boost.cpp b/swap/test/no_ambiguity_in_boost.cpp index 17fe9d6..e269252 100644 --- a/swap/test/no_ambiguity_in_boost.cpp +++ b/swap/test/no_ambiguity_in_boost.cpp @@ -25,10 +25,17 @@ namespace boost int test_main(int, char*[]) { - boost::swap_test_class object1; - boost::swap_test_class object2; + const boost::swap_test_class initial_value1(1); + const boost::swap_test_class initial_value2(2); + + boost::swap_test_class object1 = initial_value1; + boost::swap_test_class object2 = initial_value2; + + boost::swap_test_class::reset(); boost::swap(object1,object2); + BOOST_CHECK(object1 == initial_value2); + BOOST_CHECK(object2 == initial_value1); BOOST_CHECK_EQUAL(boost::swap_test_class::swap_count(),0); BOOST_CHECK_EQUAL(boost::swap_test_class::copy_count(),3); diff --git a/swap/test/specialized_in_boost.cpp b/swap/test/specialized_in_boost.cpp index 55ac390..7b3e12e 100644 --- a/swap/test/specialized_in_boost.cpp +++ b/swap/test/specialized_in_boost.cpp @@ -25,10 +25,18 @@ namespace boost int test_main(int, char*[]) { - boost::swap_test_class object1; - boost::swap_test_class object2; + const boost::swap_test_class initial_value1(1); + const boost::swap_test_class initial_value2(2); + + boost::swap_test_class object1 = initial_value1; + boost::swap_test_class object2 = initial_value2; + + boost::swap_test_class::reset(); boost::swap(object1,object2); + BOOST_CHECK(object1 == initial_value2); + BOOST_CHECK(object2 == initial_value1); + BOOST_CHECK_EQUAL(boost::swap_test_class::swap_count(),1); BOOST_CHECK_EQUAL(boost::swap_test_class::copy_count(),0); diff --git a/swap/test/specialized_in_boost_and_other.cpp b/swap/test/specialized_in_boost_and_other.cpp index 9adc5c0..ba6247f 100644 --- a/swap/test/specialized_in_boost_and_other.cpp +++ b/swap/test/specialized_in_boost_and_other.cpp @@ -44,10 +44,18 @@ namespace other int test_main(int, char*[]) { - other::swap_test_class object1; - other::swap_test_class object2; + const other::swap_test_class initial_value1(1); + const other::swap_test_class initial_value2(2); + + other::swap_test_class object1 = initial_value1; + other::swap_test_class object2 = initial_value2; + + other::swap_test_class::reset(); boost::swap(object1,object2); + BOOST_CHECK(object1 == initial_value2); + BOOST_CHECK(object2 == initial_value1); + BOOST_CHECK_EQUAL(other::swap_test_class::swap_count(),1); BOOST_CHECK_EQUAL(other::swap_test_class::copy_count(),0); diff --git a/swap/test/specialized_in_global.cpp b/swap/test/specialized_in_global.cpp index f76754f..0a0a029 100644 --- a/swap/test/specialized_in_global.cpp +++ b/swap/test/specialized_in_global.cpp @@ -19,10 +19,18 @@ void swap(swap_test_class& left, swap_test_class& right) int test_main(int, char*[]) { - swap_test_class object1; - swap_test_class object2; + const swap_test_class initial_value1(1); + const swap_test_class initial_value2(2); + + swap_test_class object1 = initial_value1; + swap_test_class object2 = initial_value2; + + swap_test_class::reset(); boost::swap(object1,object2); + BOOST_CHECK(object1 == initial_value2); + BOOST_CHECK(object2 == initial_value1); + BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1); BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0); diff --git a/swap/test/specialized_in_other.cpp b/swap/test/specialized_in_other.cpp index c3071f5..a39896f 100644 --- a/swap/test/specialized_in_other.cpp +++ b/swap/test/specialized_in_other.cpp @@ -25,10 +25,18 @@ namespace other int test_main(int, char*[]) { - other::swap_test_class object1; - other::swap_test_class object2; + const other::swap_test_class initial_value1(1); + const other::swap_test_class initial_value2(2); + + other::swap_test_class object1 = initial_value1; + other::swap_test_class object2 = initial_value2; + + other::swap_test_class::reset(); boost::swap(object1,object2); + BOOST_CHECK(object1 == initial_value2); + BOOST_CHECK(object2 == initial_value1); + BOOST_CHECK_EQUAL(other::swap_test_class::swap_count(),1); BOOST_CHECK_EQUAL(other::swap_test_class::copy_count(),0); diff --git a/swap/test/specialized_in_std.cpp b/swap/test/specialized_in_std.cpp index 641aa82..e31e850 100644 --- a/swap/test/specialized_in_std.cpp +++ b/swap/test/specialized_in_std.cpp @@ -24,10 +24,18 @@ namespace std int test_main(int, char*[]) { - swap_test_class object1; - swap_test_class object2; + const swap_test_class initial_value1(1); + const swap_test_class initial_value2(2); + + swap_test_class object1 = initial_value1; + swap_test_class object2 = initial_value2; + + swap_test_class::reset(); boost::swap(object1,object2); + BOOST_CHECK(object1 == initial_value2); + BOOST_CHECK(object2 == initial_value1); + BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1); BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0); diff --git a/swap/test/std_vector_of_boost.cpp b/swap/test/std_vector_of_boost.cpp index f9c3888..b0c6355 100644 --- a/swap/test/std_vector_of_boost.cpp +++ b/swap/test/std_vector_of_boost.cpp @@ -36,8 +36,11 @@ int test_main(int, char*[]) const vector_type::size_type initial_size1 = 1; const vector_type::size_type initial_size2 = 2; - vector_type object1(initial_size1); - vector_type object2(initial_size2); + const vector_type initial_value1(initial_size1, swap_test_class_type(1)); + const vector_type initial_value2(initial_size2, swap_test_class_type(2)); + + vector_type object1 = initial_value1; + vector_type object2 = initial_value2; swap_test_class_type::reset(); @@ -46,6 +49,9 @@ int test_main(int, char*[]) BOOST_CHECK_EQUAL(object1.size(),initial_size2); BOOST_CHECK_EQUAL(object2.size(),initial_size1); + BOOST_CHECK(object1 == initial_value2); + BOOST_CHECK(object2 == initial_value1); + BOOST_CHECK_EQUAL(swap_test_class_type::swap_count(),0); BOOST_CHECK_EQUAL(swap_test_class_type::copy_count(),0); diff --git a/swap/test/std_vector_of_global.cpp b/swap/test/std_vector_of_global.cpp index ef6b52b..96a9b6a 100644 --- a/swap/test/std_vector_of_global.cpp +++ b/swap/test/std_vector_of_global.cpp @@ -29,8 +29,11 @@ int test_main(int, char*[]) const vector_type::size_type initial_size1 = 1; const vector_type::size_type initial_size2 = 2; - vector_type object1(initial_size1); - vector_type object2(initial_size2); + const vector_type initial_value1(initial_size1, swap_test_class(1)); + const vector_type initial_value2(initial_size2, swap_test_class(2)); + + vector_type object1 = initial_value1; + vector_type object2 = initial_value2; swap_test_class::reset(); @@ -39,6 +42,9 @@ int test_main(int, char*[]) BOOST_CHECK_EQUAL(object1.size(),initial_size2); BOOST_CHECK_EQUAL(object2.size(),initial_size1); + BOOST_CHECK(object1 == initial_value2); + BOOST_CHECK(object2 == initial_value1); + BOOST_CHECK_EQUAL(swap_test_class::swap_count(),0); BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0); diff --git a/swap/test/std_vector_of_other.cpp b/swap/test/std_vector_of_other.cpp index 3834269..2176f6e 100644 --- a/swap/test/std_vector_of_other.cpp +++ b/swap/test/std_vector_of_other.cpp @@ -36,8 +36,11 @@ int test_main(int, char*[]) const vector_type::size_type initial_size1 = 1; const vector_type::size_type initial_size2 = 2; - vector_type object1(initial_size1); - vector_type object2(initial_size2); + const vector_type initial_value1(initial_size1, swap_test_class_type(1)); + const vector_type initial_value2(initial_size2, swap_test_class_type(2)); + + vector_type object1 = initial_value1; + vector_type object2 = initial_value2; swap_test_class_type::reset(); @@ -46,6 +49,9 @@ int test_main(int, char*[]) BOOST_CHECK_EQUAL(object1.size(),initial_size2); BOOST_CHECK_EQUAL(object2.size(),initial_size1); + BOOST_CHECK(object1 == initial_value2); + BOOST_CHECK(object2 == initial_value1); + BOOST_CHECK_EQUAL(swap_test_class_type::swap_count(),0); BOOST_CHECK_EQUAL(swap_test_class_type::copy_count(),0); From d264005c11db003370eebc48447ce411d85f0e3d Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 20 Aug 2008 08:29:54 +0000 Subject: [PATCH 094/164] Extended swap_arrays test, checking that boost::swap does correctly exchange the values of its arguments. [SVN r48247] --- swap/test/swap_arrays.cpp | 63 ++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/swap/test/swap_arrays.cpp b/swap/test/swap_arrays.cpp index 79c6d68..eeb64bc 100644 --- a/swap/test/swap_arrays.cpp +++ b/swap/test/swap_arrays.cpp @@ -11,6 +11,9 @@ //Put test class in the global namespace #include "./swap_test_class.hpp" +#include //for std::copy and std::equal +#include //for std::size_t + //Provide swap function in both the namespace of swap_test_class //(which is the global namespace), and the std namespace. //It's common to provide a swap function for a class in both @@ -30,29 +33,67 @@ namespace std } } - -int test_main(int, char*[]) +// Tests swapping 1-dimensional arrays. +void test_swapping_1D_arrays() { - const std::size_t dimension = 7; - + const std::size_t dimension = 2; + const swap_test_class initial_array1[dimension] = { swap_test_class(1), swap_test_class(2) }; + const swap_test_class initial_array2[dimension] = { swap_test_class(3), swap_test_class(4) }; + swap_test_class array1[dimension]; swap_test_class array2[dimension]; + + std::copy(initial_array1, initial_array1 + dimension, array1); + std::copy(initial_array2, initial_array2 + dimension, array2); + + swap_test_class::reset(); boost::swap(array1, array2); + BOOST_CHECK(std::equal(array1, array1 + dimension, initial_array2)); + BOOST_CHECK(std::equal(array2, array2 + dimension, initial_array1)); + BOOST_CHECK_EQUAL(swap_test_class::swap_count(), dimension); BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); +} + + +// Tests swapping 2-dimensional arrays. +void test_swapping_2D_arrays() +{ + const std::size_t first_dimension = 3; + const std::size_t second_dimension = 4; + const std::size_t number_of_elements = first_dimension * second_dimension; + + swap_test_class array1[first_dimension][second_dimension]; + swap_test_class array2[first_dimension][second_dimension]; + + swap_test_class* const ptr1 = array1[0]; + swap_test_class* const ptr2 = array2[0]; + + for (std::size_t i = 0; i < number_of_elements; ++i) + { + ptr1[i].set_data( static_cast(i) ); + ptr2[i].set_data( static_cast(i + number_of_elements) ); + } swap_test_class::reset(); + boost::swap(array1, array2); - const std::size_t firstDimension = 3; - const std::size_t secondDimension = 4; + for (std::size_t i = 0; i < number_of_elements; ++i) + { + BOOST_CHECK_EQUAL(ptr1[i].get_data(), static_cast(i + number_of_elements) ); + BOOST_CHECK_EQUAL(ptr2[i].get_data(), static_cast(i) ); + } - swap_test_class two_d_array1[firstDimension][secondDimension]; - swap_test_class two_d_array2[firstDimension][secondDimension]; - boost::swap(two_d_array1, two_d_array2); - - BOOST_CHECK_EQUAL(swap_test_class::swap_count(), firstDimension*secondDimension); + BOOST_CHECK_EQUAL(swap_test_class::swap_count(), number_of_elements); BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); +} + + +int test_main(int, char*[]) +{ + test_swapping_1D_arrays(); + test_swapping_2D_arrays(); return 0; } From 55f303baec75c102eefeb8dfe2c395971d372c9d Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Thu, 28 Aug 2008 18:37:45 +0000 Subject: [PATCH 095/164] Added value_initialized::swap according to ticket #2243, as agreed with Fernando Cacciola :-) [SVN r48424] --- include/boost/utility/value_init.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index 67127c0..aa7ecb4 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -7,6 +7,7 @@ // 21 Ago 2002 (Created) Fernando Cacciola // 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 +// 21 Ago 2008 (Added swap) Niels Dekker, Fernando Cacciola // #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP @@ -22,6 +23,7 @@ #include #include #include +#include #include #include @@ -93,6 +95,11 @@ class value_initialized return wrapper_address()->data; } + void swap(value_initialized & arg) + { + ::boost::swap( this->data(), arg.data() ); + } + operator T&() const { return this->data(); } } ; @@ -110,6 +117,12 @@ T& get ( value_initialized& x ) return x.data() ; } +template +void swap ( value_initialized & lhs, value_initialized & rhs ) +{ + lhs.swap(rhs) ; +} + class initialized_value_t { From 6b6e1c3252e018d13e51ef57d7a597bcd7b7ce3f Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Thu, 28 Aug 2008 19:00:20 +0000 Subject: [PATCH 096/164] Added value_initialized::swap documentation + test [SVN r48425] --- value_init.htm | 8 ++++++-- value_init_test.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/value_init.htm b/value_init.htm index 6bbfcbc..5c1b20e 100644 --- a/value_init.htm +++ b/value_init.htm @@ -253,7 +253,7 @@ its internal data, prior to constructing the object that it contains.

            template class value_initialized<T>

            -
            namespace boost {

            template<class T>
            class value_initialized
            {
            public :
            value_initialized() : x() {}
            operator T&() const { return x ; }
            T& data() const { return x ; }

            private :
            unspecified x ;
            } ;

            template<class T>
            T const& get ( value_initialized<T> const& x )
            {
            return x.data() ;
            }

            template<class T>
            T& get ( value_initialized<T>& x )
            {
            return x.data() ;
            }

            } // namespace boost
            +
            namespace boost {

            template<class T>
            class value_initialized
            {
            public :
            value_initialized() : x() {}
            operator T&() const { return x ; }
            T& data() const { return x ; }
            void swap( value_initialized<T>& );

            private :
            unspecified x ;
            } ;

            template<class T>
            T const& get ( value_initialized<T> const& x )
            {
            return x.data() ;
            }

            template<class T>
            T& get ( value_initialized<T>& x )
            {
            return x.data() ;
            }

            } // namespace boost

            An object of this template class is a T-wrapper convertible to 'T&' whose wrapped object (data member of type T) @@ -276,6 +276,10 @@ non-member function get():

            Both const and non-const objects can be wrapped. Mutable objects can be modified directly from within the wrapper but constant objects cannot:

            + +

            When T is a Swappable type, value_initialized<T> + is swappable as well, by calling its swap member function + as well as by calling boost::swap.

            value_initialized<int> x ; 
            static_cast<int&>(x) = 1 ; // OK
            get(x) = 1 ; // OK

            value_initialized<int const> y ;
            static_cast<int&>(y) = 1 ; // ERROR: cannot cast to int&
            static_cast<int const&>(y) = 1 ; // ERROR: cannot modify a const value
            get(y) = 1 ; // ERROR: cannot modify a const value
            @@ -379,7 +383,7 @@ for Boost release version 1.35 (2008), offering a workaround to various compiler


            -

            Revised 23 May 2008

            +

            Revised 28 August 2008

            © Copyright Fernando Cacciola, 2002, 2008.

            diff --git a/value_init_test.cpp b/value_init_test.cpp index 7b07b22..63f324d 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -9,6 +9,7 @@ // 21 Ago 2002 (Created) Fernando Cacciola // 15 Jan 2008 (Added tests regarding compiler issues) Fernando Cacciola, Niels Dekker // 23 May 2008 (Added tests regarding initialized_value) Niels Dekker +// 21 Ago 2008 (Added swap test) Niels Dekker #include // For memcmp. #include @@ -181,6 +182,35 @@ 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 void check_initialized_value ( T const& y ) { @@ -323,9 +353,20 @@ int test_main(int, char **) BOOST_CHECK ( ! get(copyFunctionCallTester3).is_copy_constructed); BOOST_CHECK ( get(copyFunctionCallTester3).is_assignment_called); + boost::value_initialized swapFunctionCallTester1; + boost::value_initialized 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; } unsigned int expected_failures = 0; + From 7f2348269bfff8389c99d45d3ac13a3c31bec858 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 28 Aug 2008 23:49:55 +0000 Subject: [PATCH 097/164] Boost Exception now works with BOOST_NO_RTTI and/or BOOST_NO_TYPEID. [SVN r48429] --- include/boost/exception.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/exception.hpp b/include/boost/exception.hpp index d805002..e2cbd7b 100644 --- a/include/boost/exception.hpp +++ b/include/boost/exception.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include From 2077d0daceab0b3c41541b197bad5fe8823c9eb7 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sun, 31 Aug 2008 02:40:42 +0000 Subject: [PATCH 098/164] simplified further [SVN r48485] --- include/boost/exception.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/boost/exception.hpp b/include/boost/exception.hpp index e2cbd7b..7930cdd 100644 --- a/include/boost/exception.hpp +++ b/include/boost/exception.hpp @@ -7,8 +7,6 @@ #define UUID_1D94A7C6054E11DB9804B622A1EF5492 #include -#include -#include #include #include #include From 9f08ed6de0a9e17440bfc5867a6caaf5470f5d77 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 2 Sep 2008 21:25:47 +0000 Subject: [PATCH 099/164] minor change in boost/exception.hpp [SVN r48546] --- include/boost/exception.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/boost/exception.hpp b/include/boost/exception.hpp index 7930cdd..c77f215 100644 --- a/include/boost/exception.hpp +++ b/include/boost/exception.hpp @@ -13,6 +13,5 @@ #include #include #include -#include #endif From a487f72329b69933b43d2890285536b12a8a9b29 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 5 Sep 2008 19:58:30 +0000 Subject: [PATCH 100/164] Fix result_of to work with const-qualified function pointers. Fixes #1310 [SVN r48620] --- include/boost/utility/detail/result_of_iterate.hpp | 14 ++++++++++++-- include/boost/utility/result_of.hpp | 6 ++++++ test/result_of_test.cpp | 4 ++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index 6f1b2b1..8de00b4 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -22,7 +22,8 @@ struct result_of : mpl::if_< mpl::or_< is_pointer, is_member_function_pointer > , detail::result_of_impl< - F, F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false + typename remove_cv::type, + typename remove_cv::type(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false > , detail::result_of_decltype_impl< F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)) @@ -61,7 +62,16 @@ public: template struct result_of - : boost::detail::result_of_impl::value)> {}; + : mpl::if_< + mpl::or_< is_pointer, is_member_function_pointer > + , boost::detail::result_of_impl< + typename remove_cv::type, + typename remove_cv::type(BOOST_RESULT_OF_ARGS), + (boost::detail::has_result_type::value)> + , boost::detail::result_of_impl< + F, + F(BOOST_RESULT_OF_ARGS), + (boost::detail::has_result_type::value)> >::type { }; #endif #undef BOOST_RESULT_OF_ARGS diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp index 07306d6..d8baa3e 100644 --- a/include/boost/utility/result_of.hpp +++ b/include/boost/utility/result_of.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #ifndef BOOST_RESULT_OF_NUM_ARGS # define BOOST_RESULT_OF_NUM_ARGS 10 @@ -56,6 +57,11 @@ struct result_of_void_impl typedef R type; }; +// Determine the return type of a function pointer or pointer to member. +template +struct result_of_pointer + : result_of_impl::type, FArgs, false> { }; + template struct result_of_impl { diff --git a/test/result_of_test.cpp b/test/result_of_test.cpp index c6e91ea..73dc757 100644 --- a/test/result_of_test.cpp +++ b/test/result_of_test.cpp @@ -177,6 +177,10 @@ int main() BOOST_STATIC_ASSERT((is_same::type, int volatile &>::value)); BOOST_STATIC_ASSERT((is_same::type, int const volatile &>::value)); + typedef int (*pf_t)(int); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type,int>::value)); + #if defined(BOOST_HAS_DECLTYPE) BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, unsigned int>::value)); From f15c96ffb0e9df53ebd86b4ed80e4ba016329c6b Mon Sep 17 00:00:00 2001 From: Matthew Calabrese Date: Sat, 6 Sep 2008 21:11:48 +0000 Subject: [PATCH 101/164] Adding binary literal utility. [SVN r48637] --- binary_test.cpp | 643 ++++++++++++++++++++++++++++ include/boost/binary.hpp | 14 + include/boost/utility.hpp | 3 +- include/boost/utility/binary.hpp | 708 +++++++++++++++++++++++++++++++ test/Jamfile.v2 | 1 + utility.htm | 55 ++- 6 files changed, 1421 insertions(+), 3 deletions(-) create mode 100644 binary_test.cpp create mode 100644 include/boost/binary.hpp create mode 100644 include/boost/utility/binary.hpp diff --git a/binary_test.cpp b/binary_test.cpp new file mode 100644 index 0000000..b4041b3 --- /dev/null +++ b/binary_test.cpp @@ -0,0 +1,643 @@ +/*============================================================================= + Copyright (c) 2006, 2007 Matthew Calabrese + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#include +#include +#include +#include + +/* +Note: This file tests every single valid bit-grouping on its own, and some + random combinations of bit-groupings. +*/ + +std::size_t const num_random_test_values = 32; + +// Note: These hex values should all correspond with the binary array below +unsigned int const random_unsigned_ints_hex[num_random_test_values] + = { 0x0103u, 0x77ebu, 0x5f36u, 0x1f18u, 0xc530u, 0xa73au, 0xd6f8u, 0x0919u + , 0xfbb0u, 0x3e7cu, 0xd0e9u, 0x22c8u, 0x724eu, 0x14fau, 0xd98eu, 0x40b5 + , 0xeba0u, 0xfe50u, 0x688au, 0x1b05u, 0x5f9cu, 0xe4fcu, 0xa7b8u, 0xd3acu + , 0x1dddu, 0xbf04u, 0x8352u, 0xe89cu, 0x7506u, 0xe767u, 0xf489u, 0xe167 + }; + +unsigned int const random_unsigned_ints_binary[num_random_test_values] + = { BOOST_BINARY( 0 00010000 0011 ), BOOST_BINARY( 0 11101 1111 101011 ) + , BOOST_BINARY( 010111 1100110 1 1 0 ), BOOST_BINARY( 000 1 11110 00 11000 ) + , BOOST_BINARY( 110 001010 0110 000 ), BOOST_BINARY( 1010 01110011 1010 ) + , BOOST_BINARY( 11 010 1 101111 1000 ), BOOST_BINARY( 0000 100100 0110 01 ) + , BOOST_BINARY( 1111 101110 11 0000 ), BOOST_BINARY( 00111110 01111100 ) + , BOOST_BINARY( 11 010 000111 01001 ), BOOST_BINARY( 00100 010110 01000 ) + , BOOST_BINARY( 01 11001001 001110 ), BOOST_BINARY( 0010 1001111 1010 ) + , BOOST_BINARY( 1101 1 00110 0 01110 ), BOOST_BINARY( 100 000 01011010 1 ) + , BOOST_BINARY( 11 1010 1110 1000 00 ), BOOST_BINARY( 11111 110010 10000 ) + , BOOST_BINARY( 01101 00010 001010 ), BOOST_BINARY( 000 11011 000001 01 ) + , BOOST_BINARY( 01 01111 1100111 00 ), BOOST_BINARY( 1 110010 0111111 00 ) + , BOOST_BINARY( 101 0011 11 01110 00 ), BOOST_BINARY( 110100 1 110101 100 ) + , BOOST_BINARY( 00 1110111 011 101 ), BOOST_BINARY( 1011 1111 00000 100 ) + , BOOST_BINARY( 1000 00110 101 0010 ), BOOST_BINARY( 1110 10001 001110 0 ) + , BOOST_BINARY( 011 1010100 000 110 ), BOOST_BINARY( 1110 0111 01100 111 ) + , BOOST_BINARY( 11110 10010 001001 ), BOOST_BINARY( 11 1000010 1100 111 ) + }; + +unsigned int const unsigned_ints_1_bit[2] = +{ BOOST_BINARY( 0 ) +, BOOST_BINARY( 1 ) +}; + +unsigned int const unsigned_ints_2_bits[4] = +{ BOOST_BINARY( 00 ) +, BOOST_BINARY( 01 ) +, BOOST_BINARY( 10 ) +, BOOST_BINARY( 11 ) +}; + +unsigned int const unsigned_ints_3_bits[8] = +{ BOOST_BINARY( 000 ) +, BOOST_BINARY( 001 ) +, BOOST_BINARY( 010 ) +, BOOST_BINARY( 011 ) +, BOOST_BINARY( 100 ) +, BOOST_BINARY( 101 ) +, BOOST_BINARY( 110 ) +, BOOST_BINARY( 111 ) +}; + +unsigned int const unsigned_ints_4_bits[16] = +{ BOOST_BINARY( 0000 ) +, BOOST_BINARY( 0001 ) +, BOOST_BINARY( 0010 ) +, BOOST_BINARY( 0011 ) +, BOOST_BINARY( 0100 ) +, BOOST_BINARY( 0101 ) +, BOOST_BINARY( 0110 ) +, BOOST_BINARY( 0111 ) +, BOOST_BINARY( 1000 ) +, BOOST_BINARY( 1001 ) +, BOOST_BINARY( 1010 ) +, BOOST_BINARY( 1011 ) +, BOOST_BINARY( 1100 ) +, BOOST_BINARY( 1101 ) +, BOOST_BINARY( 1110 ) +, BOOST_BINARY( 1111 ) +}; + +unsigned int const unsigned_ints_5_bits[32] = +{ BOOST_BINARY( 00000 ) +, BOOST_BINARY( 00001 ) +, BOOST_BINARY( 00010 ) +, BOOST_BINARY( 00011 ) +, BOOST_BINARY( 00100 ) +, BOOST_BINARY( 00101 ) +, BOOST_BINARY( 00110 ) +, BOOST_BINARY( 00111 ) +, BOOST_BINARY( 01000 ) +, BOOST_BINARY( 01001 ) +, BOOST_BINARY( 01010 ) +, BOOST_BINARY( 01011 ) +, BOOST_BINARY( 01100 ) +, BOOST_BINARY( 01101 ) +, BOOST_BINARY( 01110 ) +, BOOST_BINARY( 01111 ) +, BOOST_BINARY( 10000 ) +, BOOST_BINARY( 10001 ) +, BOOST_BINARY( 10010 ) +, BOOST_BINARY( 10011 ) +, BOOST_BINARY( 10100 ) +, BOOST_BINARY( 10101 ) +, BOOST_BINARY( 10110 ) +, BOOST_BINARY( 10111 ) +, BOOST_BINARY( 11000 ) +, BOOST_BINARY( 11001 ) +, BOOST_BINARY( 11010 ) +, BOOST_BINARY( 11011 ) +, BOOST_BINARY( 11100 ) +, BOOST_BINARY( 11101 ) +, BOOST_BINARY( 11110 ) +, BOOST_BINARY( 11111 ) +}; + +unsigned int const unsigned_ints_6_bits[64] = +{ BOOST_BINARY( 000000 ) +, BOOST_BINARY( 000001 ) +, BOOST_BINARY( 000010 ) +, BOOST_BINARY( 000011 ) +, BOOST_BINARY( 000100 ) +, BOOST_BINARY( 000101 ) +, BOOST_BINARY( 000110 ) +, BOOST_BINARY( 000111 ) +, BOOST_BINARY( 001000 ) +, BOOST_BINARY( 001001 ) +, BOOST_BINARY( 001010 ) +, BOOST_BINARY( 001011 ) +, BOOST_BINARY( 001100 ) +, BOOST_BINARY( 001101 ) +, BOOST_BINARY( 001110 ) +, BOOST_BINARY( 001111 ) +, BOOST_BINARY( 010000 ) +, BOOST_BINARY( 010001 ) +, BOOST_BINARY( 010010 ) +, BOOST_BINARY( 010011 ) +, BOOST_BINARY( 010100 ) +, BOOST_BINARY( 010101 ) +, BOOST_BINARY( 010110 ) +, BOOST_BINARY( 010111 ) +, BOOST_BINARY( 011000 ) +, BOOST_BINARY( 011001 ) +, BOOST_BINARY( 011010 ) +, BOOST_BINARY( 011011 ) +, BOOST_BINARY( 011100 ) +, BOOST_BINARY( 011101 ) +, BOOST_BINARY( 011110 ) +, BOOST_BINARY( 011111 ) +, BOOST_BINARY( 100000 ) +, BOOST_BINARY( 100001 ) +, BOOST_BINARY( 100010 ) +, BOOST_BINARY( 100011 ) +, BOOST_BINARY( 100100 ) +, BOOST_BINARY( 100101 ) +, BOOST_BINARY( 100110 ) +, BOOST_BINARY( 100111 ) +, BOOST_BINARY( 101000 ) +, BOOST_BINARY( 101001 ) +, BOOST_BINARY( 101010 ) +, BOOST_BINARY( 101011 ) +, BOOST_BINARY( 101100 ) +, BOOST_BINARY( 101101 ) +, BOOST_BINARY( 101110 ) +, BOOST_BINARY( 101111 ) +, BOOST_BINARY( 110000 ) +, BOOST_BINARY( 110001 ) +, BOOST_BINARY( 110010 ) +, BOOST_BINARY( 110011 ) +, BOOST_BINARY( 110100 ) +, BOOST_BINARY( 110101 ) +, BOOST_BINARY( 110110 ) +, BOOST_BINARY( 110111 ) +, BOOST_BINARY( 111000 ) +, BOOST_BINARY( 111001 ) +, BOOST_BINARY( 111010 ) +, BOOST_BINARY( 111011 ) +, BOOST_BINARY( 111100 ) +, BOOST_BINARY( 111101 ) +, BOOST_BINARY( 111110 ) +, BOOST_BINARY( 111111 ) +}; + +unsigned int const unsigned_ints_7_bits[128] = +{ BOOST_BINARY( 0000000 ) +, BOOST_BINARY( 0000001 ) +, BOOST_BINARY( 0000010 ) +, BOOST_BINARY( 0000011 ) +, BOOST_BINARY( 0000100 ) +, BOOST_BINARY( 0000101 ) +, BOOST_BINARY( 0000110 ) +, BOOST_BINARY( 0000111 ) +, BOOST_BINARY( 0001000 ) +, BOOST_BINARY( 0001001 ) +, BOOST_BINARY( 0001010 ) +, BOOST_BINARY( 0001011 ) +, BOOST_BINARY( 0001100 ) +, BOOST_BINARY( 0001101 ) +, BOOST_BINARY( 0001110 ) +, BOOST_BINARY( 0001111 ) +, BOOST_BINARY( 0010000 ) +, BOOST_BINARY( 0010001 ) +, BOOST_BINARY( 0010010 ) +, BOOST_BINARY( 0010011 ) +, BOOST_BINARY( 0010100 ) +, BOOST_BINARY( 0010101 ) +, BOOST_BINARY( 0010110 ) +, BOOST_BINARY( 0010111 ) +, BOOST_BINARY( 0011000 ) +, BOOST_BINARY( 0011001 ) +, BOOST_BINARY( 0011010 ) +, BOOST_BINARY( 0011011 ) +, BOOST_BINARY( 0011100 ) +, BOOST_BINARY( 0011101 ) +, BOOST_BINARY( 0011110 ) +, BOOST_BINARY( 0011111 ) +, BOOST_BINARY( 0100000 ) +, BOOST_BINARY( 0100001 ) +, BOOST_BINARY( 0100010 ) +, BOOST_BINARY( 0100011 ) +, BOOST_BINARY( 0100100 ) +, BOOST_BINARY( 0100101 ) +, BOOST_BINARY( 0100110 ) +, BOOST_BINARY( 0100111 ) +, BOOST_BINARY( 0101000 ) +, BOOST_BINARY( 0101001 ) +, BOOST_BINARY( 0101010 ) +, BOOST_BINARY( 0101011 ) +, BOOST_BINARY( 0101100 ) +, BOOST_BINARY( 0101101 ) +, BOOST_BINARY( 0101110 ) +, BOOST_BINARY( 0101111 ) +, BOOST_BINARY( 0110000 ) +, BOOST_BINARY( 0110001 ) +, BOOST_BINARY( 0110010 ) +, BOOST_BINARY( 0110011 ) +, BOOST_BINARY( 0110100 ) +, BOOST_BINARY( 0110101 ) +, BOOST_BINARY( 0110110 ) +, BOOST_BINARY( 0110111 ) +, BOOST_BINARY( 0111000 ) +, BOOST_BINARY( 0111001 ) +, BOOST_BINARY( 0111010 ) +, BOOST_BINARY( 0111011 ) +, BOOST_BINARY( 0111100 ) +, BOOST_BINARY( 0111101 ) +, BOOST_BINARY( 0111110 ) +, BOOST_BINARY( 0111111 ) +, BOOST_BINARY( 1000000 ) +, BOOST_BINARY( 1000001 ) +, BOOST_BINARY( 1000010 ) +, BOOST_BINARY( 1000011 ) +, BOOST_BINARY( 1000100 ) +, BOOST_BINARY( 1000101 ) +, BOOST_BINARY( 1000110 ) +, BOOST_BINARY( 1000111 ) +, BOOST_BINARY( 1001000 ) +, BOOST_BINARY( 1001001 ) +, BOOST_BINARY( 1001010 ) +, BOOST_BINARY( 1001011 ) +, BOOST_BINARY( 1001100 ) +, BOOST_BINARY( 1001101 ) +, BOOST_BINARY( 1001110 ) +, BOOST_BINARY( 1001111 ) +, BOOST_BINARY( 1010000 ) +, BOOST_BINARY( 1010001 ) +, BOOST_BINARY( 1010010 ) +, BOOST_BINARY( 1010011 ) +, BOOST_BINARY( 1010100 ) +, BOOST_BINARY( 1010101 ) +, BOOST_BINARY( 1010110 ) +, BOOST_BINARY( 1010111 ) +, BOOST_BINARY( 1011000 ) +, BOOST_BINARY( 1011001 ) +, BOOST_BINARY( 1011010 ) +, BOOST_BINARY( 1011011 ) +, BOOST_BINARY( 1011100 ) +, BOOST_BINARY( 1011101 ) +, BOOST_BINARY( 1011110 ) +, BOOST_BINARY( 1011111 ) +, BOOST_BINARY( 1100000 ) +, BOOST_BINARY( 1100001 ) +, BOOST_BINARY( 1100010 ) +, BOOST_BINARY( 1100011 ) +, BOOST_BINARY( 1100100 ) +, BOOST_BINARY( 1100101 ) +, BOOST_BINARY( 1100110 ) +, BOOST_BINARY( 1100111 ) +, BOOST_BINARY( 1101000 ) +, BOOST_BINARY( 1101001 ) +, BOOST_BINARY( 1101010 ) +, BOOST_BINARY( 1101011 ) +, BOOST_BINARY( 1101100 ) +, BOOST_BINARY( 1101101 ) +, BOOST_BINARY( 1101110 ) +, BOOST_BINARY( 1101111 ) +, BOOST_BINARY( 1110000 ) +, BOOST_BINARY( 1110001 ) +, BOOST_BINARY( 1110010 ) +, BOOST_BINARY( 1110011 ) +, BOOST_BINARY( 1110100 ) +, BOOST_BINARY( 1110101 ) +, BOOST_BINARY( 1110110 ) +, BOOST_BINARY( 1110111 ) +, BOOST_BINARY( 1111000 ) +, BOOST_BINARY( 1111001 ) +, BOOST_BINARY( 1111010 ) +, BOOST_BINARY( 1111011 ) +, BOOST_BINARY( 1111100 ) +, BOOST_BINARY( 1111101 ) +, BOOST_BINARY( 1111110 ) +, BOOST_BINARY( 1111111 ) +}; +unsigned int const unsigned_ints_8_bits[256] = +{ BOOST_BINARY( 00000000 ) +, BOOST_BINARY( 00000001 ) +, BOOST_BINARY( 00000010 ) +, BOOST_BINARY( 00000011 ) +, BOOST_BINARY( 00000100 ) +, BOOST_BINARY( 00000101 ) +, BOOST_BINARY( 00000110 ) +, BOOST_BINARY( 00000111 ) +, BOOST_BINARY( 00001000 ) +, BOOST_BINARY( 00001001 ) +, BOOST_BINARY( 00001010 ) +, BOOST_BINARY( 00001011 ) +, BOOST_BINARY( 00001100 ) +, BOOST_BINARY( 00001101 ) +, BOOST_BINARY( 00001110 ) +, BOOST_BINARY( 00001111 ) +, BOOST_BINARY( 00010000 ) +, BOOST_BINARY( 00010001 ) +, BOOST_BINARY( 00010010 ) +, BOOST_BINARY( 00010011 ) +, BOOST_BINARY( 00010100 ) +, BOOST_BINARY( 00010101 ) +, BOOST_BINARY( 00010110 ) +, BOOST_BINARY( 00010111 ) +, BOOST_BINARY( 00011000 ) +, BOOST_BINARY( 00011001 ) +, BOOST_BINARY( 00011010 ) +, BOOST_BINARY( 00011011 ) +, BOOST_BINARY( 00011100 ) +, BOOST_BINARY( 00011101 ) +, BOOST_BINARY( 00011110 ) +, BOOST_BINARY( 00011111 ) +, BOOST_BINARY( 00100000 ) +, BOOST_BINARY( 00100001 ) +, BOOST_BINARY( 00100010 ) +, BOOST_BINARY( 00100011 ) +, BOOST_BINARY( 00100100 ) +, BOOST_BINARY( 00100101 ) +, BOOST_BINARY( 00100110 ) +, BOOST_BINARY( 00100111 ) +, BOOST_BINARY( 00101000 ) +, BOOST_BINARY( 00101001 ) +, BOOST_BINARY( 00101010 ) +, BOOST_BINARY( 00101011 ) +, BOOST_BINARY( 00101100 ) +, BOOST_BINARY( 00101101 ) +, BOOST_BINARY( 00101110 ) +, BOOST_BINARY( 00101111 ) +, BOOST_BINARY( 00110000 ) +, BOOST_BINARY( 00110001 ) +, BOOST_BINARY( 00110010 ) +, BOOST_BINARY( 00110011 ) +, BOOST_BINARY( 00110100 ) +, BOOST_BINARY( 00110101 ) +, BOOST_BINARY( 00110110 ) +, BOOST_BINARY( 00110111 ) +, BOOST_BINARY( 00111000 ) +, BOOST_BINARY( 00111001 ) +, BOOST_BINARY( 00111010 ) +, BOOST_BINARY( 00111011 ) +, BOOST_BINARY( 00111100 ) +, BOOST_BINARY( 00111101 ) +, BOOST_BINARY( 00111110 ) +, BOOST_BINARY( 00111111 ) +, BOOST_BINARY( 01000000 ) +, BOOST_BINARY( 01000001 ) +, BOOST_BINARY( 01000010 ) +, BOOST_BINARY( 01000011 ) +, BOOST_BINARY( 01000100 ) +, BOOST_BINARY( 01000101 ) +, BOOST_BINARY( 01000110 ) +, BOOST_BINARY( 01000111 ) +, BOOST_BINARY( 01001000 ) +, BOOST_BINARY( 01001001 ) +, BOOST_BINARY( 01001010 ) +, BOOST_BINARY( 01001011 ) +, BOOST_BINARY( 01001100 ) +, BOOST_BINARY( 01001101 ) +, BOOST_BINARY( 01001110 ) +, BOOST_BINARY( 01001111 ) +, BOOST_BINARY( 01010000 ) +, BOOST_BINARY( 01010001 ) +, BOOST_BINARY( 01010010 ) +, BOOST_BINARY( 01010011 ) +, BOOST_BINARY( 01010100 ) +, BOOST_BINARY( 01010101 ) +, BOOST_BINARY( 01010110 ) +, BOOST_BINARY( 01010111 ) +, BOOST_BINARY( 01011000 ) +, BOOST_BINARY( 01011001 ) +, BOOST_BINARY( 01011010 ) +, BOOST_BINARY( 01011011 ) +, BOOST_BINARY( 01011100 ) +, BOOST_BINARY( 01011101 ) +, BOOST_BINARY( 01011110 ) +, BOOST_BINARY( 01011111 ) +, BOOST_BINARY( 01100000 ) +, BOOST_BINARY( 01100001 ) +, BOOST_BINARY( 01100010 ) +, BOOST_BINARY( 01100011 ) +, BOOST_BINARY( 01100100 ) +, BOOST_BINARY( 01100101 ) +, BOOST_BINARY( 01100110 ) +, BOOST_BINARY( 01100111 ) +, BOOST_BINARY( 01101000 ) +, BOOST_BINARY( 01101001 ) +, BOOST_BINARY( 01101010 ) +, BOOST_BINARY( 01101011 ) +, BOOST_BINARY( 01101100 ) +, BOOST_BINARY( 01101101 ) +, BOOST_BINARY( 01101110 ) +, BOOST_BINARY( 01101111 ) +, BOOST_BINARY( 01110000 ) +, BOOST_BINARY( 01110001 ) +, BOOST_BINARY( 01110010 ) +, BOOST_BINARY( 01110011 ) +, BOOST_BINARY( 01110100 ) +, BOOST_BINARY( 01110101 ) +, BOOST_BINARY( 01110110 ) +, BOOST_BINARY( 01110111 ) +, BOOST_BINARY( 01111000 ) +, BOOST_BINARY( 01111001 ) +, BOOST_BINARY( 01111010 ) +, BOOST_BINARY( 01111011 ) +, BOOST_BINARY( 01111100 ) +, BOOST_BINARY( 01111101 ) +, BOOST_BINARY( 01111110 ) +, BOOST_BINARY( 01111111 ) +, BOOST_BINARY( 10000000 ) +, BOOST_BINARY( 10000001 ) +, BOOST_BINARY( 10000010 ) +, BOOST_BINARY( 10000011 ) +, BOOST_BINARY( 10000100 ) +, BOOST_BINARY( 10000101 ) +, BOOST_BINARY( 10000110 ) +, BOOST_BINARY( 10000111 ) +, BOOST_BINARY( 10001000 ) +, BOOST_BINARY( 10001001 ) +, BOOST_BINARY( 10001010 ) +, BOOST_BINARY( 10001011 ) +, BOOST_BINARY( 10001100 ) +, BOOST_BINARY( 10001101 ) +, BOOST_BINARY( 10001110 ) +, BOOST_BINARY( 10001111 ) +, BOOST_BINARY( 10010000 ) +, BOOST_BINARY( 10010001 ) +, BOOST_BINARY( 10010010 ) +, BOOST_BINARY( 10010011 ) +, BOOST_BINARY( 10010100 ) +, BOOST_BINARY( 10010101 ) +, BOOST_BINARY( 10010110 ) +, BOOST_BINARY( 10010111 ) +, BOOST_BINARY( 10011000 ) +, BOOST_BINARY( 10011001 ) +, BOOST_BINARY( 10011010 ) +, BOOST_BINARY( 10011011 ) +, BOOST_BINARY( 10011100 ) +, BOOST_BINARY( 10011101 ) +, BOOST_BINARY( 10011110 ) +, BOOST_BINARY( 10011111 ) +, BOOST_BINARY( 10100000 ) +, BOOST_BINARY( 10100001 ) +, BOOST_BINARY( 10100010 ) +, BOOST_BINARY( 10100011 ) +, BOOST_BINARY( 10100100 ) +, BOOST_BINARY( 10100101 ) +, BOOST_BINARY( 10100110 ) +, BOOST_BINARY( 10100111 ) +, BOOST_BINARY( 10101000 ) +, BOOST_BINARY( 10101001 ) +, BOOST_BINARY( 10101010 ) +, BOOST_BINARY( 10101011 ) +, BOOST_BINARY( 10101100 ) +, BOOST_BINARY( 10101101 ) +, BOOST_BINARY( 10101110 ) +, BOOST_BINARY( 10101111 ) +, BOOST_BINARY( 10110000 ) +, BOOST_BINARY( 10110001 ) +, BOOST_BINARY( 10110010 ) +, BOOST_BINARY( 10110011 ) +, BOOST_BINARY( 10110100 ) +, BOOST_BINARY( 10110101 ) +, BOOST_BINARY( 10110110 ) +, BOOST_BINARY( 10110111 ) +, BOOST_BINARY( 10111000 ) +, BOOST_BINARY( 10111001 ) +, BOOST_BINARY( 10111010 ) +, BOOST_BINARY( 10111011 ) +, BOOST_BINARY( 10111100 ) +, BOOST_BINARY( 10111101 ) +, BOOST_BINARY( 10111110 ) +, BOOST_BINARY( 10111111 ) +, BOOST_BINARY( 11000000 ) +, BOOST_BINARY( 11000001 ) +, BOOST_BINARY( 11000010 ) +, BOOST_BINARY( 11000011 ) +, BOOST_BINARY( 11000100 ) +, BOOST_BINARY( 11000101 ) +, BOOST_BINARY( 11000110 ) +, BOOST_BINARY( 11000111 ) +, BOOST_BINARY( 11001000 ) +, BOOST_BINARY( 11001001 ) +, BOOST_BINARY( 11001010 ) +, BOOST_BINARY( 11001011 ) +, BOOST_BINARY( 11001100 ) +, BOOST_BINARY( 11001101 ) +, BOOST_BINARY( 11001110 ) +, BOOST_BINARY( 11001111 ) +, BOOST_BINARY( 11010000 ) +, BOOST_BINARY( 11010001 ) +, BOOST_BINARY( 11010010 ) +, BOOST_BINARY( 11010011 ) +, BOOST_BINARY( 11010100 ) +, BOOST_BINARY( 11010101 ) +, BOOST_BINARY( 11010110 ) +, BOOST_BINARY( 11010111 ) +, BOOST_BINARY( 11011000 ) +, BOOST_BINARY( 11011001 ) +, BOOST_BINARY( 11011010 ) +, BOOST_BINARY( 11011011 ) +, BOOST_BINARY( 11011100 ) +, BOOST_BINARY( 11011101 ) +, BOOST_BINARY( 11011110 ) +, BOOST_BINARY( 11011111 ) +, BOOST_BINARY( 11100000 ) +, BOOST_BINARY( 11100001 ) +, BOOST_BINARY( 11100010 ) +, BOOST_BINARY( 11100011 ) +, BOOST_BINARY( 11100100 ) +, BOOST_BINARY( 11100101 ) +, BOOST_BINARY( 11100110 ) +, BOOST_BINARY( 11100111 ) +, BOOST_BINARY( 11101000 ) +, BOOST_BINARY( 11101001 ) +, BOOST_BINARY( 11101010 ) +, BOOST_BINARY( 11101011 ) +, BOOST_BINARY( 11101100 ) +, BOOST_BINARY( 11101101 ) +, BOOST_BINARY( 11101110 ) +, BOOST_BINARY( 11101111 ) +, BOOST_BINARY( 11110000 ) +, BOOST_BINARY( 11110001 ) +, BOOST_BINARY( 11110010 ) +, BOOST_BINARY( 11110011 ) +, BOOST_BINARY( 11110100 ) +, BOOST_BINARY( 11110101 ) +, BOOST_BINARY( 11110110 ) +, BOOST_BINARY( 11110111 ) +, BOOST_BINARY( 11111000 ) +, BOOST_BINARY( 11111001 ) +, BOOST_BINARY( 11111010 ) +, BOOST_BINARY( 11111011 ) +, BOOST_BINARY( 11111100 ) +, BOOST_BINARY( 11111101 ) +, BOOST_BINARY( 11111110 ) +, BOOST_BINARY( 11111111 ) +}; + +struct left_is_not_one_less_than_right +{ + bool operator ()( unsigned int left, unsigned int right ) const + { + return right != left + 1; + } +}; + +template< std::size_t Size > +bool is_ascending_from_0_array( unsigned int const (&array)[Size] ) +{ + unsigned int const* const curr = array, + * const end = array + Size; + + return ( *curr == 0 ) + && ( std::adjacent_find( curr, end + , left_is_not_one_less_than_right() + ) + == end + ); +} + +std::size_t const unsigned_int_id = 1, + unsigned_long_int_id = 2; + +typedef char (&unsigned_int_id_type)[unsigned_int_id]; +typedef char (&unsigned_long_int_id_type)[unsigned_long_int_id]; + +// Note: Functions only used for type checking +unsigned_int_id_type binary_type_checker( unsigned int ); +unsigned_long_int_id_type binary_type_checker( unsigned long int ); + +int test_main( int, char *[] ) +{ + BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_1_bit ) ); + BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_2_bits ) ); + BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_3_bits ) ); + BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_4_bits ) ); + BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_5_bits ) ); + BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_6_bits ) ); + BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_7_bits ) ); + BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_8_bits ) ); + + BOOST_CHECK( std::equal( &random_unsigned_ints_hex[0] + , random_unsigned_ints_hex + num_random_test_values + , &random_unsigned_ints_binary[0] + ) + ); + + BOOST_CHECK( sizeof( binary_type_checker( BOOST_BINARY_U( 110100 1010 ) ) ) + == unsigned_int_id + ); + + BOOST_CHECK( sizeof( binary_type_checker( BOOST_BINARY_UL( 11110 ) ) ) + == unsigned_long_int_id + ); + + BOOST_CHECK( sizeof( binary_type_checker( BOOST_BINARY_LU( 10 0001 ) ) ) + == unsigned_long_int_id + ); + + return 0; +} diff --git a/include/boost/binary.hpp b/include/boost/binary.hpp new file mode 100644 index 0000000..b4a889d --- /dev/null +++ b/include/boost/binary.hpp @@ -0,0 +1,14 @@ +/*============================================================================= + Copyright (c) 2008 Matthew Calabrese + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_BINARY_HPP +#define BOOST_BINARY_HPP + +#include + +#endif diff --git a/include/boost/utility.hpp b/include/boost/utility.hpp index 211d89d..b909f29 100644 --- a/include/boost/utility.hpp +++ b/include/boost/utility.hpp @@ -10,7 +10,8 @@ #define BOOST_UTILITY_HPP #include -#include +#include +#include #include #include #include diff --git a/include/boost/utility/binary.hpp b/include/boost/utility/binary.hpp new file mode 100644 index 0000000..8cef146 --- /dev/null +++ b/include/boost/utility/binary.hpp @@ -0,0 +1,708 @@ +/*============================================================================= + Copyright (c) 2005 Matthew Calabrese + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef BOOST_UTILITY_BINARY_HPP +#define BOOST_UTILITY_BINARY_HPP + +/*============================================================================= + + Binary Literal Utility + ______________________ + + + The following code works by converting the input bit pattern into a + Boost.Preprocessor sequence, then converting groupings of 3 bits each into + the corresponding octal digit, and finally concatenating all of the digits + together along with a leading zero. This yields a standard octal literal + with the desired value as specified in bits. + +==============================================================================*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BOOST_BINARY( bit_groupings ) \ + BOOST_BINARY_LITERAL_D( BOOST_PP_DEDUCE_D(), bit_groupings ) + +#define BOOST_BINARY_U( bit_groupings ) \ + BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, U ) + +#define BOOST_BINARY_L( bit_groupings ) \ + BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, L ) + +#define BOOST_BINARY_UL( bit_groupings ) \ + BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, UL ) + +#define BOOST_BINARY_LU( bit_groupings ) \ + BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, LU ) + +#define BOOST_BINARY_LL( bit_groupings ) \ + BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, LL ) + +#define BOOST_BINARY_ULL( bit_groupings ) \ + BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, ULL ) + +#define BOOST_BINARY_LLU( bit_groupings ) \ + BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, LLU ) + +#define BOOST_SUFFIXED_BINARY_LITERAL( bit_groupings, suffix ) \ + BOOST_SUFFIXED_BINARY_LITERAL_D( BOOST_PP_DEDUCE_D(), bit_groupings, suffix ) + +#define BOOST_SUFFIXED_BINARY_LITERAL_D( d, bit_groupings, suffix ) \ + BOOST_PP_CAT( BOOST_BINARY_LITERAL_D( d, bit_groupings ), suffix ) + +#define BOOST_BINARY_LITERAL_D( d, bit_groupings ) \ + BOOST_PP_SEQ_CAT \ + ( (0) BOOST_DETAIL_CREATE_BINARY_LITERAL_OCTAL_SEQUENCE( d, bit_groupings ) \ + ) + +#define BOOST_DETAIL_CREATE_BINARY_LITERAL_OCTAL_SEQUENCE( d, bit_groupings ) \ + BOOST_PP_SEQ_TRANSFORM \ + ( BOOST_DETAIL_TRIPLE_TO_OCTAL_OPERATION \ + , BOOST_PP_NIL \ + , BOOST_PP_IDENTITY( BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_TRIPLE_SEQUENCE )()\ + ( BOOST_DETAIL_COMPLETE_TRIPLE_SEQUENCE \ + ( \ + d \ + , BOOST_DETAIL_CREATE_BINARY_LITERAL_BIT_SEQUENCE( d, bit_groupings ) \ + ) \ + ) \ + ) + +#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_TRIPLE_SEQUENCE( bit_sequence ) \ + BOOST_PP_CAT \ + ( BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_1 bit_sequence \ + , END_BIT \ + ) + +#define BOOST_DETAIL_BITS_PER_OCTIT 3 + +#define BOOST_DETAIL_COMPLETE_TRIPLE_SEQUENCE( d, incomplete_nibble_sequence ) \ + BOOST_PP_CAT \ + ( BOOST_DETAIL_CREATE_TRIPLE_COMPLETION_SEQUENCE_ \ + , BOOST_PP_MOD_D( d \ + , BOOST_PP_SEQ_SIZE( incomplete_nibble_sequence ) \ + , BOOST_DETAIL_BITS_PER_OCTIT \ + ) \ + ) \ + incomplete_nibble_sequence + +#define BOOST_DETAIL_FIXED_COMPL( bit ) \ + BOOST_PP_CAT( BOOST_DETAIL_FIXED_COMPL_, bit ) + +#define BOOST_DETAIL_FIXED_COMPL_0 1 + +#define BOOST_DETAIL_FIXED_COMPL_1 0 + +#define BOOST_DETAIL_CREATE_BINARY_LITERAL_BIT_SEQUENCE( d, bit_groupings ) \ + BOOST_PP_EMPTY \ + BOOST_PP_CAT( BOOST_PP_WHILE_, d ) \ + ( BOOST_DETAIL_BINARY_LITERAL_PREDICATE \ + , BOOST_DETAIL_BINARY_LITERAL_OPERATION \ + , bit_groupings () \ + ) + +#define BOOST_DETAIL_BINARY_LITERAL_PREDICATE( d, state ) \ + BOOST_DETAIL_FIXED_COMPL( BOOST_DETAIL_IS_NULLARY_ARGS( state ) ) + +#define BOOST_DETAIL_BINARY_LITERAL_OPERATION( d, state ) \ + BOOST_DETAIL_SPLIT_AND_SWAP \ + ( BOOST_PP_CAT( BOOST_DETAIL_BINARY_LITERAL_ELEMENT_, state ) ) + +#define BOOST_DETAIL_TRIPLE_TO_OCTAL_OPERATION( s, dummy_param, tuple ) \ + BOOST_DETAIL_TERNARY_TRIPLE_TO_OCTAL tuple + +#define BOOST_DETAIL_TERNARY_TRIPLE_TO_OCTAL( bit2, bit1, bit0 ) \ + BOOST_DETAIL_TRIPLE_TO_OCTAL_ ## bit2 ## bit1 ## bit0 + +#define BOOST_DETAIL_CREATE_TRIPLE_COMPLETION_SEQUENCE_1 (0)(0) +#define BOOST_DETAIL_CREATE_TRIPLE_COMPLETION_SEQUENCE_2 (0) +#define BOOST_DETAIL_CREATE_TRIPLE_COMPLETION_SEQUENCE_0 + +#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_1END_BIT + +#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_1( bit ) \ + ( ( bit, BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_2 + +#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_2( bit ) \ + bit, BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_3 + +#define BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_3( bit ) \ + bit ) ) BOOST_DETAIL_CONVERT_BIT_SEQUENCE_TO_PARENTHETIC_TUPLE_1 + +#define BOOST_DETAIL_SPLIT_AND_SWAP( params ) \ + BOOST_PP_IDENTITY( BOOST_DETAIL_SPLIT_AND_SWAP_PARAMS )()( params ) + +#define BOOST_DETAIL_SPLIT_AND_SWAP_PARAMS( first_param, second_param ) \ + second_param first_param + +#define BOOST_DETAIL_LEFT_OF_COMMA( params ) \ + BOOST_PP_IDENTITY( BOOST_DETAIL_FIRST_MACRO_PARAM )()( params ) + +#define BOOST_DETAIL_FIRST_MACRO_PARAM( first_param, second_param ) \ + first_param + +/* Begin derived concepts from Chaos by Paul Mensonides */ + +#define BOOST_DETAIL_IS_NULLARY_ARGS( param ) \ + BOOST_DETAIL_LEFT_OF_COMMA \ + ( BOOST_PP_CAT( BOOST_DETAIL_IS_NULLARY_ARGS_R_ \ + , BOOST_DETAIL_IS_NULLARY_ARGS_C param \ + ) \ + ) + +#define BOOST_DETAIL_IS_NULLARY_ARGS_C() \ + 1 + +#define BOOST_DETAIL_IS_NULLARY_ARGS_R_1 \ + 1, BOOST_PP_NIL + +#define BOOST_DETAIL_IS_NULLARY_ARGS_R_BOOST_DETAIL_IS_NULLARY_ARGS_C \ + 0, BOOST_PP_NIL + +/* End derived concepts from Chaos by Paul Mensonides */ + +#define BOOST_DETAIL_TRIPLE_TO_OCTAL_000 0 +#define BOOST_DETAIL_TRIPLE_TO_OCTAL_001 1 +#define BOOST_DETAIL_TRIPLE_TO_OCTAL_010 2 +#define BOOST_DETAIL_TRIPLE_TO_OCTAL_011 3 +#define BOOST_DETAIL_TRIPLE_TO_OCTAL_100 4 +#define BOOST_DETAIL_TRIPLE_TO_OCTAL_101 5 +#define BOOST_DETAIL_TRIPLE_TO_OCTAL_110 6 +#define BOOST_DETAIL_TRIPLE_TO_OCTAL_111 7 + +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0 (0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1 (1), + +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00 (0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01 (0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10 (1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11 (1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00 (0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01 (0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10 (1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11 (1)(1), + +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000 (0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001 (0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010 (0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011 (0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100 (1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101 (1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110 (1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111 (1)(1)(1), + +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000 (0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001 (0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010 (0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011 (0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100 (0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101 (0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110 (0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111 (0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000 (1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001 (1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010 (1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011 (1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100 (1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101 (1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110 (1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111 (1)(1)(1)(1), + +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000 (0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001 (0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010 (0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011 (0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100 (0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101 (0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110 (0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111 (0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000 (0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001 (0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010 (0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011 (0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100 (0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101 (0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110 (0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111 (0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000 (1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001 (1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010 (1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011 (1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100 (1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101 (1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110 (1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111 (1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000 (1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001 (1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010 (1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011 (1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100 (1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101 (1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110 (1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111 (1)(1)(1)(1)(1), + +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000000 (0)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000001 (0)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000010 (0)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000011 (0)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000100 (0)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000101 (0)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000110 (0)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_000111 (0)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001000 (0)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001001 (0)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001010 (0)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001011 (0)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001100 (0)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001101 (0)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001110 (0)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_001111 (0)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010000 (0)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010001 (0)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010010 (0)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010011 (0)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010100 (0)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010101 (0)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010110 (0)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_010111 (0)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011000 (0)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011001 (0)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011010 (0)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011011 (0)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011100 (0)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011101 (0)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011110 (0)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_011111 (0)(1)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100000 (1)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100001 (1)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100010 (1)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100011 (1)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100100 (1)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100101 (1)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100110 (1)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_100111 (1)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101000 (1)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101001 (1)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101010 (1)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101011 (1)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101100 (1)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101101 (1)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101110 (1)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_101111 (1)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110000 (1)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110001 (1)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110010 (1)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110011 (1)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110100 (1)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110101 (1)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110110 (1)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_110111 (1)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111000 (1)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111001 (1)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111010 (1)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111011 (1)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111100 (1)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111101 (1)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111110 (1)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_111111 (1)(1)(1)(1)(1)(1), + +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000000 (0)(0)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000001 (0)(0)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000010 (0)(0)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000011 (0)(0)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000100 (0)(0)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000101 (0)(0)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000110 (0)(0)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0000111 (0)(0)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001000 (0)(0)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001001 (0)(0)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001010 (0)(0)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001011 (0)(0)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001100 (0)(0)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001101 (0)(0)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001110 (0)(0)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0001111 (0)(0)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010000 (0)(0)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010001 (0)(0)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010010 (0)(0)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010011 (0)(0)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010100 (0)(0)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010101 (0)(0)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010110 (0)(0)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0010111 (0)(0)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011000 (0)(0)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011001 (0)(0)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011010 (0)(0)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011011 (0)(0)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011100 (0)(0)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011101 (0)(0)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011110 (0)(0)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0011111 (0)(0)(1)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100000 (0)(1)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100001 (0)(1)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100010 (0)(1)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100011 (0)(1)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100100 (0)(1)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100101 (0)(1)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100110 (0)(1)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0100111 (0)(1)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101000 (0)(1)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101001 (0)(1)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101010 (0)(1)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101011 (0)(1)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101100 (0)(1)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101101 (0)(1)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101110 (0)(1)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0101111 (0)(1)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110000 (0)(1)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110001 (0)(1)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110010 (0)(1)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110011 (0)(1)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110100 (0)(1)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110101 (0)(1)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110110 (0)(1)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0110111 (0)(1)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111000 (0)(1)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111001 (0)(1)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111010 (0)(1)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111011 (0)(1)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111100 (0)(1)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111101 (0)(1)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111110 (0)(1)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_0111111 (0)(1)(1)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000000 (1)(0)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000001 (1)(0)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000010 (1)(0)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000011 (1)(0)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000100 (1)(0)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000101 (1)(0)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000110 (1)(0)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1000111 (1)(0)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001000 (1)(0)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001001 (1)(0)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001010 (1)(0)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001011 (1)(0)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001100 (1)(0)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001101 (1)(0)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001110 (1)(0)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1001111 (1)(0)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010000 (1)(0)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010001 (1)(0)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010010 (1)(0)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010011 (1)(0)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010100 (1)(0)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010101 (1)(0)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010110 (1)(0)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1010111 (1)(0)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011000 (1)(0)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011001 (1)(0)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011010 (1)(0)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011011 (1)(0)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011100 (1)(0)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011101 (1)(0)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011110 (1)(0)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1011111 (1)(0)(1)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100000 (1)(1)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100001 (1)(1)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100010 (1)(1)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100011 (1)(1)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100100 (1)(1)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100101 (1)(1)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100110 (1)(1)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1100111 (1)(1)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101000 (1)(1)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101001 (1)(1)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101010 (1)(1)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101011 (1)(1)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101100 (1)(1)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101101 (1)(1)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101110 (1)(1)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1101111 (1)(1)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110000 (1)(1)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110001 (1)(1)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110010 (1)(1)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110011 (1)(1)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110100 (1)(1)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110101 (1)(1)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110110 (1)(1)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1110111 (1)(1)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111000 (1)(1)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111001 (1)(1)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111010 (1)(1)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111011 (1)(1)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111100 (1)(1)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111101 (1)(1)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111110 (1)(1)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_1111111 (1)(1)(1)(1)(1)(1)(1), + +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000000 (0)(0)(0)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000001 (0)(0)(0)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000010 (0)(0)(0)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000011 (0)(0)(0)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000100 (0)(0)(0)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000101 (0)(0)(0)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000110 (0)(0)(0)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00000111 (0)(0)(0)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001000 (0)(0)(0)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001001 (0)(0)(0)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001010 (0)(0)(0)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001011 (0)(0)(0)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001100 (0)(0)(0)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001101 (0)(0)(0)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001110 (0)(0)(0)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00001111 (0)(0)(0)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010000 (0)(0)(0)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010001 (0)(0)(0)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010010 (0)(0)(0)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010011 (0)(0)(0)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010100 (0)(0)(0)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010101 (0)(0)(0)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010110 (0)(0)(0)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00010111 (0)(0)(0)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011000 (0)(0)(0)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011001 (0)(0)(0)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011010 (0)(0)(0)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011011 (0)(0)(0)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011100 (0)(0)(0)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011101 (0)(0)(0)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011110 (0)(0)(0)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00011111 (0)(0)(0)(1)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100000 (0)(0)(1)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100001 (0)(0)(1)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100010 (0)(0)(1)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100011 (0)(0)(1)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100100 (0)(0)(1)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100101 (0)(0)(1)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100110 (0)(0)(1)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00100111 (0)(0)(1)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101000 (0)(0)(1)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101001 (0)(0)(1)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101010 (0)(0)(1)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101011 (0)(0)(1)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101100 (0)(0)(1)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101101 (0)(0)(1)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101110 (0)(0)(1)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00101111 (0)(0)(1)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110000 (0)(0)(1)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110001 (0)(0)(1)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110010 (0)(0)(1)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110011 (0)(0)(1)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110100 (0)(0)(1)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110101 (0)(0)(1)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110110 (0)(0)(1)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00110111 (0)(0)(1)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111000 (0)(0)(1)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111001 (0)(0)(1)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111010 (0)(0)(1)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111011 (0)(0)(1)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111100 (0)(0)(1)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111101 (0)(0)(1)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111110 (0)(0)(1)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_00111111 (0)(0)(1)(1)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000000 (0)(1)(0)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000001 (0)(1)(0)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000010 (0)(1)(0)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000011 (0)(1)(0)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000100 (0)(1)(0)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000101 (0)(1)(0)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000110 (0)(1)(0)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01000111 (0)(1)(0)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001000 (0)(1)(0)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001001 (0)(1)(0)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001010 (0)(1)(0)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001011 (0)(1)(0)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001100 (0)(1)(0)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001101 (0)(1)(0)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001110 (0)(1)(0)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01001111 (0)(1)(0)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010000 (0)(1)(0)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010001 (0)(1)(0)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010010 (0)(1)(0)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010011 (0)(1)(0)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010100 (0)(1)(0)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010101 (0)(1)(0)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010110 (0)(1)(0)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01010111 (0)(1)(0)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011000 (0)(1)(0)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011001 (0)(1)(0)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011010 (0)(1)(0)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011011 (0)(1)(0)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011100 (0)(1)(0)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011101 (0)(1)(0)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011110 (0)(1)(0)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01011111 (0)(1)(0)(1)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100000 (0)(1)(1)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100001 (0)(1)(1)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100010 (0)(1)(1)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100011 (0)(1)(1)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100100 (0)(1)(1)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100101 (0)(1)(1)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100110 (0)(1)(1)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01100111 (0)(1)(1)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101000 (0)(1)(1)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101001 (0)(1)(1)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101010 (0)(1)(1)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101011 (0)(1)(1)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101100 (0)(1)(1)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101101 (0)(1)(1)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101110 (0)(1)(1)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01101111 (0)(1)(1)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110000 (0)(1)(1)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110001 (0)(1)(1)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110010 (0)(1)(1)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110011 (0)(1)(1)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110100 (0)(1)(1)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110101 (0)(1)(1)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110110 (0)(1)(1)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01110111 (0)(1)(1)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111000 (0)(1)(1)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111001 (0)(1)(1)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111010 (0)(1)(1)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111011 (0)(1)(1)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111100 (0)(1)(1)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111101 (0)(1)(1)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111110 (0)(1)(1)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_01111111 (0)(1)(1)(1)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000000 (1)(0)(0)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000001 (1)(0)(0)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000010 (1)(0)(0)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000011 (1)(0)(0)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000100 (1)(0)(0)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000101 (1)(0)(0)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000110 (1)(0)(0)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10000111 (1)(0)(0)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001000 (1)(0)(0)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001001 (1)(0)(0)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001010 (1)(0)(0)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001011 (1)(0)(0)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001100 (1)(0)(0)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001101 (1)(0)(0)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001110 (1)(0)(0)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10001111 (1)(0)(0)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010000 (1)(0)(0)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010001 (1)(0)(0)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010010 (1)(0)(0)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010011 (1)(0)(0)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010100 (1)(0)(0)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010101 (1)(0)(0)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010110 (1)(0)(0)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10010111 (1)(0)(0)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011000 (1)(0)(0)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011001 (1)(0)(0)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011010 (1)(0)(0)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011011 (1)(0)(0)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011100 (1)(0)(0)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011101 (1)(0)(0)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011110 (1)(0)(0)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10011111 (1)(0)(0)(1)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100000 (1)(0)(1)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100001 (1)(0)(1)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100010 (1)(0)(1)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100011 (1)(0)(1)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100100 (1)(0)(1)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100101 (1)(0)(1)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100110 (1)(0)(1)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10100111 (1)(0)(1)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101000 (1)(0)(1)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101001 (1)(0)(1)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101010 (1)(0)(1)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101011 (1)(0)(1)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101100 (1)(0)(1)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101101 (1)(0)(1)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101110 (1)(0)(1)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10101111 (1)(0)(1)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110000 (1)(0)(1)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110001 (1)(0)(1)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110010 (1)(0)(1)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110011 (1)(0)(1)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110100 (1)(0)(1)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110101 (1)(0)(1)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110110 (1)(0)(1)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10110111 (1)(0)(1)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111000 (1)(0)(1)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111001 (1)(0)(1)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111010 (1)(0)(1)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111011 (1)(0)(1)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111100 (1)(0)(1)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111101 (1)(0)(1)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111110 (1)(0)(1)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_10111111 (1)(0)(1)(1)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000000 (1)(1)(0)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000001 (1)(1)(0)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000010 (1)(1)(0)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000011 (1)(1)(0)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000100 (1)(1)(0)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000101 (1)(1)(0)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000110 (1)(1)(0)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11000111 (1)(1)(0)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001000 (1)(1)(0)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001001 (1)(1)(0)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001010 (1)(1)(0)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001011 (1)(1)(0)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001100 (1)(1)(0)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001101 (1)(1)(0)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001110 (1)(1)(0)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11001111 (1)(1)(0)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010000 (1)(1)(0)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010001 (1)(1)(0)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010010 (1)(1)(0)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010011 (1)(1)(0)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010100 (1)(1)(0)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010101 (1)(1)(0)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010110 (1)(1)(0)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11010111 (1)(1)(0)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011000 (1)(1)(0)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011001 (1)(1)(0)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011010 (1)(1)(0)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011011 (1)(1)(0)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011100 (1)(1)(0)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011101 (1)(1)(0)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011110 (1)(1)(0)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11011111 (1)(1)(0)(1)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100000 (1)(1)(1)(0)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100001 (1)(1)(1)(0)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100010 (1)(1)(1)(0)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100011 (1)(1)(1)(0)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100100 (1)(1)(1)(0)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100101 (1)(1)(1)(0)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100110 (1)(1)(1)(0)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11100111 (1)(1)(1)(0)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101000 (1)(1)(1)(0)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101001 (1)(1)(1)(0)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101010 (1)(1)(1)(0)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101011 (1)(1)(1)(0)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101100 (1)(1)(1)(0)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101101 (1)(1)(1)(0)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101110 (1)(1)(1)(0)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11101111 (1)(1)(1)(0)(1)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110000 (1)(1)(1)(1)(0)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110001 (1)(1)(1)(1)(0)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110010 (1)(1)(1)(1)(0)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110011 (1)(1)(1)(1)(0)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110100 (1)(1)(1)(1)(0)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110101 (1)(1)(1)(1)(0)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110110 (1)(1)(1)(1)(0)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11110111 (1)(1)(1)(1)(0)(1)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111000 (1)(1)(1)(1)(1)(0)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111001 (1)(1)(1)(1)(1)(0)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111010 (1)(1)(1)(1)(1)(0)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111011 (1)(1)(1)(1)(1)(0)(1)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111100 (1)(1)(1)(1)(1)(1)(0)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111101 (1)(1)(1)(1)(1)(1)(0)(1), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111110 (1)(1)(1)(1)(1)(1)(1)(0), +#define BOOST_DETAIL_BINARY_LITERAL_ELEMENT_11111111 (1)(1)(1)(1)(1)(1)(1)(1), + +#endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 56c84a4..321060c 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -15,6 +15,7 @@ test-suite utility [ run ../assert_test.cpp ] [ run ../base_from_member_test.cpp ] [ run ../binary_search_test.cpp ] + [ run ../binary_test.cpp ] [ run ../call_traits_test.cpp : -u ] [ compile-fail ../checked_delete_test.cpp ] [ run ../compressed_pair_test.cpp ../../test/build//boost_test_exec_monitor/static : -u ] diff --git a/utility.htm b/utility.htm index 1102d47..a2417ef 100644 --- a/utility.htm +++ b/utility.htm @@ -23,6 +23,8 @@
          • Function template addressof()
          • Class template result_of
          • +
          • + Macro BOOST_BINARY
          • Other utilities not part of utility.hpp

          @@ -183,9 +185,58 @@ void f() {

          Class templates for the Base-from-Member Idiom

          See separate documentation.

          +

          Macro BOOST_BINARY

          + +

          The macro BOOST_BINARY allows for the + representation of binary literals. It takes as an argument + a binary number arranged as an arbitrary amount of 1s and 0s in + groupings of length 1 to 8 inclusive, with groups separated + by spaces. The type of the literal yielded is determined by + the same rules as those of hex and octal + literals (2.13.1p1). By implementation, this macro + expands directly to an octal literal during preprocessing, so + there is no overhead at runtime and the result is useable in + any place that an octal literal would be.

          + +

          In order to directly support binary literals with suffixes, + additional macros of the form BOOST_BINARY_XXX are also + provided, where XXX is a standard integer suffix in all capital + letters. LL and ULL are also provided for representing long long + and unsigned long long types in compilers which provide them as + an extension.

          + + +

          The BOOST_BINARY family of macros reside in the header + <boost/utility/binary.hpp> + which is automatically included by + <boost/utility.hpp>. + +

          Contributed by Matt Calabrese.

          +

          Example

          +
          +
          +void foo( int );
          +
          +void foo( unsigned long );
          +
          +void bar()
          +{
          +  int value1 = BOOST_BINARY( 100 111000 01 1 110 );
          +
          +  unsigned long value2 = BOOST_BINARY_UL( 100 001 ); // unsigned long
          +
          +  foo( BOOST_BINARY( 1010 ) ); // calls the first foo
          +
          +  foo( BOOST_BINARY_LU( 1010 ) ); // calls the second foo
          +
          +  long long value4 = BOOST_BINARY_LL( 11 000 ); // long long if supported
          +}
          +

          Revised  07 November, 200704 September, 2008

          © Copyright Beman Dawes 1999-2003.

          @@ -193,4 +244,4 @@ void f() { www.boost.org/LICENSE_1_0.txt

          - \ No newline at end of file + From e86ce1cb1f6fa9ba93f0846de7d5d3dc2daa495d Mon Sep 17 00:00:00 2001 From: Matthew Calabrese Date: Sat, 6 Sep 2008 21:49:49 +0000 Subject: [PATCH 102/164] Changed wording for BOOST_BINARY docs. [SVN r48640] --- utility.htm | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/utility.htm b/utility.htm index a2417ef..6bc7bb4 100644 --- a/utility.htm +++ b/utility.htm @@ -187,10 +187,10 @@ void f() {

          See separate documentation.

          Macro BOOST_BINARY

          -

          The macro BOOST_BINARY allows for the +

          The macro BOOST_BINARY is used for the representation of binary literals. It takes as an argument a binary number arranged as an arbitrary amount of 1s and 0s in - groupings of length 1 to 8 inclusive, with groups separated + groupings of length 1 to 8, with groups separated by spaces. The type of the literal yielded is determined by the same rules as those of hex and octal literals (2.13.1p1). By implementation, this macro @@ -201,17 +201,19 @@ void f() {

          In order to directly support binary literals with suffixes, additional macros of the form BOOST_BINARY_XXX are also provided, where XXX is a standard integer suffix in all capital - letters. LL and ULL are also provided for representing long long - and unsigned long long types in compilers which provide them as - an extension.

          + letters. In addition, LL and ULL suffixes may be for representing + long long and unsigned long long types in compilers which provide + them as an extension.

          -

          The BOOST_BINARY family of macros reside in the header +

          The BOOST_BINARY family of macros resides in the header <boost/utility/binary.hpp> which is automatically included by <boost/utility.hpp>. + href="../../boost/utility.hpp"><boost/utility.hpp> and + <boost/binary.hpp>..

          Contributed by Matt Calabrese.

          Example

          @@ -227,11 +229,16 @@ void bar() unsigned long value2 = BOOST_BINARY_UL( 100 001 ); // unsigned long + long long value3 = BOOST_BINARY_LL( 11 000 ); // long long if supported + + assert( BOOST_BINARY( 10010 ) + & BOOST_BINARY( 11000 ) + == BOOST_BINARY( 10000 ) + ); + foo( BOOST_BINARY( 1010 ) ); // calls the first foo foo( BOOST_BINARY_LU( 1010 ) ); // calls the second foo - - long long value4 = BOOST_BINARY_LL( 11 000 ); // long long if supported }
          From 5d53e3f837db8eeb7feed769bb0e29d292e136f3 Mon Sep 17 00:00:00 2001 From: Matthew Calabrese Date: Sat, 6 Sep 2008 21:51:53 +0000 Subject: [PATCH 103/164] Changed BOOST_BINARY docs. [SVN r48641] --- utility.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility.htm b/utility.htm index 6bc7bb4..f9082f1 100644 --- a/utility.htm +++ b/utility.htm @@ -201,7 +201,7 @@ void f() {

          In order to directly support binary literals with suffixes, additional macros of the form BOOST_BINARY_XXX are also provided, where XXX is a standard integer suffix in all capital - letters. In addition, LL and ULL suffixes may be for representing + letters. In addition, LL and ULL suffixes may be used for representing long long and unsigned long long types in compilers which provide them as an extension.

          From 28061ba3a87c8422eade1be01111dcff3aa43a85 Mon Sep 17 00:00:00 2001 From: Matthew Calabrese Date: Wed, 17 Sep 2008 01:08:03 +0000 Subject: [PATCH 104/164] Removed boost directory binary.hpp. [SVN r48804] --- include/boost/binary.hpp | 14 -------------- utility.htm | 4 +--- 2 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 include/boost/binary.hpp diff --git a/include/boost/binary.hpp b/include/boost/binary.hpp deleted file mode 100644 index b4a889d..0000000 --- a/include/boost/binary.hpp +++ /dev/null @@ -1,14 +0,0 @@ -/*============================================================================= - Copyright (c) 2008 Matthew Calabrese - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ - -#ifndef BOOST_BINARY_HPP -#define BOOST_BINARY_HPP - -#include - -#endif diff --git a/utility.htm b/utility.htm index f9082f1..d4c7205 100644 --- a/utility.htm +++ b/utility.htm @@ -211,9 +211,7 @@ void f() { href="../../boost/utility/binary.hpp"><boost/utility/binary.hpp> which is automatically included by <boost/utility.hpp> and - <boost/binary.hpp>.. + href="../../boost/utility.hpp"><boost/utility.hpp>.

          Contributed by Matt Calabrese.

          Example

          From ddd8a58ae06dc389c7c9f267e911b8f9927c517f Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sat, 20 Sep 2008 15:39:47 +0000 Subject: [PATCH 105/164] Fixes #2341. [SVN r48910] --- include/boost/detail/call_traits.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/detail/call_traits.hpp b/include/boost/detail/call_traits.hpp index 54d441c..6ad646e 100644 --- a/include/boost/detail/call_traits.hpp +++ b/include/boost/detail/call_traits.hpp @@ -92,7 +92,7 @@ struct call_traits typedef T& param_type; // hh removed const }; -#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x581 ) ) +#if BOOST_WORKAROUND( __BORLANDC__, < 0x5A0 ) // these are illegal specialisations; cv-qualifies applied to // references have no effect according to [8.3.2p1], // C++ Builder requires them though as it treats cv-qualified From c4338b1ce814c5965befe97c62b5c00570dbc9fb Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 28 Sep 2008 12:21:39 +0000 Subject: [PATCH 106/164] Clean up some link errors. [SVN r48987] --- operators.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operators.htm b/operators.htm index 61c3629..a33e814 100644 --- a/operators.htm +++ b/operators.htm @@ -2030,7 +2030,7 @@ public: -

          Check the compiler status +

          Check the compiler status report for the test results with selected platforms.


          From 487a5c1ea55fa86365b1a87480a80e4da155b1ce Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Tue, 21 Oct 2008 09:55:54 +0000 Subject: [PATCH 107/164] Swap documentation: fixed a misspelling of the name of Steven Watanabe. [SVN r49416] --- swap.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swap.html b/swap.html index 2af5a88..01afd7c 100644 --- a/swap.html +++ b/swap.html @@ -73,7 +73,7 @@ Joseph Gauterin - for the initial idea, implementation, tests, and documentation
        • - Steven Wanatabe - for the idea to make boost::swap less specialized than std::swap, thereby allowing the function to have the name 'swap' without introducing ambiguity + Steven Watanabe - for the idea to make boost::swap less specialized than std::swap, thereby allowing the function to have the name 'swap' without introducing ambiguity
        @@ -84,7 +84,7 @@
        -

        Revised: 4 August 2008

        +

        Revised: 21 October 2008

        Copyright 2007, 2008 Joseph Gauterin. Use, modification, and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.) From ebe853ff2f4c0419c12ad084b18bbdd6ea056617 Mon Sep 17 00:00:00 2001 From: "Michael A. Jackson" Date: Sat, 1 Nov 2008 13:15:41 +0000 Subject: [PATCH 108/164] Continuing merge of CMake build system files into trunk with the encouragement of Doug Gregor [SVN r49510] --- CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ module.cmake | 1 + test/CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 module.cmake create mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6df7714 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,31 @@ +#---------------------------------------------------------------------------- +# This file was automatically generated from the original CMakeLists.txt file +# Add a variable to hold the headers for the library +set (lib_headers + assert.hpp + call_traits.hpp + checked_delete.hpp + compressed_pair.hpp + current_function.hpp + operators.hpp + throw_exception.hpp + utility.hpp + utility +) + +# Add a library target to the build system +boost_library_project( + utility + # SRCDIRS + TESTDIRS test + HEADERS ${lib_headers} + # DOCDIRS + DESCRIPTION "Various small utilities for C++ programming." + MODULARIZED + AUTHORS "David Abrahams " + "Brad King" + "Douglas Gregor " + # MAINTAINERS +) + + diff --git a/module.cmake b/module.cmake new file mode 100644 index 0000000..4d78340 --- /dev/null +++ b/module.cmake @@ -0,0 +1 @@ +boost_module(utility DEPENDS iterator exception detail ) \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..bd81db0 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,36 @@ +boost_test_run(addressof_test ../addressof_test.cpp) +boost_test_run(assert_test ../assert_test.cpp) +boost_test_run(base_from_member_test ../base_from_member_test.cpp) +boost_test_run(binary_search_test ../binary_search_test.cpp) +boost_test_run(call_traits_test ../call_traits_test.cpp ARGS -u) +boost_test_compile_fail(checked_delete_test ../checked_delete_test.cpp) +boost_test_run(compressed_pair_test + ../compressed_pair_test + DEPENDS boost_test_exec_monitor) +boost_test_run(current_function_test ../current_function_test.cpp) +boost_test_run(iterators_test + ../iterators_test.cpp + DEPENDS boost_test_exec_monitor) +boost_test_run(next_prior_test DEPENDS boost_test_exec_monitor) +boost_test_compile_fail(noncopyable_test ../noncopyable_test.cpp) +boost_test_run(numeric_traits_test ../numeric_traits_test.cpp) +if (${CMAKE_SYSTEM} MATCHES "FreeBSD-.*") +boost_test_compile_fail("operators_test_compilerbug") +elseif(${CMAKE_SYSTEM} MATCHES "FreeBSD-.*") +boost_test_run(operators_test + ../operators_test.cpp + DEPENDS boost_test_exec_monitor) +endif(${CMAKE_SYSTEM} MATCHES "FreeBSD-.*") +boost_test_compile(ref_ct_test ../ref_ct_test.cpp) +boost_test_run(ref_test + ../ref_test.cpp + DEPENDS boost_test_exec_monitor) +boost_test_compile(result_of_test) +boost_test_run(shared_iterator_test ../shared_iterator_test.cpp) +boost_test_run(value_init_test ../value_init_test.cpp) +boost_test_compile_fail(value_init_test_fail1 + ../value_init_test_fail1.cpp) +boost_test_compile_fail(value_init_test_fail2 + ../value_init_test_fail2.cpp) +boost_test_compile_fail(value_init_test_fail3 + ../value_init_test_fail3.cpp) From 53f6d106527b0293a98dbdf05f7619f7fc294fcd Mon Sep 17 00:00:00 2001 From: "Michael A. Jackson" Date: Fri, 7 Nov 2008 17:02:56 +0000 Subject: [PATCH 109/164] Updating CMake files to latest trunk. Added dependency information for regression tests and a few new macros for internal use. [SVN r49627] --- test/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bd81db0..fee1ccb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,5 @@ +boost_additional_test_dependencies(utility BOOST_DEPENDS test) + boost_test_run(addressof_test ../addressof_test.cpp) boost_test_run(assert_test ../assert_test.cpp) boost_test_run(base_from_member_test ../base_from_member_test.cpp) From 57124703f9644f88c74ae2c46f6731ecd9e5596d Mon Sep 17 00:00:00 2001 From: "Michael A. Jackson" Date: Tue, 11 Nov 2008 17:22:34 +0000 Subject: [PATCH 110/164] Fixing include path to compile with modularized source tree. [SVN r49685] --- include/boost/swap.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/swap.hpp b/include/boost/swap.hpp index 2d8b44c..dfc11f0 100644 --- a/include/boost/swap.hpp +++ b/include/boost/swap.hpp @@ -7,6 +7,6 @@ #ifndef BOOST_SWAP_HPP #define BOOST_SWAP_HPP -#include "./utility/swap.hpp" +#include "boost/utility/swap.hpp" #endif From 561f83b991dc1e33e617f721f98904fa2f3d43a9 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sat, 15 Nov 2008 15:07:42 +0000 Subject: [PATCH 111/164] Updated swap.html because LWG issue 809 is now accepted as a defect. Fixed some HTML formatting. [SVN r49771] --- swap.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/swap.html b/swap.html index 01afd7c..4022e0b 100644 --- a/swap.html +++ b/swap.html @@ -14,7 +14,7 @@ template<class T> void swap(T& left, T& right);

        - +

        The template function boost::swap allows the values of two variables to be swapped, using argument dependent lookup to select a specialized swap function if available. If no specialized swap function is available, std::swap is used.

        @@ -24,10 +24,10 @@

        The generic std::swap function requires that the elements to be swapped are assignable and copy constructible. It is usually implemented using one copy construction and two assignments - this is often both unnecessarily restrictive and unnecessarily slow. In addition, where the generic swap implementation provides only the basic guarantee, specialized swap functions are often able to provide the no-throw exception guarantee (and it is considered best practice to do so where possible1).

        - The alternative to using argument dependent lookup in this situation is to provide a template specialization of std::swap for every type that requires a specialized swap. Although this is legal C++, no Boost libraries use this method, whereas many Boost libraries provide specialized swap functions in their own namespaces. + The alternative to using argument dependent lookup in this situation is to provide a template specialization of std::swap for every type that requires a specialized swap. Although this is legal C++, no Boost libraries use this method, whereas many Boost libraries provide specialized swap functions in their own namespaces.

        - boost::swap also supports swapping built-in arrays. Note that std::swap doesn't yet do so, but a request to add an overload of std::swap for built-in arrays has been well-received by the Library Working Group of the C++ Standards Committee2. + boost::swap also supports swapping built-in arrays. Note that std::swap originally did not do so, but a request to add an overload of std::swap for built-in arrays has been accepted by the C++ Standards Committee2.

        @@ -45,11 +45,11 @@

      Or:

        -
      • A function with the signature swap(T&,T&) is available via argument dependent lookup
      • +
      • A function with the signature swap(T&,T&) is available via argument dependent lookup

      Or:

        -
      • A template specialization of std::swap exists for T
      • +
      • A template specialization of std::swap exists for T

      Or:

        @@ -73,18 +73,18 @@ Joseph Gauterin - for the initial idea, implementation, tests, and documentation
      • - Steven Watanabe - for the idea to make boost::swap less specialized than std::swap, thereby allowing the function to have the name 'swap' without introducing ambiguity + Steven Watanabe - for the idea to make boost::swap less specialized than std::swap, thereby allowing the function to have the name 'swap' without introducing ambiguity

      [1]Scott Meyers, Effective C++ Third Edition, Item 25: "Consider support for a non-throwing swap"

      -

      [2]LWG issue 809 (std::swap should be overloaded for array types)

      +

      [2]LWG Defect Report 809 (std::swap should be overloaded for array types)


      -

      Revised: 21 October 2008

      +

      Revised: 15 November 2008

      Copyright 2007, 2008 Joseph Gauterin. Use, modification, and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.) From d153ab4daa94d4433c6afe1af475930ce0b2a8c9 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 16 Nov 2008 23:10:00 +0000 Subject: [PATCH 112/164] Fix a typo. [SVN r49811] --- in_place_factories.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/in_place_factories.html b/in_place_factories.html index b36387d..d3791f8 100644 --- a/in_place_factories.html +++ b/in_place_factories.html @@ -99,7 +99,7 @@ directly to the container:

      Framework

      This library proposes a framework to allow some containers to directly contruct contained objects in-place without requiring -the entire set of constructor overloads ftom the contained type. It also allows the container to remove the CopyConstuctible +the entire set of constructor overloads from the contained type. It also allows the container to remove the CopyConstuctible requirement from the contained type since objects can be directly constructed in-place without need of a copy.
      The only requirement on the container is that it must provide proper storage (that is, correctly aligned and sized). Naturally, the container will typically support uninitialized storage to avoid the in-place construction to override @@ -293,4 +293,4 @@ the latest version of this file can be found at www.boost.org, and the boost discussion lists

      - \ No newline at end of file + From d420c98a53901afa6052a40ee14517e6b2434e3a Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Fri, 21 Nov 2008 21:28:47 +0000 Subject: [PATCH 113/164] Added array_of_template test, testing the boost::swap utility on an array of objects of a template class. [SVN r49862] --- swap/test/Jamfile.v2 | 1 + swap/test/array_of_template.cpp | 68 +++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 swap/test/array_of_template.cpp diff --git a/swap/test/Jamfile.v2 b/swap/test/Jamfile.v2 index 7071837..617f7e8 100644 --- a/swap/test/Jamfile.v2 +++ b/swap/test/Jamfile.v2 @@ -29,5 +29,6 @@ test-suite utility/swap [ run std_vector_of_global.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run std_vector_of_other.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run no_ambiguity_in_boost.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run array_of_template.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/static ] ; diff --git a/swap/test/array_of_template.cpp b/swap/test/array_of_template.cpp new file mode 100644 index 0000000..e6e465f --- /dev/null +++ b/swap/test/array_of_template.cpp @@ -0,0 +1,68 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in the global namespace +#include "./swap_test_class.hpp" + +#include //for std::copy and std::equal +#include //for std::size_t + +template +class swap_test_template +{ +public: + swap_test_class swap_test_object; +}; + +template +inline bool operator==(const swap_test_template & lhs, const swap_test_template & rhs) +{ + return lhs.swap_test_object == rhs.swap_test_object; +} + +template +inline bool operator!=(const swap_test_template & lhs, const swap_test_template & rhs) +{ + return !(lhs == rhs); +} + +//Provide swap function in the namespace of swap_test_template +//(which is the global namespace). Note that it isn't allowed to put +//an overload of this function within the std namespace. +template +void swap(swap_test_template& left, swap_test_template& right) +{ + left.swap_test_object.swap(right.swap_test_object); +} + + +int test_main(int, char*[]) +{ + const std::size_t dimension = 2; + const swap_test_template initial_array1[dimension] = { swap_test_class(1), swap_test_class(2) }; + const swap_test_template initial_array2[dimension] = { swap_test_class(3), swap_test_class(4) }; + + swap_test_template array1[dimension]; + swap_test_template array2[dimension]; + + std::copy(initial_array1, initial_array1 + dimension, array1); + std::copy(initial_array2, initial_array2 + dimension, array2); + + swap_test_class::reset(); + boost::swap(array1, array2); + + BOOST_CHECK(std::equal(array1, array1 + dimension, initial_array2)); + BOOST_CHECK(std::equal(array2, array2 + dimension, initial_array1)); + + BOOST_CHECK_EQUAL(swap_test_class::swap_count(), dimension); + BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); + + return 0; +} From d4b6193f94152f65e07a19f246361d3e2f13cabe Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Mon, 24 Nov 2008 17:41:15 +0000 Subject: [PATCH 114/164] Replaced swap/test/swap_arrays by more specific tests: array_of_array, array_of_class, and array_of_int. [SVN r49916] --- swap/test/Jamfile.v2 | 6 +- .../{swap_arrays.cpp => array_of_array.cpp} | 35 +---------- swap/test/array_of_class.cpp | 59 +++++++++++++++++++ swap/test/array_of_int.cpp | 33 +++++++++++ 4 files changed, 97 insertions(+), 36 deletions(-) rename swap/test/{swap_arrays.cpp => array_of_array.cpp} (66%) create mode 100644 swap/test/array_of_class.cpp create mode 100644 swap/test/array_of_int.cpp diff --git a/swap/test/Jamfile.v2 b/swap/test/Jamfile.v2 index 617f7e8..de1cd69 100644 --- a/swap/test/Jamfile.v2 +++ b/swap/test/Jamfile.v2 @@ -29,6 +29,8 @@ test-suite utility/swap [ run std_vector_of_global.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run std_vector_of_other.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run no_ambiguity_in_boost.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run array_of_template.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run array_of_array.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run array_of_class.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run array_of_int.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run array_of_template.cpp ../../../test/build//boost_test_exec_monitor/static ] ; diff --git a/swap/test/swap_arrays.cpp b/swap/test/array_of_array.cpp similarity index 66% rename from swap/test/swap_arrays.cpp rename to swap/test/array_of_array.cpp index eeb64bc..06eee48 100644 --- a/swap/test/swap_arrays.cpp +++ b/swap/test/array_of_array.cpp @@ -33,32 +33,8 @@ namespace std } } -// Tests swapping 1-dimensional arrays. -void test_swapping_1D_arrays() -{ - const std::size_t dimension = 2; - const swap_test_class initial_array1[dimension] = { swap_test_class(1), swap_test_class(2) }; - const swap_test_class initial_array2[dimension] = { swap_test_class(3), swap_test_class(4) }; - - swap_test_class array1[dimension]; - swap_test_class array2[dimension]; - std::copy(initial_array1, initial_array1 + dimension, array1); - std::copy(initial_array2, initial_array2 + dimension, array2); - - swap_test_class::reset(); - boost::swap(array1, array2); - - BOOST_CHECK(std::equal(array1, array1 + dimension, initial_array2)); - BOOST_CHECK(std::equal(array2, array2 + dimension, initial_array1)); - - BOOST_CHECK_EQUAL(swap_test_class::swap_count(), dimension); - BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); -} - - -// Tests swapping 2-dimensional arrays. -void test_swapping_2D_arrays() +int test_main(int, char*[]) { const std::size_t first_dimension = 3; const std::size_t second_dimension = 4; @@ -76,7 +52,6 @@ void test_swapping_2D_arrays() ptr2[i].set_data( static_cast(i + number_of_elements) ); } - swap_test_class::reset(); boost::swap(array1, array2); for (std::size_t i = 0; i < number_of_elements; ++i) @@ -87,14 +62,6 @@ void test_swapping_2D_arrays() BOOST_CHECK_EQUAL(swap_test_class::swap_count(), number_of_elements); BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); -} - - -int test_main(int, char*[]) -{ - test_swapping_1D_arrays(); - test_swapping_2D_arrays(); return 0; } - diff --git a/swap/test/array_of_class.cpp b/swap/test/array_of_class.cpp new file mode 100644 index 0000000..df79801 --- /dev/null +++ b/swap/test/array_of_class.cpp @@ -0,0 +1,59 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +//Put test class in the global namespace +#include "./swap_test_class.hpp" + +#include //for std::copy and std::equal +#include //for std::size_t + +//Provide swap function in both the namespace of swap_test_class +//(which is the global namespace), and the std namespace. +//It's common to provide a swap function for a class in both +//namespaces. Scott Meyers recommends doing so: Effective C++, +//Third Edition, item 25, "Consider support for a non-throwing swap". +void swap(swap_test_class& left, swap_test_class& right) +{ + left.swap(right); +} + +namespace std +{ + template <> + void swap(swap_test_class& left, swap_test_class& right) + { + left.swap(right); + } +} + + +int test_main(int, char*[]) +{ + const std::size_t array_size = 2; + const swap_test_class initial_array1[array_size] = { swap_test_class(1), swap_test_class(2) }; + const swap_test_class initial_array2[array_size] = { swap_test_class(3), swap_test_class(4) }; + + swap_test_class array1[array_size]; + swap_test_class array2[array_size]; + + std::copy(initial_array1, initial_array1 + array_size, array1); + std::copy(initial_array2, initial_array2 + array_size, array2); + + swap_test_class::reset(); + boost::swap(array1, array2); + + BOOST_CHECK(std::equal(array1, array1 + array_size, initial_array2)); + BOOST_CHECK(std::equal(array2, array2 + array_size, initial_array1)); + + BOOST_CHECK_EQUAL(swap_test_class::swap_count(), array_size); + BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); + + return 0; +} diff --git a/swap/test/array_of_int.cpp b/swap/test/array_of_int.cpp new file mode 100644 index 0000000..f919613 --- /dev/null +++ b/swap/test/array_of_int.cpp @@ -0,0 +1,33 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#define BOOST_INCLUDE_MAIN +#include + +#include //for std::copy and std::equal +#include //for std::size_t + + +int test_main(int, char*[]) +{ + const std::size_t array_size = 3; + const int initial_array1[array_size] = { 1, 2, 3 }; + const int initial_array2[array_size] = { 4, 5, 6 }; + + int array1[array_size]; + int array2[array_size]; + + std::copy(initial_array1, initial_array1 + array_size, array1); + std::copy(initial_array2, initial_array2 + array_size, array2); + + boost::swap(array1, array2); + + BOOST_CHECK(std::equal(array1, array1 + array_size, initial_array2)); + BOOST_CHECK(std::equal(array2, array2 + array_size, initial_array1)); + + return 0; +} From 118e473a3d2f2286f2250f8a1018b35db2dc9d4c Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Thu, 27 Nov 2008 11:08:05 +0000 Subject: [PATCH 115/164] [utility/swap] Added comment to various array swapping tests, added member typedef to swap_test_template, to make the test more realistic. [SVN r49953] --- swap/test/array_of_class.cpp | 2 ++ swap/test/array_of_int.cpp | 2 ++ swap/test/array_of_template.cpp | 23 +++++++++++++---------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/swap/test/array_of_class.cpp b/swap/test/array_of_class.cpp index df79801..356762d 100644 --- a/swap/test/array_of_class.cpp +++ b/swap/test/array_of_class.cpp @@ -4,6 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +// Tests swapping an array of arrays of swap_test_class objects by means of boost::swap. + #include #define BOOST_INCLUDE_MAIN #include diff --git a/swap/test/array_of_int.cpp b/swap/test/array_of_int.cpp index f919613..22a7dde 100644 --- a/swap/test/array_of_int.cpp +++ b/swap/test/array_of_int.cpp @@ -4,6 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +// Tests swapping an array of integers by means of boost::swap. + #include #define BOOST_INCLUDE_MAIN #include diff --git a/swap/test/array_of_template.cpp b/swap/test/array_of_template.cpp index e6e465f..8f350ad 100644 --- a/swap/test/array_of_template.cpp +++ b/swap/test/array_of_template.cpp @@ -4,6 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +// Tests swapping an array of swap_test_template objects by means of boost::swap. + #include #define BOOST_INCLUDE_MAIN #include @@ -18,6 +20,7 @@ template class swap_test_template { public: + typedef T template_argument; swap_test_class swap_test_object; }; @@ -45,23 +48,23 @@ void swap(swap_test_template& left, swap_test_template& right) int test_main(int, char*[]) { - const std::size_t dimension = 2; - const swap_test_template initial_array1[dimension] = { swap_test_class(1), swap_test_class(2) }; - const swap_test_template initial_array2[dimension] = { swap_test_class(3), swap_test_class(4) }; + const std::size_t array_size = 2; + const swap_test_template initial_array1[array_size] = { swap_test_class(1), swap_test_class(2) }; + const swap_test_template initial_array2[array_size] = { swap_test_class(3), swap_test_class(4) }; - swap_test_template array1[dimension]; - swap_test_template array2[dimension]; + swap_test_template array1[array_size]; + swap_test_template array2[array_size]; - std::copy(initial_array1, initial_array1 + dimension, array1); - std::copy(initial_array2, initial_array2 + dimension, array2); + std::copy(initial_array1, initial_array1 + array_size, array1); + std::copy(initial_array2, initial_array2 + array_size, array2); swap_test_class::reset(); boost::swap(array1, array2); - BOOST_CHECK(std::equal(array1, array1 + dimension, initial_array2)); - BOOST_CHECK(std::equal(array2, array2 + dimension, initial_array1)); + BOOST_CHECK(std::equal(array1, array1 + array_size, initial_array2)); + BOOST_CHECK(std::equal(array2, array2 + array_size, initial_array1)); - BOOST_CHECK_EQUAL(swap_test_class::swap_count(), dimension); + BOOST_CHECK_EQUAL(swap_test_class::swap_count(), array_size); BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); return 0; From 97e11b024ed2068ddce6986ac719d2d4d25aa27c Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Thu, 27 Nov 2008 11:14:52 +0000 Subject: [PATCH 116/164] [utility/swap] Distinguished between testing array-of-array-of-class and array-of-array-of-int, as the latter appears to succeed on CodeGear 6.10 while the former does not. [SVN r49954] --- swap/test/Jamfile.v2 | 3 +- ..._array.cpp => array_of_array_of_class.cpp} | 2 + swap/test/array_of_array_of_int.cpp | 42 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) rename swap/test/{array_of_array.cpp => array_of_array_of_class.cpp} (95%) create mode 100644 swap/test/array_of_array_of_int.cpp diff --git a/swap/test/Jamfile.v2 b/swap/test/Jamfile.v2 index de1cd69..f5b0d46 100644 --- a/swap/test/Jamfile.v2 +++ b/swap/test/Jamfile.v2 @@ -29,7 +29,8 @@ test-suite utility/swap [ run std_vector_of_global.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run std_vector_of_other.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run no_ambiguity_in_boost.cpp ../../../test/build//boost_test_exec_monitor/static ] - [ run array_of_array.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run array_of_array_of_class.cpp ../../../test/build//boost_test_exec_monitor/static ] + [ run array_of_array_of_int.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run array_of_class.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run array_of_int.cpp ../../../test/build//boost_test_exec_monitor/static ] [ run array_of_template.cpp ../../../test/build//boost_test_exec_monitor/static ] diff --git a/swap/test/array_of_array.cpp b/swap/test/array_of_array_of_class.cpp similarity index 95% rename from swap/test/array_of_array.cpp rename to swap/test/array_of_array_of_class.cpp index 06eee48..4f02578 100644 --- a/swap/test/array_of_array.cpp +++ b/swap/test/array_of_array_of_class.cpp @@ -4,6 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +// Tests swapping an array of arrays of swap_test_class objects by means of boost::swap. + #include #define BOOST_INCLUDE_MAIN #include diff --git a/swap/test/array_of_array_of_int.cpp b/swap/test/array_of_array_of_int.cpp new file mode 100644 index 0000000..c1778ec --- /dev/null +++ b/swap/test/array_of_array_of_int.cpp @@ -0,0 +1,42 @@ +// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Tests swapping an array of arrays of integers by means of boost::swap. + +#include +#define BOOST_INCLUDE_MAIN +#include + +#include //for std::copy and std::equal +#include //for std::size_t + +int test_main(int, char*[]) +{ + const std::size_t first_dimension = 3; + const std::size_t second_dimension = 4; + const std::size_t number_of_elements = first_dimension * second_dimension; + + int array1[first_dimension][second_dimension]; + int array2[first_dimension][second_dimension]; + + int* const ptr1 = array1[0]; + int* const ptr2 = array2[0]; + + for (std::size_t i = 0; i < number_of_elements; ++i) + { + ptr1[i] = static_cast(i); + ptr2[i] = static_cast(i + number_of_elements); + } + + boost::swap(array1, array2); + + for (std::size_t i = 0; i < number_of_elements; ++i) + { + BOOST_CHECK_EQUAL(ptr1[i], static_cast(i + number_of_elements) ); + BOOST_CHECK_EQUAL(ptr2[i], static_cast(i) ); + } + return 0; +} From 6725719bd94ad616ab514691d6ec330c6e8e149a Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 29 Jan 2009 19:13:08 +0000 Subject: [PATCH 117/164] This html was outdated; changed to forward to throw_exception.html documentation from Boost Exception [SVN r50879] --- throw_exception.html | 69 +++++++++----------------------------------- 1 file changed, 13 insertions(+), 56 deletions(-) diff --git a/throw_exception.html b/throw_exception.html index 66a63f3..141f487 100644 --- a/throw_exception.html +++ b/throw_exception.html @@ -1,58 +1,15 @@ - + - - Boost: throw_exception.hpp documentation - - - - - - - - - - - -
      boost.png (6897 bytes) - -

      throw_exception.hpp

      -
       
      -

      - The header <boost/throw_exception.hpp> defines the - helper function boost::throw_exception. It is intended to be - used in Boost libraries that need to throw exceptions, but support - configurations and platforms where exceptions aren't available, as indicated by - the presence of the BOOST_NO_EXCEPTIONS - configuration macro. -

      -

      When BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) - is equivalent to throw e. Otherwise, the function is left undefined, - and the user is expected to supply an appropriate definition. Callers of throw_exception - are allowed to assume that the function never returns; therefore, if the - user-defined throw_exception returns, the behavior is undefined.

      -

      Synopsis

      -
      -namespace boost
      -{
      -
      -#ifdef BOOST_NO_EXCEPTIONS
      -
      -void throw_exception(std::exception const & e); // user defined
      -
      -#else
      -
      -template<class E> void throw_exception(E const & e)
      -{
      -    throw e;
      -}
      -
      -#endif
      -
      -}
      -
      -


      - Copyright © 2002 by Peter Dimov. Distributed under the Boost Software License, Version - 1.0. See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt.

      - + + +Automatic redirection + + +Automatic redirection failed, please go to +throw_exception.html
      +

      © Copyright Beman Dawes, 2001

      +

      Distributed under the Boost Software License, Version 1.0. (See accompanying +file LICENSE_1_0.txt or copy +at www.boost.org/LICENSE_1_0.txt)

      + From 0282c8a14177cf672bf09f10becf36b8336e20fc Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Fri, 30 Jan 2009 00:06:01 +0000 Subject: [PATCH 118/164] added #error in headers incompatible with BOOST_NO_EXCEPTIONS [SVN r50887] --- include/boost/exception.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/exception.hpp b/include/boost/exception.hpp index c77f215..b4716a0 100644 --- a/include/boost/exception.hpp +++ b/include/boost/exception.hpp @@ -12,6 +12,8 @@ #include #include #include +#ifndef BOOST_NO_EXCEPTIONS #include +#endif #endif From 5f0cf4f5dea6c28c9cb1bc5ad961ffae1e2f8b7c Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Fri, 20 Feb 2009 20:28:54 +0000 Subject: [PATCH 119/164] Fixed const issue of value_initialized according to ticket #2548. See also http://lists.boost.org/Archives/boost/2009/02/148489.php [SVN r51355] --- include/boost/utility/value_init.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index aa7ecb4..5aefac9 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -8,6 +8,7 @@ // 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 // 21 Ago 2008 (Added swap) Niels Dekker, Fernando Cacciola +// 20 Feb 2009 (Fixed logical const-ness issues) Niels Dekker, Fernando Cacciola // #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP @@ -90,7 +91,12 @@ class value_initialized wrapper_address()->wrapper::~wrapper(); } - T& data() const + T const & data() const + { + return wrapper_address()->data; + } + + T& data() { return wrapper_address()->data; } @@ -100,7 +106,9 @@ class value_initialized ::boost::swap( this->data(), arg.data() ); } - operator T&() const { return this->data(); } + operator T const &() const { return this->data(); } + + operator T&() { return this->data(); } } ; From 0af1959b304c12d38dce5b61835954498273a754 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Fri, 20 Feb 2009 20:35:34 +0000 Subject: [PATCH 120/164] Updated value_initialized documentation and test following changeset [51355]. [SVN r51356] --- value_init.htm | 68 ++++++++++++++++++++++++++++++--------------- value_init_test.cpp | 2 +- 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/value_init.htm b/value_init.htm index 5c1b20e..5c50fd9 100644 --- a/value_init.htm +++ b/value_init.htm @@ -253,7 +253,33 @@ its internal data, prior to constructing the object that it contains.

      template class value_initialized<T>

      -
      namespace boost {

      template<class T>
      class value_initialized
      {
      public :
      value_initialized() : x() {}
      operator T&() const { return x ; }
      T& data() const { return x ; }
      void swap( value_initialized<T>& );

      private :
      unspecified x ;
      } ;

      template<class T>
      T const& get ( value_initialized<T> const& x )
      {
      return x.data() ;
      }

      template<class T>
      T& get ( value_initialized<T>& x )
      {
      return x.data() ;
      }

      } // namespace boost
      +
      namespace boost {

      template<class T>
      class value_initialized
      { +
      public : +
      value_initialized() : x() {} +
      operator T const &() const { return x ; } +
      operator T&() { return x ; } +
      T const &data() const { return x ; } +
      T& data() { return x ; } +
      void swap( value_initialized<T>& ); +
      +
      private : +
      unspecified x ; +
      } ; +
      +
      template<class T> +
      T const& get ( value_initialized<T> const& x ) +
      { +
      return x.data() ; +
      } +
      +
      template<class T> +
      T& get ( value_initialized<T>& x ) +
      { +
      return x.data() ; +
      } +
      +
      } // namespace boost +

      An object of this template class is a T-wrapper convertible to 'T&' whose wrapped object (data member of type T) @@ -271,7 +297,8 @@ its internal data, prior to constructing the object that it contains. T&, the member function data(), or the non-member function get():

      -
      void watch(int);
      value_initialized<int> x;

      watch(x) ; // operator T& used.
      watch(x.data());
      watch( get(x) ) // function get() used
      +
      void watch(int);
      value_initialized<int> x; +

      watch(x) ; // operator T& used.
      watch(x.data());
      watch( get(x) ) // function get() used

      Both const and non-const objects can be wrapped. Mutable objects can be modified directly from within the wrapper but constant @@ -281,37 +308,34 @@ non-member function get():

      is swappable as well, by calling its swap member function as well as by calling boost::swap.

      -
      value_initialized<int> x ; 
      static_cast<int&>(x) = 1 ; // OK
      get(x) = 1 ; // OK

      value_initialized<int const> y ;
      static_cast<int&>(y) = 1 ; // ERROR: cannot cast to int&
      static_cast<int const&>(y) = 1 ; // ERROR: cannot modify a const value
      get(y) = 1 ; // ERROR: cannot modify a const value
      +
      value_initialized<int> x ; 
      static_cast<int&>(x) = 1 ; // OK
      get(x) = 1 ; // OK +

      value_initialized<int const> y ;
      static_cast<int&>(y) = 1 ; // ERROR: cannot cast to int&
      static_cast<int const&>(y) = 1 ; // ERROR: cannot modify a const value
      get(y) = 1 ; // ERROR: cannot modify a const value

      Warning:

      -

      Both the conversion operator and the data() member function - are const in order to allow access to the wrapped object -from a constant wrapper:

      +

      The value_initialized implementation of Boost version 1.38.0 and older +allowed non-const access to the wrapped object, from a constant wrapper, +both by its conversion operator and its data() member function. For example:

      -
      void foo(int);
      value_initialized<int> const x ;
      foo(x);
      +
      value_initialized<int> const x_c ;
      int& xr = x_c ; // OK, conversion to int& available even though x_c is itself const. +
      xr = 2 ;
      -

      But notice that this conversion operator is to T& although - it is itself const. As a consequence, if T is - a non-const type, you can modify the wrapped object even from - within a constant wrapper:

      - -
      value_initialized<int> const x_c ;
      int& xr = x_c ; // OK, conversion to int& available even though x_c is itself const.
      xr = 2 ;
      - -

      The reason for this obscure behavior is that some commonly used compilers - just don't accept the following valid code:

      +

      The reason for this obscure behavior was that some compilers + didn't accept the following valid code:

      struct X
      {
      operator int&() ;
      operator int const&() const ;
      };
      X x ;
      (x == 1 ) ; // ERROR HERE!
      -

      These compilers complain about ambiguity between the conversion operators. - This complaint is incorrect, but the only workaround that I know of is - to provide only one of them, which leads to the obscure behavior just explained.
      +

      The current version of value_initialized no longer has this obscure behavior. +As compilers nowadays widely support overloading the conversion operator by having a const and a non-const version, we have decided to fix the issue accordingly. So the current version supports the idea of logical constness. +

      Recommended practice: The non-member get() idiom

      The obscure behavior of being able to modify a non-const -wrapped object from within a constant wrapper can be avoided if access to +wrapped object from within a constant wrapper (as was supported by previous +versions of value_initialized) +can be avoided if access to the wrapped object is always performed with the get() idiom:

      value_initialized<int> x ;
      get(x) = 1 ; // OK

      value_initialized<int const> cx ;
      get(x) = 1 ; // ERROR: Cannot modify a const object

      value_initialized<int> const x_c ;
      get(x_c) = 1 ; // ERROR: Cannot modify a const object

      value_initialized<int const> const cx_c ;
      get(cx_c) = 1 ; // ERROR: Cannot modify a const object
      @@ -383,9 +407,9 @@ for Boost release version 1.35 (2008), offering a workaround to various compiler


      -

      Revised 28 August 2008

      +

      Revised 20 February 2009

      -

      © Copyright Fernando Cacciola, 2002, 2008.

      +

      © Copyright Fernando Cacciola, 2002, 2009.

      Distributed under the Boost Software License, Version 1.0. See www.boost.org/LICENSE_1_0.txt

      diff --git a/value_init_test.cpp b/value_init_test.cpp index 63f324d..67ebad8 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -260,7 +260,7 @@ bool test ( T const& y, T const& z ) boost::value_initialized const x_c ; BOOST_CHECK ( y == x_c ) ; BOOST_CHECK ( y == boost::get(x_c) ) ; - T& x_c_ref = x_c ; + T& x_c_ref = const_cast( boost::get(x_c) ) ; x_c_ref = z ; BOOST_CHECK ( x_c == z ) ; From f7aa9a893587b4a2b1e75fb4e756f0236eea0580 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 1 Mar 2009 17:04:14 +0000 Subject: [PATCH 121/164] Refs #2128 (fixed in trunk.) [SVN r51512] --- include/boost/ref.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 9c996ab..6058d69 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -179,6 +179,11 @@ unwrap_ref(T& t) return t; } +template inline T* get_pointer( reference_wrapper const & r ) +{ + return r.get_pointer(); +} + } // namespace boost #endif // #ifndef BOOST_REF_HPP_INCLUDED From e27fc4a85316556dc9ec235cbd6076bb661b1fe1 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 20 Mar 2009 17:14:00 +0000 Subject: [PATCH 122/164] Attempt to fix addressof in trunk to handle classes with conversion operators. Refs #2878. [SVN r51872] --- addressof_fn_test.cpp | 76 +++++++++++++++++++++++ addressof_test2.cpp | 95 +++++++++++++++++++++++++++++ include/boost/utility/addressof.hpp | 16 +++++ test/Jamfile.v2 | 2 + 4 files changed, 189 insertions(+) create mode 100644 addressof_fn_test.cpp create mode 100644 addressof_test2.cpp diff --git a/addressof_fn_test.cpp b/addressof_fn_test.cpp new file mode 100644 index 0000000..0d043bf --- /dev/null +++ b/addressof_fn_test.cpp @@ -0,0 +1,76 @@ +#include + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +// addressof_fn_test.cpp: addressof( f ) +// +// Copyright (c) 2008, 2009 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +#include +#include + + +void f0() +{ +} + +void f1(int) +{ +} + +void f2(int, int) +{ +} + +void f3(int, int, int) +{ +} + +void f4(int, int, int, int) +{ +} + +void f5(int, int, int, int, int) +{ +} + +void f6(int, int, int, int, int, int) +{ +} + +void f7(int, int, int, int, int, int, int) +{ +} + +void f8(int, int, int, int, int, int, int, int) +{ +} + +void f9(int, int, int, int, int, int, int, int, int) +{ +} + +int main() +{ + BOOST_TEST( boost::addressof( f0 ) == &f0 ); + BOOST_TEST( boost::addressof( f1 ) == &f1 ); + BOOST_TEST( boost::addressof( f2 ) == &f2 ); + BOOST_TEST( boost::addressof( f3 ) == &f3 ); + BOOST_TEST( boost::addressof( f4 ) == &f4 ); + BOOST_TEST( boost::addressof( f5 ) == &f5 ); + BOOST_TEST( boost::addressof( f6 ) == &f6 ); + BOOST_TEST( boost::addressof( f7 ) == &f7 ); + BOOST_TEST( boost::addressof( f8 ) == &f8 ); + BOOST_TEST( boost::addressof( f9 ) == &f9 ); + + return boost::report_errors(); +} diff --git a/addressof_test2.cpp b/addressof_test2.cpp new file mode 100644 index 0000000..b1c36f8 --- /dev/null +++ b/addressof_test2.cpp @@ -0,0 +1,95 @@ +// Copyright (C) 2002 Brad King (brad.king@kitware.com) +// Douglas Gregor (gregod@cs.rpi.edu) +// +// Copyright 2009 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// For more information, see http://www.boost.org + + +#include + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include + +template void scalar_test( T * = 0 ) +{ + T* px = new T(); + + T& x = *px; + BOOST_TEST( boost::addressof(x) == px ); + + const T& cx = *px; + const T* pcx = boost::addressof(cx); + BOOST_TEST( pcx == px ); + + volatile T& vx = *px; + volatile T* pvx = boost::addressof(vx); + BOOST_TEST( pvx == px ); + + const volatile T& cvx = *px; + const volatile T* pcvx = boost::addressof(cvx); + BOOST_TEST( pcvx == px ); + + delete px; +} + +template void array_test( T * = 0 ) +{ + T nrg[3] = {1,2,3}; + T (*pnrg)[3] = &nrg; + BOOST_TEST( boost::addressof(nrg) == pnrg ); + + T const cnrg[3] = {1,2,3}; + T const (*pcnrg)[3] = &cnrg; + BOOST_TEST( boost::addressof(cnrg) == pcnrg ); +} + +class convertible { +public: + + convertible( int = 0 ) + { + } + + template operator U () const + { + return U(); + } +}; + +class convertible2 { +public: + + convertible2( int = 0 ) + { + } + + operator convertible2* () const + { + return 0; + } +}; + +int main() +{ + scalar_test(); + scalar_test(); + + array_test(); + array_test(); + + return boost::report_errors(); +} diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index 8e0a586..f0da384 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -21,6 +21,14 @@ namespace boost namespace detail { +template struct addr_impl_ref +{ + T & v_; + + inline addr_impl_ref( T & v ): v_( v ) {} + inline operator T& () const { return v_; } +}; + template struct addressof_impl { static inline T * f( T & v, long ) @@ -39,7 +47,15 @@ template struct addressof_impl template T * addressof( T & v ) { +#if BOOST_WORKAROUND( __BORLANDC__, < 0x560 ) + return boost::detail::addressof_impl::f( v, 0 ); + +#else + + return boost::detail::addressof_impl::f( boost::detail::addr_impl_ref( v ), 0 ); + +#endif } // Borland doesn't like casting an array reference to a char reference diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 321060c..3111cad 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -11,7 +11,9 @@ import testing ; # Please keep the tests ordered by filename test-suite utility : + [ run ../addressof_fn_test.cpp ] [ run ../addressof_test.cpp ] + [ run ../addressof_test2.cpp ] [ run ../assert_test.cpp ] [ run ../base_from_member_test.cpp ] [ run ../binary_search_test.cpp ] From 3900e8ece4e860acc759a965cd55262bf925365f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 21 Mar 2009 20:20:37 +0000 Subject: [PATCH 123/164] Disable new addressof code for all Borland versions. Refs #2878. [SVN r51891] --- include/boost/utility/addressof.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index f0da384..48602be 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -47,7 +47,7 @@ template struct addressof_impl template T * addressof( T & v ) { -#if BOOST_WORKAROUND( __BORLANDC__, < 0x560 ) +#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) return boost::detail::addressof_impl::f( v, 0 ); From d97b303777e64cf32ffd20a4ed116891758afaac Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 26 Mar 2009 00:06:47 +0000 Subject: [PATCH 124/164] Try to fix array addressof failures on Sun C++. [SVN r51977] --- include/boost/utility/addressof.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index 48602be..2ebaefb 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -47,7 +47,7 @@ template struct addressof_impl template T * addressof( T & v ) { -#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) +#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) return boost::detail::addressof_impl::f( v, 0 ); @@ -58,9 +58,18 @@ template T * addressof( T & v ) #endif } +#if defined( __SUNPRO_CC ) && BOOST_WORKAROUND( __SUNPRO_CC, BOOST_TESTED_AT( 0x590 ) ) + +template T (*addressof(T (&t)[N]))[N] +{ + return &t; +} + +#endif + // Borland doesn't like casting an array reference to a char reference // but these overloads work around the problem. -# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +#if defined( __BORLANDC__ ) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) template T (*addressof(T (&t)[N]))[N] { @@ -72,7 +81,7 @@ const T (*addressof(const T (&t)[N]))[N] { return reinterpret_cast(&t); } -# endif +#endif } // namespace boost From 61e9b93f7ccedb675e0b562e81e53510d6896e94 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 26 Mar 2009 13:05:05 +0000 Subject: [PATCH 125/164] Try the Sun workaround with int instead of size_t. [SVN r51986] --- include/boost/utility/addressof.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index 2ebaefb..bea9a01 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -60,7 +60,7 @@ template T * addressof( T & v ) #if defined( __SUNPRO_CC ) && BOOST_WORKAROUND( __SUNPRO_CC, BOOST_TESTED_AT( 0x590 ) ) -template T (*addressof(T (&t)[N]))[N] +template T (*addressof(T (&t)[N]))[N] { return &t; } From 91385ac6276439482572fc44f7395bdf5278430d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 27 Mar 2009 12:50:09 +0000 Subject: [PATCH 126/164] Another try at the Sun workaround. [SVN r52010] --- include/boost/utility/addressof.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index bea9a01..ac42a51 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -60,7 +60,18 @@ template T * addressof( T & v ) #if defined( __SUNPRO_CC ) && BOOST_WORKAROUND( __SUNPRO_CC, BOOST_TESTED_AT( 0x590 ) ) -template T (*addressof(T (&t)[N]))[N] +namespace detail +{ + +template struct addressof_addp +{ + typedef T * type; +}; + +} // namespace detail + +template< class T, std::size_t N > +typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] ) { return &t; } From 75cf20cace3a5993dc62716ca1dd75357e8196e9 Mon Sep 17 00:00:00 2001 From: Daniel Frey Date: Sat, 18 Apr 2009 09:06:31 +0000 Subject: [PATCH 127/164] primary operand type must be class type, see ticket #2938 [SVN r52463] --- operators.htm | 55 +++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/operators.htm b/operators.htm index a33e814..37820e1 100644 --- a/operators.htm +++ b/operators.htm @@ -132,18 +132,18 @@ class MyInt : boost::operators<MyInt> { - bool operator<(const MyInt& x) const; + bool operator<(const MyInt& x) const; bool operator==(const MyInt& x) const; - MyInt& operator+=(const MyInt& x); - MyInt& operator-=(const MyInt& x); - MyInt& operator*=(const MyInt& x); - MyInt& operator/=(const MyInt& x); - MyInt& operator%=(const MyInt& x); - MyInt& operator|=(const MyInt& x); - MyInt& operator&=(const MyInt& x); - MyInt& operator^=(const MyInt& x); - MyInt& operator++(); - MyInt& operator--(); + MyInt& operator+=(const MyInt& x); + MyInt& operator-=(const MyInt& x); + MyInt& operator*=(const MyInt& x); + MyInt& operator/=(const MyInt& x); + MyInt& operator%=(const MyInt& x); + MyInt& operator|=(const MyInt& x); + MyInt& operator&=(const MyInt& x); + MyInt& operator^=(const MyInt& x); + MyInt& operator++(); + MyInt& operator--(); }; @@ -345,7 +345,7 @@ class MyInt

    As Daniel Krügler pointed out, this technique violates 14.6.5/2 - and is thus non-portable. The reasoning is, that the operators injected + and is thus non-portable. The reasoning is, that the operators injected by the instantiation of e.g. less_than_comparable<myclass> can not be found by ADL according to the rules given by 3.4.2/2, since myclass is @@ -445,6 +445,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4); optional template parameter B, which is not shown, for the base class chaining technique.

    +

    The primary operand type T needs to be of class type, + built-in types are not supported.

    +
    Simple Arithmetic Operator Template Classes @@ -917,7 +920,7 @@ T operator+( const T& lhs, const T& rhs ) created, operator+= is called on it and it is copied to the function return value (which is another unnamed object of type T). The standard doesn't generally allow the intermediate - object to be optimized away: + object to be optimized away:
    3.7.2/2: Automatic storage duration
    @@ -928,7 +931,7 @@ T operator+( const T& lhs, const T& rhs ) unused, except that a class object or its copy may be eliminated as specified in 12.8.
    - The reference to 12.8 is important for us: + The reference to 12.8 is important for us:
    12.8/15: Copying class objects
    @@ -942,7 +945,7 @@ T operator+( const T& lhs, const T& rhs )
    This optimization is known as the named return value optimization (NRVO), which leads us to the following implementation for - operator+: + operator+:
     T operator+( const T& lhs, const T& rhs )
     {
    @@ -956,7 +959,7 @@ T operator+( const T& lhs, const T& rhs )
         even implement it in an incorrect way which makes it useless here.
         Without the NRVO, the NRVO-friendly code is no worse than the original
         code showed above, but there is another possible implementation, which
    -    has some very special properties: 
    +    has some very special properties:
     
     T operator+( T lhs, const T& rhs )
     {
    @@ -982,7 +985,7 @@ T operator+( T lhs, const T& rhs )
         will force the NRVO-friendly implementation to be used even for compilers
         that don't implement the NRVO. 

    - +

    Grouped Arithmetic Operators

    The following templates provide common groups of related operations. @@ -1864,7 +1867,7 @@ T operator+( T lhs, const T& rhs ) V, D, P, R>

    - Supports the operations and has the requirements of + Supports the operations and has the requirements of - Supports the operations and has the requirements of + Supports the operations and has the requirements of
    - Supports the operations and has the requirements of + Supports the operations and has the requirements of - Supports the operations and has the requirements of + Supports the operations and has the requirements of
    - Supports the operations and has the requirements of + Supports the operations and has the requirements of
    • Revised: 7 Aug 2008

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

      -

      Copyright © Daniel Frey, 2002-2008.

      -

      Use, modification, and distribution is subject to the Boost Software +

      Copyright © Daniel Frey, 2002-2009.

      +

      Use, modification, and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at From 67afd7e3150d45e5b0201cdce571ca0f4c64e191 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Thu, 7 May 2009 17:47:08 +0000 Subject: [PATCH 128/164] eliminate noisy warning on msvc, fixes #2993 [SVN r52837] --- include/boost/utility/addressof.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index ac42a51..95cd92f 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -27,6 +27,9 @@ template struct addr_impl_ref inline addr_impl_ref( T & v ): v_( v ) {} inline operator T& () const { return v_; } + +private: + addr_impl_ref & operator=(const addr_impl_ref &); }; template struct addressof_impl From 682032a3408590bfac5aa02b50eee391ab54bf8c Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 16 May 2009 14:23:59 +0000 Subject: [PATCH 129/164] Use a local copy of the valid HTML 4.01 icon. [SVN r53048] --- Assignable.html | 2 +- Collection.html | 2 +- CopyConstructible.html | 2 +- LessThanComparable.html | 2 +- MultiPassInputIterator.html | 2 +- generator_iterator.htm | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Assignable.html b/Assignable.html index 54934f1..d3b3157 100644 --- a/Assignable.html +++ b/Assignable.html @@ -85,7 +85,7 @@


      Valid HTML 4.01 Transitional

      Revised diff --git a/Collection.html b/Collection.html index c811e7e..b92ddd6 100644 --- a/Collection.html +++ b/Collection.html @@ -509,7 +509,7 @@ Returns the largest size that this Collection can ever have. [8]

      Valid HTML 4.01 Transitional

      Revised diff --git a/CopyConstructible.html b/CopyConstructible.html index 40ff7a7..6a7ce65 100644 --- a/CopyConstructible.html +++ b/CopyConstructible.html @@ -160,7 +160,7 @@ t.~T()


      Valid HTML 4.01 Transitional

      Revised diff --git a/LessThanComparable.html b/LessThanComparable.html index a723377..15b938f 100644 --- a/LessThanComparable.html +++ b/LessThanComparable.html @@ -185,7 +185,7 @@


      Valid HTML 4.01 Transitional

      Revised diff --git a/MultiPassInputIterator.html b/MultiPassInputIterator.html index fa7517c..e331ca3 100644 --- a/MultiPassInputIterator.html +++ b/MultiPassInputIterator.html @@ -70,7 +70,7 @@


      Valid HTML 4.01 Transitional

      Revised diff --git a/generator_iterator.htm b/generator_iterator.htm index 6070522..b0e376e 100644 --- a/generator_iterator.htm +++ b/generator_iterator.htm @@ -146,7 +146,7 @@ int main()


      Valid HTML 4.01 Transitional

      Revised From 61a6015b5ac2fd3d9dc19c314a36a6bf8e8b804a Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Sun, 17 May 2009 00:06:34 +0000 Subject: [PATCH 130/164] Replace aFactoty with aFactory. Fixes #3019 [SVN r53060] --- in_place_factories.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/in_place_factories.html b/in_place_factories.html index d3791f8..f8a4c7b 100644 --- a/in_place_factories.html +++ b/in_place_factories.html @@ -117,7 +117,7 @@ The following simplified example shows the basic idea. A complete example follow

      struct C
       {
          template<class InPlaceFactory>
      -   C ( InPlaceFactory const& aFactoty )
      +   C ( InPlaceFactory const& aFactory )
           :
           contained_ ( uninitialized_storage() )
          {
      
      From b02677375f49572e5eb88c3a711153a337e47659 Mon Sep 17 00:00:00 2001
      From: Jeremiah Willcock 
      Date: Wed, 20 May 2009 19:19:00 +0000
      Subject: [PATCH 131/164] Fixed most tab and min/max issues from trunk
       inspection report
      
      [SVN r53141]
      ---
       include/boost/utility/result_of.hpp | 4 ++--
       swap/test/std_bitset.cpp            | 2 +-
       swap/test/swap_test_class.hpp       | 2 +-
       3 files changed, 4 insertions(+), 4 deletions(-)
      
      diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp
      index d8baa3e..78168fa 100644
      --- a/include/boost/utility/result_of.hpp
      +++ b/include/boost/utility/result_of.hpp
      @@ -81,8 +81,8 @@ struct result_of_nested_result : F::template result
       template
       struct result_of_impl
         : mpl::if_,
      -	     result_of_void_impl,
      -	     result_of_nested_result >::type
      +             result_of_void_impl,
      +             result_of_nested_result >::type
       {};
       
       } // end namespace detail
      diff --git a/swap/test/std_bitset.cpp b/swap/test/std_bitset.cpp
      index 4b9fbae..d8d69e7 100644
      --- a/swap/test/std_bitset.cpp
      +++ b/swap/test/std_bitset.cpp
      @@ -19,7 +19,7 @@ int test_main(int, char*[])
         typedef std::bitset<8> bitset_type;
         const bitset_type initial_value1 = 1ul;
         const bitset_type initial_value2 = 2ul;
      -	
      +
         bitset_type object1 = initial_value1;
         bitset_type object2 = initial_value2;
       
      diff --git a/swap/test/swap_test_class.hpp b/swap/test/swap_test_class.hpp
      index 8cf1fe9..a25dbbd 100644
      --- a/swap/test/swap_test_class.hpp
      +++ b/swap/test/swap_test_class.hpp
      @@ -12,7 +12,7 @@
       
       class swap_test_class
       {
      -  int m_data;	
      +  int m_data;
       public:
         explicit swap_test_class(int arg = 0)
         :
      
      From b514e40733928598125314b59595e7e551d1cf00 Mon Sep 17 00:00:00 2001
      From: Niels Dekker 
      Date: Mon, 29 Jun 2009 17:53:33 +0000
      Subject: [PATCH 132/164] Worked around Intel 9 specific ambiguity w.r.t.
       value_initialized conversion operators, by applying
       intel_9_value_init_conversion-operator.patch, as discussed w/ Daniel James at
       ticket #2548
      
      [SVN r54502]
      ---
       include/boost/utility/value_init.hpp | 4 +++-
       1 file changed, 3 insertions(+), 1 deletion(-)
      
      diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp
      index 5aefac9..85670fd 100644
      --- a/include/boost/utility/value_init.hpp
      +++ b/include/boost/utility/value_init.hpp
      @@ -106,8 +106,10 @@ class value_initialized
             ::boost::swap( this->data(), arg.data() );
           }
       
      +#if !BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 900)
           operator T const &() const { return this->data(); }
      -
      +#endif
      +    
           operator T&() { return this->data(); }
       
       } ;
      
      From d3879051506108912d025db4217407d2bd1c1887 Mon Sep 17 00:00:00 2001
      From: Niels Dekker 
      Date: Mon, 29 Jun 2009 18:04:24 +0000
      Subject: [PATCH 133/164] Updated documentation of value_initialized, according
       to a remark by Daniel James at ticket #2548
      
      [SVN r54503]
      ---
       value_init.htm | 4 ++--
       1 file changed, 2 insertions(+), 2 deletions(-)
      
      diff --git a/value_init.htm b/value_init.htm
      index 5c50fd9..654d548 100644
      --- a/value_init.htm
      +++ b/value_init.htm
      @@ -313,7 +313,7 @@ non-member    function get():  

      Warning:

      -

      The value_initialized implementation of Boost version 1.38.0 and older +

      The value_initialized implementation of Boost version 1.39.0 and older allowed non-const access to the wrapped object, from a constant wrapper, both by its conversion operator and its data() member function. For example:

      @@ -407,7 +407,7 @@ for Boost release version 1.35 (2008), offering a workaround to various compiler


      -

      Revised 20 February 2009

      +

      Revised 28 June 2009

      © Copyright Fernando Cacciola, 2002, 2009.

      From 5be3004e6cc520d35121b9c3f1362c71cf610a96 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 8 Jul 2009 23:44:28 +0000 Subject: [PATCH 134/164] Added commonly used error_info typedefs. Added boost/exception/all.hpp. Removed tabs from source files. [SVN r54825] --- include/boost/exception.hpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/include/boost/exception.hpp b/include/boost/exception.hpp index b4716a0..15ed0c9 100644 --- a/include/boost/exception.hpp +++ b/include/boost/exception.hpp @@ -6,14 +6,6 @@ #ifndef UUID_1D94A7C6054E11DB9804B622A1EF5492 #define UUID_1D94A7C6054E11DB9804B622A1EF5492 -#include -#include -#include -#include -#include -#include -#ifndef BOOST_NO_EXCEPTIONS -#include -#endif +#include #endif From a1d3ec6c53ac1d3f0f45b4a1f563dab1697993d9 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 9 Jul 2009 03:51:30 +0000 Subject: [PATCH 135/164] Documentation update [SVN r54828] --- include/boost/exception.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/exception.hpp b/include/boost/exception.hpp index 15ed0c9..ff31565 100644 --- a/include/boost/exception.hpp +++ b/include/boost/exception.hpp @@ -6,6 +6,8 @@ #ifndef UUID_1D94A7C6054E11DB9804B622A1EF5492 #define UUID_1D94A7C6054E11DB9804B622A1EF5492 +//The header has been deprecated. +//Please #include instead. #include #endif From 09a01370168566f5ec477ae24e1259a858fd1ef3 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Thu, 9 Jul 2009 08:06:19 +0000 Subject: [PATCH 136/164] Reverted value_init revision [54502], intel_9_value_init_conversion-operator.patch from ticket #2548, as it only increased the number of compile errors at the regression page, and Fernando Cacciola also suggested me to leave it broken (without the patch), for this specific (old) compiler version. [SVN r54832] --- include/boost/utility/value_init.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index 85670fd..5aefac9 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -106,10 +106,8 @@ class value_initialized ::boost::swap( this->data(), arg.data() ); } -#if !BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 900) operator T const &() const { return this->data(); } -#endif - + operator T&() { return this->data(); } } ; From afe74fffbc4fd7b1a6bc163d704d1cee5cf053ce Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sun, 26 Jul 2009 00:49:56 +0000 Subject: [PATCH 137/164] Copyrights on CMakeLists.txt to keep them from clogging up the inspect reports. This is essentially the same commit as r55095 on the release branch. [SVN r55159] --- CMakeLists.txt | 6 ++++++ test/CMakeLists.txt | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6df7714..040fa4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,9 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# #---------------------------------------------------------------------------- # This file was automatically generated from the original CMakeLists.txt file # Add a variable to hold the headers for the library diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fee1ccb..6b93338 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,9 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# boost_additional_test_dependencies(utility BOOST_DEPENDS test) boost_test_run(addressof_test ../addressof_test.cpp) From ba61e9d796ffcf3cbeee51763427a12dd51be41e Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Tue, 8 Sep 2009 16:54:54 +0000 Subject: [PATCH 138/164] Mentioned swap.hpp header, as requested by Thorsten Ottosen and David Abrahams [SVN r56107] --- swap.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/swap.html b/swap.html index 4022e0b..50722b2 100644 --- a/swap.html +++ b/swap.html @@ -7,7 +7,11 @@ +

      C++ Boost + Header <boost/swap.hpp> +

      +

      Swap

      From 8745ca628a9430c318fa0161026d0a07544aec1d Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Tue, 8 Sep 2009 17:07:13 +0000 Subject: [PATCH 139/164] Updated revision date of Boost Swap documentation [SVN r56108] --- swap.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swap.html b/swap.html index 50722b2..36f8425 100644 --- a/swap.html +++ b/swap.html @@ -88,9 +88,9 @@


      -

      Revised: 15 November 2008

      +

      Revised: 08 September 2009

      - Copyright 2007, 2008 Joseph Gauterin. Use, modification, and distribution are subject to the Boost Software License, Version 1.0. + Copyright 2007 - 2009 Joseph Gauterin. Use, modification, and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)

      From f2349baf7d3190561e9b7cf8f3c571a108316e74 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sat, 3 Oct 2009 09:18:26 +0000 Subject: [PATCH 140/164] Updated value_init documentation, because the fix of #2548 was not yet included with Boost release 1.40.0. [SVN r56544] --- value_init.htm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/value_init.htm b/value_init.htm index 654d548..57b2313 100644 --- a/value_init.htm +++ b/value_init.htm @@ -313,7 +313,7 @@ non-member function get():

      Warning:

      -

      The value_initialized implementation of Boost version 1.39.0 and older +

      The value_initialized implementation of Boost version 1.40.0 and older allowed non-const access to the wrapped object, from a constant wrapper, both by its conversion operator and its data() member function. For example:

      @@ -407,7 +407,7 @@ for Boost release version 1.35 (2008), offering a workaround to various compiler


      -

      Revised 28 June 2009

      +

      Revised 03 October 2009

      © Copyright Fernando Cacciola, 2002, 2009.

      @@ -418,4 +418,4 @@ for Boost release version 1.35 (2008), offering a workaround to various compiler
      - \ No newline at end of file + From 9339431e03a599b33617375f9b0d5986942b463a Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 17 Oct 2009 02:07:38 +0000 Subject: [PATCH 141/164] rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back [SVN r56942] --- CMakeLists.txt | 37 ------------------------------------- module.cmake | 1 - test/CMakeLists.txt | 44 -------------------------------------------- 3 files changed, 82 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 module.cmake delete mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 040fa4f..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -#---------------------------------------------------------------------------- -# This file was automatically generated from the original CMakeLists.txt file -# Add a variable to hold the headers for the library -set (lib_headers - assert.hpp - call_traits.hpp - checked_delete.hpp - compressed_pair.hpp - current_function.hpp - operators.hpp - throw_exception.hpp - utility.hpp - utility -) - -# Add a library target to the build system -boost_library_project( - utility - # SRCDIRS - TESTDIRS test - HEADERS ${lib_headers} - # DOCDIRS - DESCRIPTION "Various small utilities for C++ programming." - MODULARIZED - AUTHORS "David Abrahams " - "Brad King" - "Douglas Gregor " - # MAINTAINERS -) - - diff --git a/module.cmake b/module.cmake deleted file mode 100644 index 4d78340..0000000 --- a/module.cmake +++ /dev/null @@ -1 +0,0 @@ -boost_module(utility DEPENDS iterator exception detail ) \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 6b93338..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -boost_additional_test_dependencies(utility BOOST_DEPENDS test) - -boost_test_run(addressof_test ../addressof_test.cpp) -boost_test_run(assert_test ../assert_test.cpp) -boost_test_run(base_from_member_test ../base_from_member_test.cpp) -boost_test_run(binary_search_test ../binary_search_test.cpp) -boost_test_run(call_traits_test ../call_traits_test.cpp ARGS -u) -boost_test_compile_fail(checked_delete_test ../checked_delete_test.cpp) -boost_test_run(compressed_pair_test - ../compressed_pair_test - DEPENDS boost_test_exec_monitor) -boost_test_run(current_function_test ../current_function_test.cpp) -boost_test_run(iterators_test - ../iterators_test.cpp - DEPENDS boost_test_exec_monitor) -boost_test_run(next_prior_test DEPENDS boost_test_exec_monitor) -boost_test_compile_fail(noncopyable_test ../noncopyable_test.cpp) -boost_test_run(numeric_traits_test ../numeric_traits_test.cpp) -if (${CMAKE_SYSTEM} MATCHES "FreeBSD-.*") -boost_test_compile_fail("operators_test_compilerbug") -elseif(${CMAKE_SYSTEM} MATCHES "FreeBSD-.*") -boost_test_run(operators_test - ../operators_test.cpp - DEPENDS boost_test_exec_monitor) -endif(${CMAKE_SYSTEM} MATCHES "FreeBSD-.*") -boost_test_compile(ref_ct_test ../ref_ct_test.cpp) -boost_test_run(ref_test - ../ref_test.cpp - DEPENDS boost_test_exec_monitor) -boost_test_compile(result_of_test) -boost_test_run(shared_iterator_test ../shared_iterator_test.cpp) -boost_test_run(value_init_test ../value_init_test.cpp) -boost_test_compile_fail(value_init_test_fail1 - ../value_init_test_fail1.cpp) -boost_test_compile_fail(value_init_test_fail2 - ../value_init_test_fail2.cpp) -boost_test_compile_fail(value_init_test_fail3 - ../value_init_test_fail3.cpp) From 7eb1536590bcf7f2e045b3e46bfeba95a6292a31 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 8 Nov 2009 18:53:59 +0000 Subject: [PATCH 142/164] Suppress/fix some msvc and gcc compiler warnings. [SVN r57494] --- base_from_member_test.cpp | 2 +- binary_test.cpp | 4 ++++ call_traits_test.cpp | 11 +++++++++-- ref_test.cpp | 2 +- value_init_test.cpp | 6 +++--- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/base_from_member_test.cpp b/base_from_member_test.cpp index 89328e4..2598df5 100644 --- a/base_from_member_test.cpp +++ b/base_from_member_test.cpp @@ -281,7 +281,7 @@ object_id_compare::operator () } else { - return a.second->before( *b.second ); + return a.second->before( *b.second ) != 0; } } } diff --git a/binary_test.cpp b/binary_test.cpp index b4041b3..aacfab9 100644 --- a/binary_test.cpp +++ b/binary_test.cpp @@ -11,6 +11,10 @@ #include #include +#ifdef BOOST_MSVC +#pragma warning(disable:4996) // warning C4996: 'std::equal': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' +#endif + /* Note: This file tests every single valid bit-grouping on its own, and some random combinations of bit-groupings. diff --git a/call_traits_test.cpp b/call_traits_test.cpp index e73ede7..72852c4 100644 --- a/call_traits_test.cpp +++ b/call_traits_test.cpp @@ -21,6 +21,10 @@ #include #include +#ifdef BOOST_MSVC +#pragma warning(disable:4181) // : warning C4181: qualifier applied to reference type; ignored +#endif + // a way prevent warnings for unused variables template inline void unused_variable(const T&) {} @@ -52,7 +56,8 @@ struct contained const_reference const_get()const { return v_; } // pass value: void call(param_type){} - +private: + contained& operator=(const contained&); }; #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION @@ -77,6 +82,8 @@ struct contained reference get() { return v_; } const_reference const_get()const { return v_; } void call(param_type){} +private: + contained& operator=(const contained&); }; #endif @@ -197,7 +204,7 @@ struct comparible_UDT bool operator == (const comparible_UDT& v){ return v.i_ == i_; } }; -int main(int argc, char *argv[ ]) +int main() { call_traits_checker c1; comparible_UDT u; diff --git a/ref_test.cpp b/ref_test.cpp index d4237b4..71481fa 100644 --- a/ref_test.cpp +++ b/ref_test.cpp @@ -70,7 +70,7 @@ struct ref_wrapper struct copy_counter { static int count_; - copy_counter(copy_counter const& other) { + copy_counter(copy_counter const& /*other*/) { ++count_; } copy_counter() {} diff --git a/value_init_test.cpp b/value_init_test.cpp index 67ebad8..98b8860 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -29,9 +29,9 @@ // struct POD { - POD () : c(0), i(0), f(0) {} + POD () : f(0), c(0), i(0){} - POD ( char c_, int i_, float f_ ) : c(c_), i(i_), f(f_) {} + POD ( char c_, int i_, float f_ ) : f(f_), c(c_), i(i_) {} friend std::ostream& operator << ( std::ostream& os, POD const& pod ) { return os << '(' << pod.c << ',' << pod.i << ',' << pod.f << ')' ; } @@ -291,7 +291,7 @@ int test_main(int, char **) { BOOST_CHECK ( test( 0,1234 ) ) ; BOOST_CHECK ( test( 0.0,12.34 ) ) ; - BOOST_CHECK ( test( POD(0,0,0.0), POD('a',1234,56.78) ) ) ; + BOOST_CHECK ( test( POD(0,0,0.0), POD('a',1234,56.78f) ) ) ; BOOST_CHECK ( test( NonPOD( std::string() ), NonPOD( std::string("something") ) ) ) ; NonPOD NonPOD_object( std::string("NonPOD_object") ); From 3de5974419b62307a2953a7a8e38a42468810d25 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 1 Dec 2009 02:16:50 +0000 Subject: [PATCH 143/164] Suppressing warnings. Please report any problems (may have broken something!) [SVN r58072] --- include/boost/exception.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/boost/exception.hpp b/include/boost/exception.hpp index ff31565..6424159 100644 --- a/include/boost/exception.hpp +++ b/include/boost/exception.hpp @@ -6,8 +6,6 @@ #ifndef UUID_1D94A7C6054E11DB9804B622A1EF5492 #define UUID_1D94A7C6054E11DB9804B622A1EF5492 -//The header has been deprecated. -//Please #include instead. -#include +#error The header has been deprecated. Please #include instead. #endif From 76b17c497b6e013958ac5f83ccf4c5441f5e30e3 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 24 Jan 2010 02:08:46 +0000 Subject: [PATCH 144/164] Support different MS calling conventions, thanks to Nicolas Lelong. Closes #3833. [SVN r59247] --- test/Jamfile.v2 | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 3111cad..9fed03f 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -25,6 +25,7 @@ test-suite utility [ run ../iterators_test.cpp ../../test/build//boost_test_exec_monitor/static ] [ run next_prior_test.cpp ../../test/build//boost_test_exec_monitor/static ] [ compile-fail ../noncopyable_test.cpp ] + [ run noncopyable_adl_barrier.cpp ] [ run ../numeric_traits_test.cpp ] [ run ../operators_test.cpp ../../test/build//boost_test_exec_monitor/static ] [ compile ../ref_ct_test.cpp ] From bf713ad47a0e71f9ff1059d8229ecc8030815900 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 28 Jan 2010 14:41:16 +0000 Subject: [PATCH 145/164] Revert unintentional reference to "noncopyable_adl_barrier" test that's not checked in. [SVN r59332] --- test/Jamfile.v2 | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 9fed03f..3111cad 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -25,7 +25,6 @@ test-suite utility [ run ../iterators_test.cpp ../../test/build//boost_test_exec_monitor/static ] [ run next_prior_test.cpp ../../test/build//boost_test_exec_monitor/static ] [ compile-fail ../noncopyable_test.cpp ] - [ run noncopyable_adl_barrier.cpp ] [ run ../numeric_traits_test.cpp ] [ run ../operators_test.cpp ../../test/build//boost_test_exec_monitor/static ] [ compile ../ref_ct_test.cpp ] From 74a6a693d3fcbe98e2ba3b7afc89a576c354e531 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 1 Mar 2010 19:39:52 +0000 Subject: [PATCH 146/164] Remove use of deprecated config macro in result_of. [SVN r60052] --- include/boost/utility/detail/result_of_iterate.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index 8de00b4..7b09435 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -10,7 +10,7 @@ # error Boost result_of - do not include this file! #endif -#if defined(BOOST_HAS_DECLTYPE) +#if !defined(BOOST_NO_DECLTYPE) // As of N2588, C++0x result_of only supports function call // expressions of the form f(x). This precludes support for member From bbccfbbab4d5feb9cd772000afb143a24aeceab7 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 7 Mar 2010 13:10:54 +0000 Subject: [PATCH 147/164] Remove use of deprecated macro in result_of test. [SVN r60293] --- test/result_of_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/result_of_test.cpp b/test/result_of_test.cpp index 73dc757..bdbba2b 100644 --- a/test/result_of_test.cpp +++ b/test/result_of_test.cpp @@ -133,7 +133,7 @@ int main() // 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) +#if !defined(BOOST_NO_DECLTYPE) BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same(void)>::type, int>::value)); @@ -149,7 +149,7 @@ int main() // 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) +#if !defined(BOOST_NO_DECLTYPE) BOOST_STATIC_ASSERT((is_same::type, char>::value)); BOOST_STATIC_ASSERT((is_same(char)>::type, char>::value)); #else @@ -181,7 +181,7 @@ int main() BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type,int>::value)); -#if defined(BOOST_HAS_DECLTYPE) +#if !defined(BOOST_NO_DECLTYPE) BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, unsigned int>::value)); BOOST_STATIC_ASSERT((is_same::type, short>::value)); From e6cb3a77eeebb2a6524fef3ede1365c15ab16d84 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 7 Mar 2010 13:11:10 +0000 Subject: [PATCH 148/164] Fix a couple of comments. [SVN r60294] --- include/boost/utility/detail/result_of_iterate.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index 7b09435..9719339 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -49,7 +49,7 @@ public: } // namespace detail -#else // defined(BOOST_HAS_DECLTYPE) +#else // defined(BOOST_NO_DECLTYPE) // CWPro8 requires an argument in a function type specialization #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0 @@ -76,7 +76,7 @@ struct result_of #undef BOOST_RESULT_OF_ARGS -#endif // defined(BOOST_HAS_DECLTYPE) +#endif // defined(BOOST_NO_DECLTYPE) #if BOOST_PP_ITERATION() >= 1 From 3770221507b1ba14f8a989606f4bd0576be2b939 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 7 Mar 2010 21:42:22 +0000 Subject: [PATCH 149/164] Hopefully fixed #3984 (std::bitset constructor issue). Tested by Juergen Hunold on msvc-10.0, msvc-9.0, and gcc-4.4. See thread starting at http://lists.boost.org/Archives/boost/2010/03/162690.php [SVN r60331] --- swap/test/std_bitset.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swap/test/std_bitset.cpp b/swap/test/std_bitset.cpp index d8d69e7..8c0851a 100644 --- a/swap/test/std_bitset.cpp +++ b/swap/test/std_bitset.cpp @@ -17,8 +17,8 @@ int test_main(int, char*[]) { typedef std::bitset<8> bitset_type; - const bitset_type initial_value1 = 1ul; - const bitset_type initial_value2 = 2ul; + const bitset_type initial_value1 = 1; + const bitset_type initial_value2 = 2; bitset_type object1 = initial_value1; bitset_type object2 = initial_value2; From 9339b321786374e1eee295fd39a5affe7bfef3ee Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Mon, 5 Apr 2010 19:08:01 +0000 Subject: [PATCH 150/164] Updated copyright notice. [SVN r61075] --- swap/test/std_bitset.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swap/test/std_bitset.cpp b/swap/test/std_bitset.cpp index 8c0851a..c46b686 100644 --- a/swap/test/std_bitset.cpp +++ b/swap/test/std_bitset.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2008 Joseph Gauterin, Niels Dekker +// Copyright (c) 2008 - 2010 Joseph Gauterin, Niels Dekker // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at From 82e1111bb801d36607f6bd15a92d499e956365e6 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 6 Apr 2010 07:56:54 +0000 Subject: [PATCH 151/164] Revert [60052], as it causes other libraries to break. [SVN r61097] --- include/boost/utility/detail/result_of_iterate.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index 9719339..e22537c 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -10,7 +10,7 @@ # error Boost result_of - do not include this file! #endif -#if !defined(BOOST_NO_DECLTYPE) +#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 From e3c982287a6eab3f2ee59bbb7b2e4a2609fdc00b Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Tue, 13 Apr 2010 15:01:11 +0000 Subject: [PATCH 152/164] add tr1_result_of that always behaves as TR1 specifies, fix Boost.TR1's result_of to use tr1_result_of [SVN r61248] --- .../utility/detail/result_of_iterate.hpp | 65 ++++++++++--------- include/boost/utility/result_of.hpp | 11 ++-- test/result_of_test.cpp | 40 ++++++++++++ 3 files changed, 82 insertions(+), 34 deletions(-) diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index e22537c..035bf19 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -10,7 +10,30 @@ # error Boost result_of - do not include this file! #endif -#if defined(BOOST_HAS_DECLTYPE) +// CWPro8 requires an argument in a function type specialization +#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0 +# define BOOST_RESULT_OF_ARGS void +#else +# define BOOST_RESULT_OF_ARGS BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T) +#endif + +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) +template +struct tr1_result_of + : mpl::if_< + mpl::or_< is_pointer, is_member_function_pointer > + , boost::detail::tr1_result_of_impl< + typename remove_cv::type, + typename remove_cv::type(BOOST_RESULT_OF_ARGS), + (boost::detail::has_result_type::value)> + , boost::detail::tr1_result_of_impl< + F, + F(BOOST_RESULT_OF_ARGS), + (boost::detail::has_result_type::value)> >::type { }; +#endif + +#if !defined(BOOST_NO_DECLTYPE) && defined(BOOST_RESULT_OF_USE_DECLTYPE) // As of N2588, C++0x result_of only supports function call // expressions of the form f(x). This precludes support for member @@ -21,11 +44,11 @@ template : mpl::if_< mpl::or_< is_pointer, is_member_function_pointer > - , detail::result_of_impl< + , detail::tr1_result_of_impl< typename remove_cv::type, typename remove_cv::type(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false > - , detail::result_of_decltype_impl< + , detail::cpp0x_result_of_impl< F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)) > >::type @@ -39,7 +62,7 @@ namespace detail { template -class result_of_decltype_impl +class cpp0x_result_of_impl { static F f; BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_RESULT_OF_STATIC_MEMBERS, _) @@ -51,47 +74,31 @@ public: #else // defined(BOOST_NO_DECLTYPE) -// CWPro8 requires an argument in a function type specialization -#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0 -# define BOOST_RESULT_OF_ARGS void -#else -# define BOOST_RESULT_OF_ARGS BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T) -#endif - #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) template struct result_of - : mpl::if_< - mpl::or_< is_pointer, is_member_function_pointer > - , boost::detail::result_of_impl< - typename remove_cv::type, - typename remove_cv::type(BOOST_RESULT_OF_ARGS), - (boost::detail::has_result_type::value)> - , boost::detail::result_of_impl< - F, - F(BOOST_RESULT_OF_ARGS), - (boost::detail::has_result_type::value)> >::type { }; + : tr1_result_of { }; #endif -#undef BOOST_RESULT_OF_ARGS - #endif // defined(BOOST_NO_DECLTYPE) +#undef BOOST_RESULT_OF_ARGS + #if BOOST_PP_ITERATION() >= 1 namespace detail { template -struct result_of_impl +struct tr1_result_of_impl { typedef R type; }; template -struct result_of_impl +struct tr1_result_of_impl { typedef R type; }; @@ -99,7 +106,7 @@ struct result_of_impl -struct result_of_impl { @@ -108,7 +115,7 @@ struct result_of_impl -struct result_of_impl @@ -118,7 +125,7 @@ struct result_of_impl -struct result_of_impl @@ -128,7 +135,7 @@ struct result_of_impl -struct result_of_impl diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp index 78168fa..9a42fd2 100644 --- a/include/boost/utility/result_of.hpp +++ b/include/boost/utility/result_of.hpp @@ -30,14 +30,15 @@ namespace boost { template struct result_of; +template struct tr1_result_of; // a TR1-style implementation of result_of #if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) namespace detail { BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) -template struct result_of_impl; -template struct result_of_decltype_impl; +template struct tr1_result_of_impl; +template struct cpp0x_result_of_impl; template struct result_of_void_impl @@ -60,10 +61,10 @@ struct result_of_void_impl // Determine the return type of a function pointer or pointer to member. template struct result_of_pointer - : result_of_impl::type, FArgs, false> { }; + : tr1_result_of_impl::type, FArgs, false> { }; template -struct result_of_impl +struct tr1_result_of_impl { typedef typename F::result_type type; }; @@ -79,7 +80,7 @@ struct result_of_nested_result : F::template result {}; template -struct result_of_impl +struct tr1_result_of_impl : mpl::if_, result_of_void_impl, result_of_nested_result >::type diff --git a/test/result_of_test.cpp b/test/result_of_test.cpp index bdbba2b..a282a75 100644 --- a/test/result_of_test.cpp +++ b/test/result_of_test.cpp @@ -5,6 +5,8 @@ // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#define BOOST_RESULT_OF_USE_DECLTYPE + // For more information, see http://www.boost.org/libs/utility #include #include @@ -131,6 +133,18 @@ int main() BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(float)>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); + + BOOST_STATIC_ASSERT((is_same::type, void>::value)); + BOOST_STATIC_ASSERT((is_same::type, void>::value)); + BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value)); + BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value)); + // Prior to decltype, result_of could not deduce the return type // nullary function objects unless they exposed a result_type. #if !defined(BOOST_NO_DECLTYPE) @@ -145,6 +159,9 @@ int main() BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value)); #endif + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(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 @@ -168,6 +185,17 @@ int main() BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, double>::value)); BOOST_STATIC_ASSERT((is_same::type, const double>::value)); BOOST_STATIC_ASSERT((is_same::type, volatile double>::value)); @@ -177,10 +205,22 @@ int main() BOOST_STATIC_ASSERT((is_same::type, int volatile &>::value)); BOOST_STATIC_ASSERT((is_same::type, int const volatile &>::value)); + BOOST_STATIC_ASSERT((is_same::type, double>::value)); + BOOST_STATIC_ASSERT((is_same::type, const double>::value)); + BOOST_STATIC_ASSERT((is_same::type, volatile double>::value)); + BOOST_STATIC_ASSERT((is_same::type, const volatile double>::value)); + BOOST_STATIC_ASSERT((is_same::type, int &>::value)); + BOOST_STATIC_ASSERT((is_same::type, int const &>::value)); + BOOST_STATIC_ASSERT((is_same::type, int volatile &>::value)); + BOOST_STATIC_ASSERT((is_same::type, int const volatile &>::value)); + typedef int (*pf_t)(int); BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type,int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type,int>::value)); + #if !defined(BOOST_NO_DECLTYPE) BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, unsigned int>::value)); From 22743ee1252a34722dd4c1005ab0e57fcd432f29 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 9 May 2010 20:51:24 +0000 Subject: [PATCH 153/164] Added boost::initialized as was agreed at http://lists.boost.org/Archives/boost/2010/04/164916.php -- see #3472 [SVN r61883] --- include/boost/utility/value_init.hpp | 123 ++++++++++++++++++++++----- initialized_test.cpp | 116 +++++++++++++++++++++++++ initialized_test_fail1.cpp | 33 +++++++ initialized_test_fail2.cpp | 37 ++++++++ test/Jamfile.v2 | 3 + value_init.htm | 60 ++++++++++++- 6 files changed, 349 insertions(+), 23 deletions(-) create mode 100644 initialized_test.cpp create mode 100644 initialized_test_fail1.cpp create mode 100644 initialized_test_fail2.cpp diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index 5aefac9..8392f70 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -9,6 +9,7 @@ // 23 May 2008 (Fixed operator= const issue, added initialized_value) Niels Dekker, Fernando Cacciola // 21 Ago 2008 (Added swap) Niels Dekker, Fernando Cacciola // 20 Feb 2009 (Fixed logical const-ness issues) Niels Dekker, Fernando Cacciola +// 03 Apr 2010 (Added initialized, suggested by Jeffrey Hellrung, fixing #3472) Niels Dekker // #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP @@ -28,10 +29,19 @@ #include #include +#ifdef BOOST_MSVC +#pragma warning(push) +#if _MSC_VER >= 1310 +// It is safe to ignore the following warning from MSVC 7.1 or higher: +// "warning C4351: new behavior: elements of array will be default initialized" +#pragma warning(disable: 4351) +#endif +#endif + namespace boost { template -class value_initialized +class initialized { private : struct wrapper @@ -40,6 +50,18 @@ class value_initialized typename #endif remove_const::type data; + + wrapper() + : + data() + { + } + + wrapper(T const & arg) + : + data(arg) + { + } }; mutable @@ -55,30 +77,26 @@ class value_initialized public : - value_initialized() + initialized() { + // Note: the following memset call will become conditional when ticket #3869 is fixed: + // https://svn.boost.org/trac/boost/ticket/3869 reported by Aleksey Gurtovoy. std::memset(&x, 0, sizeof(x)); -#ifdef BOOST_MSVC -#pragma warning(push) -#if _MSC_VER >= 1310 -// When using MSVC 7.1 or higher, the following placement new expression may trigger warning C4345: -// "behavior change: an object of POD type constructed with an initializer of the form () -// will be default-initialized". It is safe to ignore this warning when using value_initialized. -#pragma warning(disable: 4345) -#endif -#endif + new (wrapper_address()) wrapper(); -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif } - value_initialized(value_initialized const & arg) + initialized(initialized const & arg) { new (wrapper_address()) wrapper( static_cast(*(arg.wrapper_address()))); } - value_initialized & operator=(value_initialized const & arg) + explicit initialized(T const & arg) + { + new (wrapper_address()) wrapper(arg); + } + + initialized & operator=(initialized const & arg) { // Assignment is only allowed when T is non-const. BOOST_STATIC_ASSERT( ! is_const::value ); @@ -86,7 +104,7 @@ class value_initialized return *this; } - ~value_initialized() + ~initialized() { wrapper_address()->wrapper::~wrapper(); } @@ -101,17 +119,76 @@ class value_initialized return wrapper_address()->data; } - void swap(value_initialized & arg) + void swap(initialized & arg) { ::boost::swap( this->data(), arg.data() ); } - operator T const &() const { return this->data(); } + operator T const &() const + { + return wrapper_address()->data; + } - operator T&() { return this->data(); } + operator T&() + { + return wrapper_address()->data; + } } ; +template +T const& get ( initialized const& x ) +{ + return x.data() ; +} + +template +T& get ( initialized& x ) +{ + return x.data() ; +} + +template +void swap ( initialized & lhs, initialized & rhs ) +{ + lhs.swap(rhs) ; +} + +template +class value_initialized +{ + private : + + // initialized does value-initialization by default. + initialized m_data; + + public : + + T const & data() const + { + return m_data.data(); + } + + T& data() + { + return m_data.data(); + } + + void swap(value_initialized & arg) + { + m_data.swap(arg.m_data); + } + + operator T const &() const + { + return m_data; + } + + operator T&() + { + return m_data; + } +} ; template @@ -119,6 +196,7 @@ T const& get ( value_initialized const& x ) { return x.data() ; } + template T& get ( value_initialized& x ) { @@ -138,7 +216,7 @@ class initialized_value_t template operator T() const { - return get( value_initialized() ); + return initialized().data(); } }; @@ -147,5 +225,8 @@ initialized_value_t const initialized_value = {} ; } // namespace boost +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif #endif diff --git a/initialized_test.cpp b/initialized_test.cpp new file mode 100644 index 0000000..9380957 --- /dev/null +++ b/initialized_test.cpp @@ -0,0 +1,116 @@ +// Copyright 2010, Niels Dekker. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Test program for boost::initialized. +// +// 2 May 2010 (Created) Niels Dekker + +#include +#include + +#include + +namespace +{ + // Typical use case for boost::initialized: A generic class that + // holds a value of type T, which must be initialized by either + // value-initialization or direct-initialization. + template class key_value_pair + { + std::string m_key; + boost::initialized m_value; + public: + + // Value-initializes the object held by m_value. + key_value_pair() { } + + // Value-initializes the object held by m_value. + explicit key_value_pair(const std::string& key) + : + m_key(key) + { + } + + // Direct-initializes the object held by m_value. + key_value_pair(const std::string& key, const T& value) + : + m_key(key), m_value(value) + { + } + + const T& get_value() const + { + return m_value; + } + }; + + + // Tells whether the argument is value-initialized. + bool is_value_initialized(const int& arg) + { + return arg == 0; + } + + + // Tells whether the argument is value-initialized. + bool is_value_initialized(const std::string& arg) + { + return arg.empty(); + } + + struct foo + { + int data; + }; + + bool operator==(const foo& lhs, const foo& rhs) + { + return lhs.data == rhs.data; + } + + + // Tells whether the argument is value-initialized. + bool is_value_initialized(const foo& arg) + { + return arg.data == 0; + } + + + template + void test_key_value_pair(const T& magic_value) + { + // The value component of a default key_value_pair must be value-initialized. + key_value_pair default_key_value_pair; + BOOST_TEST( is_value_initialized(default_key_value_pair.get_value() ) ); + + // The value component of a key_value_pair that only has its key explicitly specified + // must also be value-initialized. + BOOST_TEST( is_value_initialized(key_value_pair("key").get_value()) ); + + // However, the value component of the following key_value_pair must be + // "magic_value", as it must be direct-initialized. + BOOST_TEST( key_value_pair("key", magic_value).get_value() == magic_value ); + } +} + + +// Tests boost::initialize for a fundamental type, a type with a +// user-defined constructor, and a user-defined type without +// a user-defined constructor. +int main() +{ + + const int magic_number = 42; + test_key_value_pair(magic_number); + + const std::string magic_string = "magic value"; + test_key_value_pair(magic_string); + + const foo magic_foo = { 42 }; + test_key_value_pair(magic_foo); + + return boost::report_errors(); +} diff --git a/initialized_test_fail1.cpp b/initialized_test_fail1.cpp new file mode 100644 index 0000000..ffeecab --- /dev/null +++ b/initialized_test_fail1.cpp @@ -0,0 +1,33 @@ +// Copyright 2010, Niels Dekker. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Test program for boost::initialized. Must fail to compile. +// +// Initial: 2 May 2010 + +#include + +namespace +{ + void direct_initialize_from_int() + { + // Okay: initialized supports direct-initialization from T. + boost::initialized direct_initialized_int(1); + } + + void copy_initialize_from_int() + { + // The following line should not compile, because initialized + // was not intended to supports copy-initialization from T. + boost::initialized copy_initialized_int = 1; + } +} + +int main() +{ + // This should fail to compile, so there is no need to call any function. + return 0; +} diff --git a/initialized_test_fail2.cpp b/initialized_test_fail2.cpp new file mode 100644 index 0000000..f3fbf39 --- /dev/null +++ b/initialized_test_fail2.cpp @@ -0,0 +1,37 @@ +// Copyright 2010, Niels Dekker. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Test program for boost::initialized. Must fail to compile. +// +// Initial: 2 May 2010 + +#include + +namespace +{ + void from_value_initialized_to_initialized() + { + boost::value_initialized value_initialized_int; + + // Okay: initialized can be initialized by value_initialized. + boost::initialized initialized_int(value_initialized_int); + } + + void from_initialized_to_value_initialized() + { + boost::initialized initialized_int(13); + + // The following line should not compile, because initialized + // should not be convertible to value_initialized. + boost::value_initialized value_initialized_int(initialized_int); + } +} + +int main() +{ + // This should fail to compile, so there is no need to call any function. + return 0; +} diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 3111cad..78bdd7f 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -32,9 +32,12 @@ test-suite utility [ compile result_of_test.cpp ] [ run ../shared_iterator_test.cpp ] [ run ../value_init_test.cpp ] + [ run ../initialized_test.cpp ] [ compile-fail ../value_init_test_fail1.cpp ] [ compile-fail ../value_init_test_fail2.cpp ] [ compile-fail ../value_init_test_fail3.cpp ] + [ compile-fail ../initialized_test_fail1.cpp ] + [ compile-fail ../initialized_test_fail2.cpp ] [ run ../verify_test.cpp ] ; diff --git a/value_init.htm b/value_init.htm index 57b2313..018f63b 100644 --- a/value_init.htm +++ b/value_init.htm @@ -33,6 +33,7 @@ @@ -123,6 +124,12 @@ constructed by the following declaration:

      +The template initialized +offers both value-initialization and direct-initialization. +It is especially useful as a data member type, allowing the very same object +to be either direct-initialized or value-initialized. +

      +

      The const object initialized_value allows value-initializing a variable as follows:

      @@ -340,6 +347,52 @@ the wrapped object is always performed with the get() idiom:

      value_initialized<int> x ;
      get(x) = 1 ; // OK

      value_initialized<int const> cx ;
      get(x) = 1 ; // ERROR: Cannot modify a const object

      value_initialized<int> const x_c ;
      get(x_c) = 1 ; // ERROR: Cannot modify a const object

      value_initialized<int const> const cx_c ;
      get(cx_c) = 1 ; // ERROR: Cannot modify a const object
      +

      template class initialized<T>

      + +
      namespace boost {

      template<class T>
      class initialized
      { +
      public : +
      initialized() : x() {} +
      explicit initialized(T const & arg) : x(arg) {} +
      operator T const &() const; +
      operator T&(); +
      T const &data() const; +
      T& data(); +
      void swap( value_initialized<T>& ); +
      +
      private : +
      unspecified x ; +
      } ; +
      +
      template<class T> +
      T const& get ( initialized<T> const& x ); +
      +
      template<class T> +
      T& get ( initialized<T>& x ); +
      +
      } // namespace boost +
      + +The template class boost::initialized<T> supports both value-initialization +and direct-initialization, so its interface is a superset of the interface +of value_initialized<T>: Its default-constructor +value-initializes the wrapped object just like the default-constructor of +value_initialized<T>, but boost::initialized<T> +also offers an extra explicit +constructor, which direct-initializes the wrapped object by the specified value. +

      + +initialized<T> is especially useful when the wrapped +object must be either value-initialized or direct-initialized, depending on +runtime conditions. For example, initialized<T> could +hold the value of a data member that may be value-initialized by some +constructors, and direct-initialized by others. +On the other hand, if it is known beforehand that the +object must always be value-initialized, value_initialized<T> +may be preferable. And if the object must always be +direct-initialized, none of the two wrappers really needs to be used. +

      + +

      initialized_value

      @@ -399,6 +452,9 @@ Special thanks to Björn Karlsson who carefully edited and completed this do
       

      value_initialized was reimplemented by Fernando Cacciola and Niels Dekker for Boost release version 1.35 (2008), offering a workaround to various compiler issues.

      +

      boost::initialized was very much inspired by feedback from Edward Diener and + Jeffrey Hellrung. +

      initialized_value was written by Niels Dekker, and added to Boost release version 1.36 (2008).

      Developed by Fernando Cacciola, @@ -407,9 +463,9 @@ for Boost release version 1.35 (2008), offering a workaround to various compiler


      -

      Revised 03 October 2009

      +

      Revised 1 May 2010

      -

      © Copyright Fernando Cacciola, 2002, 2009.

      +

      © Copyright Fernando Cacciola, 2002 - 2010.

      Distributed under the Boost Software License, Version 1.0. See www.boost.org/LICENSE_1_0.txt

      From f29a5db08e94b384b76d9c148d8af5d14c8e0817 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Thu, 13 May 2010 14:36:06 +0000 Subject: [PATCH 154/164] Hopefully fixed value_initialized compile errors on clang and comeau (strict mode) reported by Christopher Jefferson, see #4213 [SVN r61947] --- include/boost/utility/value_init.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index 8392f70..17e597b 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -163,7 +163,12 @@ class value_initialized initialized m_data; public : - + + value_initialized() + : + m_data() + { } + T const & data() const { return m_data.data(); From e601fcb9c9e2838d238b53d2b84f9997e9f63e5e Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 16 May 2010 11:08:00 +0000 Subject: [PATCH 155/164] Locally disabled a trivial MSVC warning in value_init.hpp (C4512, "assignment operator could not be generated") [SVN r62030] --- include/boost/utility/value_init.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index 17e597b..8623911 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -35,6 +35,9 @@ // It is safe to ignore the following warning from MSVC 7.1 or higher: // "warning C4351: new behavior: elements of array will be default initialized" #pragma warning(disable: 4351) +// It is safe to ignore the following MSVC warning, which may pop up when T is +// a const type: "warning C4512: assignment operator could not be generated". +#pragma warning(disable: 4512) #endif #endif From 6239e685a2bed4b547f71bebff0e4b1075e58f11 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sat, 22 May 2010 22:05:54 +0000 Subject: [PATCH 156/164] value_init_test now uses lightweight_test by Peter Dimov; see #4246. Fernando Cacciola mailed me he agreed as well. [SVN r62158] --- value_init_test.cpp | 87 ++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 45 deletions(-) diff --git a/value_init_test.cpp b/value_init_test.cpp index 98b8860..bee8e10 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -22,7 +22,7 @@ #pragma hdrstop #endif -#include "boost/test/minimal.hpp" +#include // // Sample POD type @@ -215,7 +215,7 @@ template void check_initialized_value ( T const& y ) { T initializedValue = boost::initialized_value ; - BOOST_CHECK ( y == initializedValue ) ; + BOOST_TEST ( y == initializedValue ) ; } #ifdef __BORLANDC__ @@ -245,128 +245,125 @@ void check_initialized_value( NonPOD const& ) template bool test ( T const& y, T const& z ) { - const boost::unit_test::counter_t counter_before_test = boost::minimal_test::errors_counter(); + const int errors_before_test = boost::detail::test_errors(); check_initialized_value(y); boost::value_initialized x ; - BOOST_CHECK ( y == x ) ; - BOOST_CHECK ( y == boost::get(x) ) ; + BOOST_TEST ( y == x ) ; + BOOST_TEST ( y == boost::get(x) ) ; static_cast(x) = z ; boost::get(x) = z ; - BOOST_CHECK ( x == z ) ; + BOOST_TEST ( x == z ) ; boost::value_initialized const x_c ; - BOOST_CHECK ( y == x_c ) ; - BOOST_CHECK ( y == boost::get(x_c) ) ; + BOOST_TEST ( y == x_c ) ; + BOOST_TEST ( y == boost::get(x_c) ) ; T& x_c_ref = const_cast( boost::get(x_c) ) ; x_c_ref = z ; - BOOST_CHECK ( x_c == z ) ; + BOOST_TEST ( x_c == z ) ; boost::value_initialized const copy1 = x; - BOOST_CHECK ( boost::get(copy1) == boost::get(x) ) ; + BOOST_TEST ( boost::get(copy1) == boost::get(x) ) ; boost::value_initialized copy2; copy2 = x; - BOOST_CHECK ( boost::get(copy2) == boost::get(x) ) ; + BOOST_TEST ( boost::get(copy2) == boost::get(x) ) ; boost::shared_ptr > ptr( new boost::value_initialized ); - BOOST_CHECK ( y == *ptr ) ; + BOOST_TEST ( y == *ptr ) ; #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) boost::value_initialized cx ; - BOOST_CHECK ( y == cx ) ; - BOOST_CHECK ( y == boost::get(cx) ) ; + BOOST_TEST ( y == cx ) ; + BOOST_TEST ( y == boost::get(cx) ) ; boost::value_initialized const cx_c ; - BOOST_CHECK ( y == cx_c ) ; - BOOST_CHECK ( y == boost::get(cx_c) ) ; + BOOST_TEST ( y == cx_c ) ; + BOOST_TEST ( y == boost::get(cx_c) ) ; #endif - return boost::minimal_test::errors_counter() == counter_before_test ; + return boost::detail::test_errors() == errors_before_test ; } -int test_main(int, char **) +int main(int, char **) { - BOOST_CHECK ( test( 0,1234 ) ) ; - BOOST_CHECK ( test( 0.0,12.34 ) ) ; - BOOST_CHECK ( test( POD(0,0,0.0), POD('a',1234,56.78f) ) ) ; - BOOST_CHECK ( test( NonPOD( std::string() ), NonPOD( std::string("something") ) ) ) ; + BOOST_TEST ( test( 0,1234 ) ) ; + BOOST_TEST ( test( 0.0,12.34 ) ) ; + BOOST_TEST ( test( POD(0,0,0.0), POD('a',1234,56.78f) ) ) ; + BOOST_TEST ( test( NonPOD( std::string() ), NonPOD( std::string("something") ) ) ) ; NonPOD NonPOD_object( std::string("NonPOD_object") ); - BOOST_CHECK ( test( 0, &NonPOD_object ) ) ; + BOOST_TEST ( test( 0, &NonPOD_object ) ) ; AggregatePODStruct zeroInitializedAggregatePODStruct = { 0.0f, '\0', 0 }; AggregatePODStruct nonZeroInitializedAggregatePODStruct = { 1.25f, 'a', -1 }; - BOOST_CHECK ( test(zeroInitializedAggregatePODStruct, nonZeroInitializedAggregatePODStruct) ); + BOOST_TEST ( test(zeroInitializedAggregatePODStruct, nonZeroInitializedAggregatePODStruct) ); StringAndInt stringAndInt0; StringAndInt stringAndInt1; stringAndInt0.i = 0; stringAndInt1.i = 1; stringAndInt1.s = std::string("1"); - BOOST_CHECK ( test(stringAndInt0, stringAndInt1) ); + BOOST_TEST ( test(stringAndInt0, stringAndInt1) ); StructWithDestructor structWithDestructor0; StructWithDestructor structWithDestructor1; structWithDestructor0.i = 0; structWithDestructor1.i = 1; - BOOST_CHECK ( test(structWithDestructor0, structWithDestructor1) ); + BOOST_TEST ( test(structWithDestructor0, structWithDestructor1) ); StructWithVirtualFunction structWithVirtualFunction0; StructWithVirtualFunction structWithVirtualFunction1; structWithVirtualFunction0.i = 0; structWithVirtualFunction1.i = 1; - BOOST_CHECK ( test(structWithVirtualFunction0, structWithVirtualFunction1) ); + BOOST_TEST ( test(structWithVirtualFunction0, structWithVirtualFunction1) ); DerivedFromAggregatePODStruct derivedFromAggregatePODStruct0; DerivedFromAggregatePODStruct derivedFromAggregatePODStruct1; static_cast(derivedFromAggregatePODStruct0) = zeroInitializedAggregatePODStruct; static_cast(derivedFromAggregatePODStruct1) = nonZeroInitializedAggregatePODStruct; - BOOST_CHECK ( test(derivedFromAggregatePODStruct0, derivedFromAggregatePODStruct1) ); + BOOST_TEST ( test(derivedFromAggregatePODStruct0, derivedFromAggregatePODStruct1) ); AggregatePODStructWrapper aggregatePODStructWrapper0; AggregatePODStructWrapper aggregatePODStructWrapper1; aggregatePODStructWrapper0.dataMember = zeroInitializedAggregatePODStruct; aggregatePODStructWrapper1.dataMember = nonZeroInitializedAggregatePODStruct; - BOOST_CHECK ( test(aggregatePODStructWrapper0, aggregatePODStructWrapper1) ); + BOOST_TEST ( test(aggregatePODStructWrapper0, aggregatePODStructWrapper1) ); ArrayOfBytes zeroInitializedArrayOfBytes = { 0 }; boost::value_initialized valueInitializedArrayOfBytes; - BOOST_CHECK (std::memcmp(get(valueInitializedArrayOfBytes), zeroInitializedArrayOfBytes, sizeof(ArrayOfBytes)) == 0); + BOOST_TEST (std::memcmp(get(valueInitializedArrayOfBytes), zeroInitializedArrayOfBytes, sizeof(ArrayOfBytes)) == 0); boost::value_initialized valueInitializedArrayOfBytes2; valueInitializedArrayOfBytes2 = valueInitializedArrayOfBytes; - BOOST_CHECK (std::memcmp(get(valueInitializedArrayOfBytes), get(valueInitializedArrayOfBytes2), sizeof(ArrayOfBytes)) == 0); + BOOST_TEST (std::memcmp(get(valueInitializedArrayOfBytes), get(valueInitializedArrayOfBytes2), sizeof(ArrayOfBytes)) == 0); boost::value_initialized copyFunctionCallTester1; - BOOST_CHECK ( ! get(copyFunctionCallTester1).is_copy_constructed); - BOOST_CHECK ( ! get(copyFunctionCallTester1).is_assignment_called); + BOOST_TEST ( ! get(copyFunctionCallTester1).is_copy_constructed); + BOOST_TEST ( ! get(copyFunctionCallTester1).is_assignment_called); boost::value_initialized copyFunctionCallTester2 = boost::value_initialized(copyFunctionCallTester1); - BOOST_CHECK ( get(copyFunctionCallTester2).is_copy_constructed); - BOOST_CHECK ( ! get(copyFunctionCallTester2).is_assignment_called); + BOOST_TEST ( get(copyFunctionCallTester2).is_copy_constructed); + BOOST_TEST ( ! get(copyFunctionCallTester2).is_assignment_called); boost::value_initialized copyFunctionCallTester3; copyFunctionCallTester3 = boost::value_initialized(copyFunctionCallTester1); - BOOST_CHECK ( ! get(copyFunctionCallTester3).is_copy_constructed); - BOOST_CHECK ( get(copyFunctionCallTester3).is_assignment_called); + BOOST_TEST ( ! get(copyFunctionCallTester3).is_copy_constructed); + BOOST_TEST ( get(copyFunctionCallTester3).is_assignment_called); boost::value_initialized swapFunctionCallTester1; boost::value_initialized 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 ); + BOOST_TEST( get(swapFunctionCallTester1).data == 2 ); + BOOST_TEST( get(swapFunctionCallTester2).data == 1 ); + BOOST_TEST( get(swapFunctionCallTester1).is_custom_swap_called ); + BOOST_TEST( get(swapFunctionCallTester2).is_custom_swap_called ); - return 0; + return boost::report_errors(); } -unsigned int expected_failures = 0; - - From a991936c965321af6075d4752ae8c8ebc8e360e7 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 30 May 2010 09:19:09 +0000 Subject: [PATCH 157/164] Made memset call in value_init conditional, see #3869. Updated the section "compiler issues" of its documentation. [SVN r62307] --- include/boost/utility/value_init.hpp | 24 +++++++- value_init.htm | 82 +++++++++++++++++++--------- 2 files changed, 76 insertions(+), 30 deletions(-) diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index 8623911..5de9585 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -10,6 +10,7 @@ // 21 Ago 2008 (Added swap) Niels Dekker, Fernando Cacciola // 20 Feb 2009 (Fixed logical const-ness issues) Niels Dekker, Fernando Cacciola // 03 Apr 2010 (Added initialized, suggested by Jeffrey Hellrung, fixing #3472) Niels Dekker +// 30 May 2010 (Made memset call conditional, fixing #3869) Niels Dekker // #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP @@ -21,6 +22,7 @@ // contains. More details on these issues are at libs/utility/value_init.htm #include +#include // For BOOST_NO_COMPLETE_VALUE_INITIALIZATION. #include #include #include @@ -41,6 +43,23 @@ #endif #endif +#ifdef BOOST_NO_COMPLETE_VALUE_INITIALIZATION + // Implementation detail: The macro BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED + // suggests that a workaround should be applied, because of compiler issues + // regarding value-initialization. + #define BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED +#endif + +// Implementation detail: The macro BOOST_DETAIL_VALUE_INIT_WORKAROUND +// switches the value-initialization workaround either on or off. +#ifndef BOOST_DETAIL_VALUE_INIT_WORKAROUND + #ifdef BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED + #define BOOST_DETAIL_VALUE_INIT_WORKAROUND 1 + #else + #define BOOST_DETAIL_VALUE_INIT_WORKAROUND 0 + #endif +#endif + namespace boost { template @@ -82,10 +101,9 @@ class initialized initialized() { - // Note: the following memset call will become conditional when ticket #3869 is fixed: - // https://svn.boost.org/trac/boost/ticket/3869 reported by Aleksey Gurtovoy. +#if BOOST_DETAIL_VALUE_INIT_WORKAROUND std::memset(&x, 0, sizeof(x)); - +#endif new (wrapper_address()) wrapper(); } diff --git a/value_init.htm b/value_init.htm index 018f63b..4ae9177 100644 --- a/value_init.htm +++ b/value_init.htm @@ -223,37 +223,65 @@ it may in practice still be left uninitialized, because of those compiler issues! It's hard to make a general statement on what those issues are like, because they depend on the compiler you are using, its version number, and the type of object you would like to have value-initialized. -Compilers usually support value-initialization for built-in types properly. -But objects of user-defined types that involve aggregates may in some cases -be partially, or even entirely left uninitialized, when they should be value-initialized. +All compilers we have tested so far support value-initialization for arithmetic types properly. +However, various compilers may leave some types of aggregates uninitialized, when they +should be value-initialized. Value-initialization of objects of a pointer-to-member type may also +go wrong on various compilers.

      -We have encountered issues regarding value-initialization on compilers by -Microsoft, Sun, Borland, and GNU. Here is a list of bug reports on those issues: - -
      - -Microsoft Feedback ID 100744 - Value-initialization in new-expression -
      Reported by Pavel Kuznetsov (MetaCommunications Engineering), 2005-07-28 -
      - -GCC Bug 30111 - Value-initialization of POD base class doesn't initialize members -
      Reported by Jonathan Wakely, 2006-12-07 -
      - -GCC Bug 33916 - Default constructor fails to initialize array members -
      Reported by Michael Elizabeth Chastain, 2007-10-26 -
      - -Borland Report 51854 - Value-initialization: POD struct should be zero-initialized -
      Reported by Niels Dekker (LKEB, Leiden University Medical Center), 2007-09-11 -
      -
      +At the moment of writing, May 2010, the following reported issues regarding +value-initialization are still there in current compiler releases: +

      +Note that all known GCC issues regarding value-initialization are +fixed with GCC version 4.4, including +GCC Bug 30111. +Clang also has completely implemented value-initialization, as far as we know, +now that Clang Bug 7139 is fixed.

      + New versions of value_initialized (Boost release version 1.35 or higher) -offer a workaround to these issues: value_initialized will now clear -its internal data, prior to constructing the object that it contains. +offer a workaround to these issues: value_initialized may now clear +its internal data, prior to constructing the object that it contains. It will do +so for those compilers that need to have such a workaround, based on the +compiler defect macro BOOST_NO_COMPLETE_VALUE_INITIALIZATION.

      Types and objects

      @@ -463,7 +491,7 @@ for Boost release version 1.35 (2008), offering a workaround to various compiler


      -

      Revised 1 May 2010

      +

      Revised 30 May 2010

      © Copyright Fernando Cacciola, 2002 - 2010.

      From 9da96d97373988cda1582f63cf4c6dfa97082ada Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 16 Jun 2010 08:45:43 +0000 Subject: [PATCH 158/164] Added value_init_workaround_test, reviewed by Fernando Cacciola, see #3869 [SVN r63014] --- test/Jamfile.v2 | 1 + value_init_workaround_test.cpp | 119 +++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 value_init_workaround_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 78bdd7f..d3fc34c 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -32,6 +32,7 @@ test-suite utility [ compile result_of_test.cpp ] [ run ../shared_iterator_test.cpp ] [ run ../value_init_test.cpp ] + [ run ../value_init_workaround_test.cpp ] [ run ../initialized_test.cpp ] [ compile-fail ../value_init_test_fail1.cpp ] [ compile-fail ../value_init_test_fail2.cpp ] diff --git a/value_init_workaround_test.cpp b/value_init_workaround_test.cpp new file mode 100644 index 0000000..958ddb3 --- /dev/null +++ b/value_init_workaround_test.cpp @@ -0,0 +1,119 @@ +// Copyright 2010, Niels Dekker. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Test program for the boost::value_initialized workaround. +// +// 30 May 2010 (Created) Niels Dekker + +// Switch the workaround off, before inluding "value_init.hpp". +#define BOOST_DETAIL_VALUE_INIT_WORKAROUND 0 +#include + +#include // For cout. +#include // For EXIT_SUCCESS and EXIT_FAILURE. + +namespace +{ + struct empty_struct + { + }; + + // A POD aggregate struct derived from an empty struct. + // Similar to struct Foo1 from Microsoft Visual C++ bug report 484295, + // "VC++ does not value-initialize members of derived classes without + // user-declared constructor", reported in 2009 by Sylvester Hesp: + // https://connect.microsoft.com/VisualStudio/feedback/details/484295 + struct derived_struct: empty_struct + { + int data; + }; + + bool is_value_initialized(const derived_struct& arg) + { + return arg.data == 0; + } + + + class virtual_destructor_holder + { + public: + int i; + virtual ~virtual_destructor_holder() + { + } + }; + + bool is_value_initialized(const virtual_destructor_holder& arg) + { + return arg.i == 0; + } + + template + bool is_value_initialized(const T(& arg)[2]) + { + return + is_value_initialized(arg[0]) && + is_value_initialized(arg[1]); + } + + template + bool is_value_initialized(const boost::value_initialized& arg) + { + return is_value_initialized(arg.data()); + } + + // Returns zero when the specified object is value-initializated, and one otherwise. + // Prints a message to standard output if the value-initialization has failed. + template + unsigned failed_to_value_initialized(const T& object, const char *const object_name) + { + if ( is_value_initialized(object) ) + { + return 0u; + } + else + { + std::cout << "Note: Failed to value-initialize " << object_name << '.' << std::endl; + return 1u; + } + } + +// A macro that passed both the name and the value of the specified object to +// the function above here. +#define FAILED_TO_VALUE_INITIALIZE(value) failed_to_value_initialized(value, #value) + + // Equivalent to the dirty_stack() function from GCC Bug 33916, + // "Default constructor fails to initialize array members", reported in 2007 by + // Michael Elizabeth Chastain: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916 + void dirty_stack() + { + unsigned char array_on_stack[4096]; + for (unsigned i = 0; i < sizeof(array_on_stack); ++i) + { + array_on_stack[i] = 0x11; + } + } + +} + + +int main() +{ + dirty_stack(); + + // TODO More types may be added later. + const unsigned num_failures = + FAILED_TO_VALUE_INITIALIZE(boost::value_initialized()) + + FAILED_TO_VALUE_INITIALIZE(boost::value_initialized()); + +#ifdef BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED + // One or more failures are expected. + return num_failures > 0 ? EXIT_SUCCESS : EXIT_FAILURE; +#else + // No failures are expected. + return num_failures == 0 ? EXIT_SUCCESS : EXIT_FAILURE; +#endif +} From b4a08fc80eb3dde3a313ecd092e719918f6179bc Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Thu, 17 Jun 2010 16:53:55 +0000 Subject: [PATCH 159/164] Added test for private_int_array_pair, hoping to (possibly) fix a minion-clang/darwin-4.2.1 failure at boost.org/development/tests/trunk/developer/utility_.html [SVN r63045] --- value_init_workaround_test.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/value_init_workaround_test.cpp b/value_init_workaround_test.cpp index 958ddb3..190c267 100644 --- a/value_init_workaround_test.cpp +++ b/value_init_workaround_test.cpp @@ -6,7 +6,7 @@ // // Test program for the boost::value_initialized workaround. // -// 30 May 2010 (Created) Niels Dekker +// 17 June 2010 (Created) Niels Dekker // Switch the workaround off, before inluding "value_init.hpp". #define BOOST_DETAIL_VALUE_INIT_WORKAROUND 0 @@ -51,6 +51,30 @@ namespace return arg.i == 0; } + // Equivalent to the Stats class from GCC Bug 33916, + // "Default constructor fails to initialize array members", reported in 2007 by + // Michael Elizabeth Chastain: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916 + // and fixed for GCC 4.2.4. + class private_int_array_pair + { + friend bool is_value_initialized(const private_int_array_pair& arg); + private: + int first[12]; + int second[12]; + }; + + bool is_value_initialized(const private_int_array_pair& arg) + { + for ( unsigned i = 0; i < 12; ++i) + { + if ( (arg.first[i] != 0) || (arg.second[i] != 0) ) + { + return false; + } + } + return true; + } + template bool is_value_initialized(const T(& arg)[2]) { @@ -107,7 +131,8 @@ int main() // TODO More types may be added later. const unsigned num_failures = FAILED_TO_VALUE_INITIALIZE(boost::value_initialized()) + - FAILED_TO_VALUE_INITIALIZE(boost::value_initialized()); + FAILED_TO_VALUE_INITIALIZE(boost::value_initialized()) + + FAILED_TO_VALUE_INITIALIZE(boost::value_initialized()); #ifdef BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED // One or more failures are expected. From a4b8043e68ee2f466517529d5f343704b1c3d4c3 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 14 Jul 2010 08:15:33 +0000 Subject: [PATCH 160/164] Fix some header links. [SVN r64006] --- include/boost/utility/compare_pointees.hpp | 2 +- include/boost/utility/detail/in_place_factory_prefix.hpp | 2 +- include/boost/utility/detail/in_place_factory_suffix.hpp | 2 +- include/boost/utility/in_place_factory.hpp | 2 +- include/boost/utility/typed_in_place_factory.hpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/utility/compare_pointees.hpp b/include/boost/utility/compare_pointees.hpp index e6888a6..7e2515c 100644 --- a/include/boost/utility/compare_pointees.hpp +++ b/include/boost/utility/compare_pointees.hpp @@ -4,7 +4,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // -// See http://www.boost.org/lib/optional for documentation. +// See http://www.boost.org/libs/optional for documentation. // // You are welcome to contact the author at: // fernando_cacciola@hotmail.com diff --git a/include/boost/utility/detail/in_place_factory_prefix.hpp b/include/boost/utility/detail/in_place_factory_prefix.hpp index 6ce7247..afd76b5 100644 --- a/include/boost/utility/detail/in_place_factory_prefix.hpp +++ b/include/boost/utility/detail/in_place_factory_prefix.hpp @@ -5,7 +5,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // -// See http://www.boost.org/lib/optional for documentation. +// See http://www.boost.org/libs/optional for documentation. // // You are welcome to contact the author at: // fernando_cacciola@hotmail.com diff --git a/include/boost/utility/detail/in_place_factory_suffix.hpp b/include/boost/utility/detail/in_place_factory_suffix.hpp index b1fc4d3..58f48c7 100644 --- a/include/boost/utility/detail/in_place_factory_suffix.hpp +++ b/include/boost/utility/detail/in_place_factory_suffix.hpp @@ -5,7 +5,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // -// See http://www.boost.org/lib/optional for documentation. +// See http://www.boost.org/libs/optional for documentation. // // You are welcome to contact the author at: // fernando_cacciola@hotmail.com diff --git a/include/boost/utility/in_place_factory.hpp b/include/boost/utility/in_place_factory.hpp index 16eaacf..f84b003 100644 --- a/include/boost/utility/in_place_factory.hpp +++ b/include/boost/utility/in_place_factory.hpp @@ -5,7 +5,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // -// See http://www.boost.org/lib/optional for documentation. +// See http://www.boost.org/libs/optional for documentation. // // You are welcome to contact the author at: // fernando_cacciola@hotmail.com diff --git a/include/boost/utility/typed_in_place_factory.hpp b/include/boost/utility/typed_in_place_factory.hpp index 347b7f4..833a346 100644 --- a/include/boost/utility/typed_in_place_factory.hpp +++ b/include/boost/utility/typed_in_place_factory.hpp @@ -5,7 +5,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // -// See http://www.boost.org/lib/optional for documentation. +// See http://www.boost.org/libs/optional for documentation. // // You are welcome to contact the author at: // fernando_cacciola@hotmail.com From 94b91e8c92b58ec400045f301f00e8c3ba512ad5 Mon Sep 17 00:00:00 2001 From: Daniel Walker Date: Mon, 9 Aug 2010 16:07:20 +0000 Subject: [PATCH 161/164] updated result_of documentation [SVN r64695] --- utility.htm | 99 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 79 insertions(+), 20 deletions(-) diff --git a/utility.htm b/utility.htm index d4c7205..328aff2 100644 --- a/utility.htm +++ b/utility.htm @@ -151,37 +151,96 @@ void f() { result_of<F(T1, T2, ..., TN)>::type defines the result type of the expression f(t1, t2, - ...,tN). The implementation permits + ...,tN)
      . This implementation permits the type F to be a function pointer, function reference, member function pointer, or class - type.

      If your compiler does not support - decltype, then when F is a - class type with a member type result_type, + type. By default, N may be any value between 0 and + 10. To change the upper limit, define the macro + BOOST_RESULT_OF_NUM_ARGS to the maximum + value for N. Class template result_of + resides in the header <boost/utility/result_of.hpp>.

      + +

      If your compiler supports decltype, + then you can enable automatic result type deduction by + defining the macro BOOST_RESULT_OF_USE_DECLTYPE, + as in the following example.

      + +
      +
      #define BOOST_RESULT_OF_USE_DECLTYPE
      +#include <boost/utility/result_of.hpp>
      +
      +struct functor {
      +    template<class T>
      +    T operator()(T x)
      +    {
      +        return x;
      +    }
      +};
      +
      +typedef boost::result_of<
      +    functor(int)
      +>::type type;
      +
      + +

      If your compiler does not support + decltype, then automatic result type + deduction of function objects is not + possible. Instead, result_of + uses the following protocol to allow the programmer to + specify a type. When F is a class type with a + member type result_type, result_of<F(T1, T2, ..., TN)> is - F::result_type. When F - does not contain result_type, + F::result_type. When F does + not contain result_type, result_of<F(T1, T2, ..., TN)> is F::result<F(T1, T2, ..., TN)>::type when N > 0 or void - when N = 0. For additional - information about result_of, see the - C++ Library Technical Report, N1836, - or, for motivation and design rationale, the result_of proposal.

      + when N = 0. Note that it is the + responsibility of the programmer to ensure that + function objects accurately advertise their result + type via this protocol, as in the following + example.

      -

      Class template result_of resides in - the header <boost/utility/result_of.hpp>. By - default, N may be any value between 0 and - 10. To change the upper limit, define the macro - BOOST_RESULT_OF_NUM_ARGS to the maximum - value for N.

      +
      +
      struct functor {
      +    template<class> struct result;
      +
      +    template<class F, class T>
      +    struct result<F(T)> {
      +        typedef T type;
      +    };
      +
      +    template<class T>
      +    T operator()(T x)
      +    {
      +        return x;
      +    }
      +};
      +
      +typedef boost::result_of<
      +    functor(int)
      +>::type type;
      +
      -

      This implementation of result_of requires class template partial specialization, the ability to parse function types properly, and support for SFINAE. If result_of is not supported by your compiler, including the header boost/utility/result_of.hpp will define the macro BOOST_NO_RESULT_OF. Contributed by Doug Gregor.

      +

      This implementation of result_of + requires class template partial specialization, the + ability to parse function types properly, and support + for SFINAE. If result_of is not supported + by your compiler, including the header + boost/utility/result_of.hpp will + define the macro BOOST_NO_RESULT_OF.

      + +

      For additional information + about result_of, see the C++ Library + Technical Report, + N1836, + or, for motivation and design rationale, + the result_of proposal.

      + Contributed by Doug Gregor.

      Class templates for the Base-from-Member Idiom

      See separate documentation.

      From fb1d2effef8c3af015b14a25613eb61bf113c240 Mon Sep 17 00:00:00 2001 From: Daniel Walker Date: Mon, 9 Aug 2010 16:23:50 +0000 Subject: [PATCH 162/164] correction to result_of documentation [SVN r64696] --- utility.htm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/utility.htm b/utility.htm index 328aff2..3ac5d42 100644 --- a/utility.htm +++ b/utility.htm @@ -183,10 +183,9 @@ typedef boost::result_of< >::type type;
      -

      If your compiler does not support - decltype, then automatic result type - deduction of function objects is not - possible. Instead, result_of +

      If decltype is not enabled, + then automatic result type deduction of function + objects is not possible. Instead, result_of uses the following protocol to allow the programmer to specify a type. When F is a class type with a member type result_type, From f7e4b0e399b48558352c9fe9c9b2495d5950a8ea Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Thu, 16 Sep 2010 15:40:47 +0000 Subject: [PATCH 163/164] Make sure that utility/index.html has a complete list of components. Fixes #4629. [SVN r65437] --- index.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.html b/index.html index 5af6f75..307971f 100644 --- a/index.html +++ b/index.html @@ -14,16 +14,22 @@

      But that doesn't mean there isn't useful stuff here. Take a look:

      + addressof
      assert
      base_from_member
      + BOOST_BINARY
      call_traits
      checked_delete
      compressed_pair
      current_function
      enable_if
      + in_place_factory
      iterator_adaptors
      generator iterator adaptors
      + next/prior
      + noncopyable
      operators
      + result_of
      swap
      throw_exception
      utility
      From 71e78a0081a38dd87a140b82b590335a55b797ad Mon Sep 17 00:00:00 2001 From: John Maddock Date: Fri, 17 Sep 2010 12:12:03 +0000 Subject: [PATCH 164/164] Add declval and common type from Vicente J. Botet Escriba. Regenerate docs. [SVN r65443] --- doc/Jamfile.v2 | 68 +++++++++++++ doc/declval.qbk | 104 +++++++++++++++++++ doc/html/declval.html | 163 ++++++++++++++++++++++++++++++ include/boost/utility/declval.hpp | 44 ++++++++ index.html | 6 +- 5 files changed, 383 insertions(+), 2 deletions(-) create mode 100644 doc/Jamfile.v2 create mode 100644 doc/declval.qbk create mode 100644 doc/html/declval.html create mode 100644 include/boost/utility/declval.hpp diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 new file mode 100644 index 0000000..b12d71a --- /dev/null +++ b/doc/Jamfile.v2 @@ -0,0 +1,68 @@ + +# Copyright John Maddock 2005. Use, modification, and distribution are +# subject to the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +project : requirements + # Path for links to Boost: + boost.root=../../../.. + + # Some general style settings: + table.footnote.number.format=1 + footnote.number.format=1 + + # HTML options first: + # Use graphics not text for navigation: + navig.graphics=1 + # PDF Options: + # TOC Generation: this is needed for FOP-0.9 and later: + fop1.extensions=0 + xep.extensions=1 + # TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9! + fop.extensions=0 + # No indent on body text: + body.start.indent=0pt + # Margin size: + page.margin.inner=0.5in + # Margin size: + page.margin.outer=0.5in + # Paper type = A4 + paper.type=A4 + # Yes, we want graphics for admonishments: + admon.graphics=1 + # Set this one for PDF generation *only*: + # default pnd graphics are awful in PDF form, + # better use SVG's instead: + pdf:admon.graphics.extension=".svg" + pdf:admon.graphics.path=$(boost-images)/ + pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/libs/utility/doc/html +; + +using quickbook ; + +path-constant boost-images : ../../../doc/src/images ; + +xml declval : declval.qbk ; +boostbook standalone + : + declval + : + # File name of HTML output: + root.filename=declval + # How far down we chunk nested sections, basically all of them: + chunk.section.depth=0 + # Don't put the first section on the same page as the TOC: + chunk.first.sections=0 + # How far down sections get TOC's + toc.section.depth=1 + # Max depth in each TOC: + toc.max.depth=1 + # How far down we go with TOC's + generate.section.toc.level=1 + + ; + + + + + diff --git a/doc/declval.qbk b/doc/declval.qbk new file mode 100644 index 0000000..67e82d2 --- /dev/null +++ b/doc/declval.qbk @@ -0,0 +1,104 @@ +[/ + / Copyright (c) 2008 Howard Hinnant + / Copyright (c) 2008 Beman Dawes + / Copyright (c) 2009-20010 Vicente J. Botet Escriba + / + / Distributed under the Boost Software License, Version 1.0. (See accompanying + / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + /] + +[article Declval + [quickbook 1.5] + [authors [Hinnant, Howard]] + [authors [Dawes, Beman]] + [authors [Botet Escriba, Vicente J.]] + [copyright 2008 Howard Hinnant] + [copyright 2008 Beman Dawes] + [copyright 2009-2010 Vicente J. Botet Escriba] + [license + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + [@http://www.boost.org/LICENSE_1_0.txt]) + ] +] + +[/===============] +[section Overview] +[/===============] + +The motivation for `declval` was introduced in [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2958.html#Value N2958: +Moving Swap Forward]. Here follows a rewording of this chapter. + +With the provision of decltype, late-specified return types, and default template-arguments for function templates a +new generation of SFINAE patterns will emerge to at least partially compensate the lack of concepts on the C++0x timescale. +Using this technique, it is sometimes necessary to obtain an object of a known type in a non-using context, e.g. given the declaration + + template + T&& declval(); // not used + +as part of the function template declaration + + template + decltype(static_cast(declval())) convert(From&&); + +or as part of a class template definition + + template class result_of; + + template + struct result_of + { + typedef decltype(declval()(declval()...)) type; + }; + +The role of the function template declval() is a transformation of a type T into a value without using or evaluating this function. +The name is supposed to direct the reader's attention to the fact that the expression `declval()` is an lvalue if and only if +T is an lvalue-reference, otherwise an rvalue. To extend the domain of this function we can do a bit better by changing its declaration to + + template + typename std::add_rvalue_reference::type declval(); // not used + +which ensures that we can also use cv void as template parameter. The careful reader might have noticed that `declval()` +already exists under the name create() as part of the definition of the semantics of the type trait is_convertible in the C==0x standard. + +The provision of a new library component that allows the production of values in unevaluated expressions is considered as +important to realize constrained templates in C++0x where concepts are not available. +This extremely light-weight function is expected to be part of the daily tool-box of the C++0x programmer. + +[endsect] + + +[/=================] +[section:reference Reference ] +[/=================] + +`#include ` + + namespace boost { + + template + typename add_rvalue_reference::type declval(); //noexcept; // as unevaluated operand + + } // namespace boost + + +The library provides the function template declval to simplify the definition of expressions which occur as unevaluated operands. + + template + typename add_rvalue_reference::type declval(); + +[*Remarks:] If this function is used, the program is ill-formed. + +[*Remarks:] The template parameter T of declval may be an incomplete type. + +[*Example:] + + template + decltype(static_cast(declval())) convert(From&&); + +Declares a function template convert which only participats in overloading if the type From can be explicitly converted to type To. + +[endsect] + + + diff --git a/doc/html/declval.html b/doc/html/declval.html new file mode 100644 index 0000000..a2c5a01 --- /dev/null +++ b/doc/html/declval.html @@ -0,0 +1,163 @@ + + + +Declval + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +


      +
      +
      +
      +
      +

      +Declval

      +
      +

      +Howard Hinnant +

      +

      +Beman Dawes +

      +

      +Vicente J. Botet Escriba +

      +
      +
      +
      +
      +
      +

      + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +

      +
      +
      +
      +
      +
      +

      Table of Contents

      +
      +
      Overview
      +
      Reference
      +
      +
      +
      + +

      + The motivation for declval + was introduced in N2958: + Moving Swap Forward. Here follows a rewording of this chapter. +

      +

      + With the provision of decltype, late-specified return types, and default template-arguments + for function templates a new generation of SFINAE patterns will emerge to at + least partially compensate the lack of concepts on the C++0x timescale. Using + this technique, it is sometimes necessary to obtain an object of a known type + in a non-using context, e.g. given the declaration +

      +
      template<class T>
      +T&& declval(); // not used
      +
      +

      + as part of the function template declaration +

      +
      template<class To, class From>
      +decltype(static_cast<To>(declval<From>())) convert(From&&);
      +
      +

      + or as part of a class template definition +

      +
      template<class> class result_of;
      +
      +template<class Fn, class... ArgTypes>
      +struct result_of<Fn(ArgTypes...)> 
      +{
      +  typedef decltype(declval<Fn>()(declval<ArgTypes>()...)) type;
      +};
      +
      +

      + The role of the function template declval() is a transformation of a type T + into a value without using or evaluating this function. The name is supposed + to direct the reader's attention to the fact that the expression declval<T>() is + an lvalue if and only if T is an lvalue-reference, otherwise an rvalue. To + extend the domain of this function we can do a bit better by changing its declaration + to +

      +
      template<class T>
      +typename std::add_rvalue_reference<T>::type declval(); // not used
      +
      +

      + which ensures that we can also use cv void as template parameter. The careful + reader might have noticed that declval() already exists under the name create() as + part of the definition of the semantics of the type trait is_convertible in + the C==0x standard. +

      +

      + The provision of a new library component that allows the production of values + in unevaluated expressions is considered as important to realize constrained + templates in C++0x where concepts are not available. This extremely light-weight + function is expected to be part of the daily tool-box of the C++0x programmer. +

      +
      +
      + +

      + #include <boost/utility/declval.hpp> +

      +
      namespace boost {
      +
      +    template <typename T>
      +    typename add_rvalue_reference<T>::type declval(); //noexcept; // as unevaluated operand
      +
      +}  // namespace boost
      +
      +

      + The library provides the function template declval to simplify the definition + of expressions which occur as unevaluated operands. +

      +
      template <typename T>
      +typename add_rvalue_reference<T>::type declval();
      +
      +

      + Remarks: If this function is used, the program + is ill-formed. +

      +

      + Remarks: The template parameter T of declval + may be an incomplete type. +

      +

      + Example: +

      +
      template <class To, class From>
      +decltype(static_cast<To>(declval<From>())) convert(From&&);
      +
      +

      + Declares a function template convert which only participats in overloading + if the type From can be explicitly converted to type To. +

      +
      +
      + + + +

      Last revised: September 16, 2010 at 16:19:10 GMT

      +
      +
      + + diff --git a/include/boost/utility/declval.hpp b/include/boost/utility/declval.hpp new file mode 100644 index 0000000..41ec3dc --- /dev/null +++ b/include/boost/utility/declval.hpp @@ -0,0 +1,44 @@ +// common_type.hpp ---------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +#ifndef BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP +#define BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP + +#include + +//----------------------------------------------------------------------------// + +#include + +//----------------------------------------------------------------------------// +// // +// C++03 implementation of // +// Written by Vicente J. Botet Escriba // +//~ 20.3.4 Function template declval [declval] +//~ 1 The library provides the function template declval to simplify the definition of expressions which occur as +//~ unevaluated operands. +//~ 2 Remarks: If this function is used, the program is ill-formed. +//~ 3 Remarks: The template parameter T of declval may be an incomplete type. +//~ [ Example: + +//~ template +//~ decltype(static_cast(declval())) convert(From&&); + +//~ declares a function template convert which only participats in overloading if the type From can be +//~ explicitly converted to type To. For another example see class template common_type (20.7.6.6). —end +//~ example ] +// // +//----------------------------------------------------------------------------// + +namespace boost { + + template + typename add_rvalue_reference::type declval(); //noexcept; // as unevaluated operand + +} // namespace boost + +#endif // BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP diff --git a/index.html b/index.html index 307971f..d384487 100644 --- a/index.html +++ b/index.html @@ -22,7 +22,8 @@ checked_delete
      compressed_pair
      current_function
      - enable_if
      + declval
      + enable_if
      in_place_factory
      iterator_adaptors
      generator iterator adaptors
      @@ -33,7 +34,8 @@ swap
      throw_exception
      utility
      - value_init

      + value_init +


      © Copyright Beman Dawes, 2001