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 01/81] 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 02/81] 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 03/81] 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 04/81] 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 05/81] 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 06/81] 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 07/81] 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 08/81] 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 09/81] 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 10/81] 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 11/81] 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 12/81] 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 13/81] 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 14/81] 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 15/81] 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 16/81] 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 17/81] 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 18/81] 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 19/81] 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 20/81] 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 21/81] 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 22/81] 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 23/81] 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 24/81] 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 25/81] 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 26/81] 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 27/81] 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 28/81] 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 29/81] 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 30/81] 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 31/81] 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 32/81] 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 33/81] 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 34/81] 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 35/81] 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 36/81] 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 37/81] 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 38/81] 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 39/81] 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 40/81] 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 41/81] 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 42/81] 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 43/81] 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 44/81] =?UTF-8?q?With=20his=20kind=20permission,=20change?= =?UTF-8?q?=20Jaakko=20"J=C3=A4rvi"=20to=20"Jarvi"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [SVN r46808] --- enable_if/test/constructors.cpp | 2 +- enable_if/test/dummy_arg_disambiguation.cpp | 2 +- enable_if/test/lazy.cpp | 2 +- enable_if/test/lazy_test.cpp | 2 +- enable_if/test/member_templates.cpp | 2 +- enable_if/test/namespace_disambiguation.cpp | 2 +- enable_if/test/no_disambiguation.cpp | 2 +- enable_if/test/partial_specializations.cpp | 2 +- include/boost/ref.hpp | 2 +- include/boost/utility/enable_if.hpp | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/enable_if/test/constructors.cpp b/enable_if/test/constructors.cpp index 889133d..0d465de 100644 --- a/enable_if/test/constructors.cpp +++ b/enable_if/test/constructors.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/dummy_arg_disambiguation.cpp b/enable_if/test/dummy_arg_disambiguation.cpp index 90275e9..60dfdfd 100644 --- a/enable_if/test/dummy_arg_disambiguation.cpp +++ b/enable_if/test/dummy_arg_disambiguation.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/lazy.cpp b/enable_if/test/lazy.cpp index 117ec41..f04111e 100644 --- a/enable_if/test/lazy.cpp +++ b/enable_if/test/lazy.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/lazy_test.cpp b/enable_if/test/lazy_test.cpp index 10bb60c..9ec5324 100644 --- a/enable_if/test/lazy_test.cpp +++ b/enable_if/test/lazy_test.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/member_templates.cpp b/enable_if/test/member_templates.cpp index f7c00a0..55e2d80 100644 --- a/enable_if/test/member_templates.cpp +++ b/enable_if/test/member_templates.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/namespace_disambiguation.cpp b/enable_if/test/namespace_disambiguation.cpp index a53d3a7..45d4f0a 100644 --- a/enable_if/test/namespace_disambiguation.cpp +++ b/enable_if/test/namespace_disambiguation.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/no_disambiguation.cpp b/enable_if/test/no_disambiguation.cpp index 122d600..e2416ed 100644 --- a/enable_if/test/no_disambiguation.cpp +++ b/enable_if/test/no_disambiguation.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/partial_specializations.cpp b/enable_if/test/partial_specializations.cpp index 5c322ae..1d4db99 100644 --- a/enable_if/test/partial_specializations.cpp +++ b/enable_if/test/partial_specializations.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index ab09ae7..330ca65 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -15,7 +15,7 @@ // // ref.hpp - ref/cref, useful helper functions // -// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2001, 2002 Peter Dimov // Copyright (C) 2002 David Abrahams // diff --git a/include/boost/utility/enable_if.hpp b/include/boost/utility/enable_if.hpp index d77d108..d292c6a 100644 --- a/include/boost/utility/enable_if.hpp +++ b/include/boost/utility/enable_if.hpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) From 3c5c2bc107790c476e4523d3ab9e27173fc24327 Mon Sep 17 00:00:00 2001 From: Joseph Gauterin Date: Sat, 5 Jul 2008 11:16:38 +0000 Subject: [PATCH 45/81] 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 46/81] 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 47/81] 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 48/81] 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 49/81] 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 50/81] 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 51/81] 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 52/81] 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 53/81] 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 54/81] 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 55/81] 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 56/81] 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 57/81] 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 58/81] 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 59/81] 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 60/81] 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 61/81] 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 62/81] 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 63/81] 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 64/81] 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 65/81] 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 66/81] 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 67/81] 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 68/81] 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 69/81] 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 70/81] 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 71/81] 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 72/81] 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 73/81] 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 74/81] 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 75/81] 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 76/81] 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 77/81] 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 78/81] 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 79/81] 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 80/81] 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 81/81] 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