Compare commits

..

64 Commits

Author SHA1 Message Date
Daniel James
6741375cae Update 'more' links.
[SVN r44996]
2008-05-01 21:34:42 +00:00
Daniel James
f0f76aaff1 Merge with trunk.
[SVN r44810]
2008-04-27 08:13:25 +00:00
Daniel James
d6c957da65 Fix the lincense url in shared container iterator documentation.
[SVN r44641]
2008-04-20 17:59:47 +00:00
Daniel James
9862788664 Create a branch for documentation work.
[SVN r44584]
2008-04-19 14:48:18 +00:00
Emil Dotchevski
bafe37fdab Boost Exception header compilation tests added.
[SVN r44442]
2008-04-15 21:13:24 +00:00
Daniel Frey
be50b95508 Added test and fix for "convertible to bool" requirement
[SVN r44151]
2008-04-10 14:38:14 +00:00
Marshall Clow
96d573d6ca Replaced all occurrences of non-ASCII copyright symbol with '(c)' for people using non-ASCII code pages
[SVN r43992]
2008-04-02 01:42:32 +00:00
John Maddock
2412b864d6 Fix some inspection report issues.
[SVN r43633]
2008-03-15 18:41:51 +00:00
Emil Dotchevski
94865eabe6 boost exception
[SVN r43485]
2008-03-04 01:41:17 +00:00
Niels Dekker
50268d1b29 Tested the assignment of value_initialized<T>, for T being a C-style array. Related to the fix of changeset [43308]
[SVN r43309]
2008-02-18 22:13:21 +00:00
Niels Dekker
ad9108c1dc Fixed the assignment of value_initialized<T> for T being a C-style array. (The previous version would trigger a compile error in this case.)
[SVN r43308]
2008-02-18 22:11:19 +00:00
Daniel James
691e4b6c34 Link to people pages on the website, as they've been removed from the download.
[SVN r43209]
2008-02-10 14:56:22 +00:00
Niels Dekker
28596e678d 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]
2008-01-30 22:42:23 +00:00
Niels Dekker
1beca24dd8 Removed local named variable from value_initialized::operator=, as Fernando Cacciola suggested me to avoid unnecessary named variables.
[SVN r42869]
2008-01-19 20:52:04 +00:00
Niels Dekker
721764937f 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]
2008-01-19 20:21:18 +00:00
Niels Dekker
a511007d0f Added test and documentation for convenience class initialized_value, that was added with changeset [42815]
[SVN r42816]
2008-01-16 09:37:25 +00:00
Niels Dekker
8ce58b1675 Added convenience class initialized_value, as announced at http://article.gmane.org/gmane.comp.lib.boost.devel/169833
[SVN r42815]
2008-01-16 09:35:12 +00:00
Niels Dekker
9ed68b8321 value_init doc + test: Added revision date.
[SVN r42798]
2008-01-15 19:53:28 +00:00
Niels Dekker
79bbf71d0d Minor "beautifications" of value_init documentation, inc. placing references in order of appearance
[SVN r42779]
2008-01-14 21:46:20 +00:00
Niels Dekker
ac93de7c1b Documented value_init workaround to compiler issues, added new introduction, updated to 2003 edition of C++ Standard -- reviewed by Fernando Cacciola
[SVN r42771]
2008-01-14 18:17:30 +00:00
Niels Dekker
d731b8e1c5 Added value_init tests, testing copy construction and assignment.
[SVN r42278]
2007-12-24 22:00:37 +00:00
Niels Dekker
ac1567b3fc value_init now uses aligned_storage::address(), instead of "&x", as recommended by Fernando Cacciola (by mail)
[SVN r42277]
2007-12-24 20:42:16 +00:00
Douglas Gregor
c1fd670480 Reduce header dependencies, from Shunsuke Sogame. Fixes #1535
[SVN r42234]
2007-12-21 21:18:17 +00:00
Niels Dekker
01274cf6ac 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]
2007-12-09 22:49:58 +00:00
Niels Dekker
8080673977 Added value_init tests if a copy function of T is called when value_initialized<T> is copied -- a case I hadn't thought of before...
[SVN r41919]
2007-12-09 11:53:08 +00:00
Niels Dekker
a470b591fb Added value_init test for an value_initialized<T> object allocated on the heap.
[SVN r41667]
2007-12-03 21:41:59 +00:00
Niels Dekker
e1a63495b6 Added missing #include to value_init_test.cpp. (My mistake!)
[SVN r41648]
2007-12-03 18:20:19 +00:00
Niels Dekker
7300ac83f1 Added value_init test for C style array of bytes
[SVN r41647]
2007-12-03 18:14:37 +00:00
Niels Dekker
882d38c2c7 Added value_init tests, based upon GCC bug report by Jonathan Wakely. Added URL to Borland bug report.
[SVN r41529]
2007-12-01 12:14:37 +00:00
Niels Dekker
33041ad664 Added tests for two more struct types to value_init_test -- discussed with Fernando Cacciola
[SVN r41436]
2007-11-28 17:19:37 +00:00
Niels Dekker
6a2aa822f8 Added value_init test for struct as used in MSVC bug report regarding value-initialization.
[SVN r41423]
2007-11-27 21:34:08 +00:00
Niels Dekker
09ab16bfc1 Checked the result of value_init test function, hoping to pinpoint exactly for what particular type T value_initialized<T> might fail, on some platforms
[SVN r41326]
2007-11-24 11:51:03 +00:00
Niels Dekker
ec46e40809 Code refactoring: removed private base classes of value_initialized, as suggested by Fernando Cacciola.
[SVN r41216]
2007-11-18 22:11:57 +00:00
Beman Dawes
b3a971e7e9 Copyright and/or License cleanup
[SVN r40890]
2007-11-07 16:08:09 +00:00
John Maddock
7ddb559887 Fix path to test case.
[SVN r40736]
2007-11-04 12:01:16 +00:00
Peter Dimov
ea8c99b1d5 Added a sentence with a brief explanation of the intended uses of BOOST_VERIFY.
[SVN r40731]
2007-11-03 22:47:17 +00:00
Peter Dimov
56b0846099 BOOST_VERIFY added.
[SVN r40728]
2007-11-03 20:55:22 +00:00
Niels Dekker
42e0001370 Added value_initialized<T> 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]
2007-10-16 17:06:39 +00:00
Niels Dekker
cd8f85afee 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]
2007-10-16 17:00:28 +00:00
Markus Schöpflin
bddd52c4b9 Fixed bug preventing compilation on Tru64/CXX.
[SVN r39918]
2007-10-11 07:36:41 +00:00
Niels Dekker
8f03aeac4e Added unit test to make sure that Visual C++ 7.1 ICE reported by Ralf W. Grosse-Kunstleve (Boost Developers mailing list, subject "utility/value_init.hpp: VC 7.1 ICE & workaround") will not occur anymore.
[SVN r39309]
2007-09-16 09:48:28 +00:00
Niels Dekker
3bb2568fad Visual C++ 7.1 ICE workaround by Ralf W. Grosse-Kunstleve added to ~const_T_base() as well. See also Boost Developers mailing list, subject "utility/value_init.hpp: VC 7.1 ICE & workaround"
[SVN r39308]
2007-09-16 09:33:34 +00:00
Ralf W. Grosse-Kunstleve
01e91a3799 work around Visual C++ 7.1 internal compiler error
[SVN r39302]
2007-09-15 23:11:50 +00:00
Niels Dekker
55f3c351a3 Added MSVC workaround to value_initialized, as described by ticket #1217, proposed at the Boost Developers mailing list, and discussed with Fernando Cacciola.
[SVN r39157]
2007-09-07 17:17:09 +00:00
Vladimir Prus
3f72b10182 Remove V1 Jamfiles
[SVN r38516]
2007-08-08 19:02:26 +00:00
Eric Niebler
71cb8cb574 broken msvc name look-up getting confused about which detail namespace
[SVN r38511]
2007-08-08 18:05:24 +00:00
Tobias Schwinger
c950825ef4 - overloads apply for array construction
- adds support for zero arguments
- lets apply return the result of the new-expression
- revises the preprocessing code


[SVN r38101]
2007-06-26 23:07:25 +00:00
Douglas Gregor
66ca84a45d Update result_of information
[SVN r38024]
2007-06-18 12:48:37 +00:00
Daniel Frey
06404f7d39 Improved empty_base
[SVN r37754]
2007-05-23 22:48:42 +00:00
Douglas Gregor
2d860e2574 Fix result_of's handling of F(void).
[SVN r37140]
2007-03-05 15:25:16 +00:00
Eric Niebler
66514f61ff fix result_of ambiguity error for nullary functions
[SVN r36773]
2007-01-24 06:44:20 +00:00
Eric Niebler
63cde4d3fd slightly modified implementation works around msvc 7.1/8.0 compiler bugs
[SVN r36668]
2007-01-08 20:38:51 +00:00
Daniel James
1950f292df Merge fixed links from RC_1_34_0.
[SVN r36660]
2007-01-07 23:50:56 +00:00
Andreas Huber
92a0602190 Fixed license & copyright issues and converted to HTML 4.01
[SVN r36280]
2006-12-05 21:11:21 +00:00
Peter Dimov
c9a3ab1d04 Linked to current_function.html
[SVN r36268]
2006-12-04 20:31:38 +00:00
Vladimir Prus
0782034333 Allow building of shared versions of some Boost.Test libraries.
Adjust tests to use always use static linking to Boost.Test, since
linking to the shared version requires test changes.

Patch from Juergen Hunold.


[SVN r35989]
2006-11-10 19:09:56 +00:00
Peter Dimov
0808883f3c License/copyright edits
[SVN r35958]
2006-11-09 20:34:33 +00:00
Beman Dawes
2f69501e55 Add copyright, license
[SVN r35905]
2006-11-07 19:11:57 +00:00
John Maddock
5b83f641a8 Removed unneeded semicolon.
[SVN r35636]
2006-10-16 18:01:40 +00:00
Dave Abrahams
c730ab4ffb Parameter library Workarounds for Borland and MSVC
Parameter library explicit markup for expected failures

value_init.hpp:
  Borland workarounds
  Use angle-includes consistently


[SVN r35084]
2006-09-13 03:00:18 +00:00
Fernando Cacciola
e55610a0d0 Some additional functions added to optional (being new there won't be regressions)
[SVN r34411]
2006-06-26 18:01:38 +00:00
Hartmut Kaiser
bf968794c9 Fixed an ambiguity.
[SVN r34403]
2006-06-26 01:58:38 +00:00
Peter Dimov
ce6e9c6698 Digital Mars support (Pavel Vozenilek)
[SVN r34373]
2006-06-22 12:47:19 +00:00
Dave Abrahams
7ac180ed54 Use forwarding to get SFINAE effect in some common use cases.
Rename detail::result_of to detail::result_of_impl to avoid surprises
when result_of is used from within boost::detail.


[SVN r33981]
2006-05-16 22:55:27 +00:00
19 changed files with 420 additions and 262 deletions

View File

@@ -1,6 +1,6 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -291,6 +291,6 @@ www.boost.org/LICENSE_1_0.txt</a>)</p>
<P>Developed by <A HREF="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</A>, <P>Developed by <A HREF="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</A>,
the latest version of this file can be found at <A the latest version of this file can be found at <A
HREF="http://www.boost.org">www.boost.org</A>, and the boost HREF="http://www.boost.org">www.boost.org</A>, and the boost
<A HREF="http://www.boost.org/more/mailing_lists.htm#main">discussion lists</A></P> <A HREF="http://www.boost.org/community/groups.html#main">discussion lists</A></P>
</BODY> </BODY>
</HTML> </HTML>

View File

@@ -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 <boost/exception/info_tuple.hpp>
#include <boost/exception_ptr.hpp>
#include <boost/throw_exception.hpp>
#endif

View File

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

View File

@@ -1,6 +1,7 @@
// Copyright (C) 2002 Brad King (brad.king@kitware.com) // Copyright (C) 2002 Brad King (brad.king@kitware.com)
// Douglas Gregor (gregod@cs.rpi.edu) // Douglas Gregor (gregod@cs.rpi.edu)
// Peter Dimov //
// Copyright (C) 2002, 2008 Peter Dimov
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -14,27 +15,31 @@
# include <boost/config.hpp> # include <boost/config.hpp>
# include <boost/detail/workaround.hpp> # include <boost/detail/workaround.hpp>
namespace boost { namespace boost
// Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov)
// VC7 strips const from nested classes unless we add indirection here
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
template<class T> struct _addp
{ {
typedef T * type;
namespace detail
{
template<class T> struct addressof_impl
{
static inline T * f( T & v, long )
{
return reinterpret_cast<T*>(
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
}
static inline T * f( T * v, int )
{
return v;
}
}; };
template <typename T> typename _addp<T>::type
# else } // namespace detail
template <typename T> T*
# endif template<class T> T * addressof( T & v )
addressof(T& v)
{ {
return reinterpret_cast<T*>( return boost::detail::addressof_impl<T>::f( v, 0 );
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
} }
// Borland doesn't like casting an array reference to a char reference // Borland doesn't like casting an array reference to a char reference
@@ -53,6 +58,6 @@ const T (*addressof(const T (&t)[N]))[N]
} }
# endif # endif
} } // namespace boost
#endif // BOOST_UTILITY_ADDRESSOF_HPP #endif // BOOST_UTILITY_ADDRESSOF_HPP

View File

@@ -1,6 +1,6 @@
// Boost enable_if library // Boost enable_if library
// Copyright 2003 <EFBFBD> The Trustees of Indiana University. // Copyright 2003 (c) The Trustees of Indiana University.
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@@ -10,9 +10,10 @@
#define BOOST_RESULT_OF_HPP #define BOOST_RESULT_OF_HPP
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/type_traits/ice.hpp> #include <boost/preprocessor/iteration/iterate.hpp>
#include <boost/type.hpp> #include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor.hpp> #include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
#include <boost/mpl/has_xxx.hpp> #include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/if.hpp> #include <boost/mpl/if.hpp>

View File

@@ -1,34 +1,24 @@
// (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 // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
// 21 Ago 2002 (Created) Fernando Cacciola // 21 Ago 2002 (Created) Fernando Cacciola
// 24 Dec 2007 (Refactored and worked around various compiler bugs) 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 #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
#define 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 // Note: The implementation of boost::value_initialized had to deal with the
// fact that various compilers haven't fully implemented value-initialization: // fact that various compilers haven't fully implemented value-initialization.
// Microsoft Feedback ID 100744 - Value-initialization in new-expression // The constructor of boost::value_initialized<T> works around these compiler
// Reported by Pavel Kuznetsov (MetaCommunications Engineering), 2005-07-28 // issues, by clearing the bytes of T, before constructing the T object it
// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744 // contains. More details on these issues are at libs/utility/value_init.htm
// 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<T> works around these issues, by
// clearing the bytes of T, before constructing the T object it contains.
#include <boost/aligned_storage.hpp> #include <boost/aligned_storage.hpp>
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/cv_traits.hpp> #include <boost/type_traits/cv_traits.hpp>
#include <boost/type_traits/alignment_of.hpp> #include <boost/type_traits/alignment_of.hpp>
#include <cstring> #include <cstring>
@@ -48,23 +38,32 @@ class value_initialized
remove_const<T>::type data; remove_const<T>::type data;
}; };
mutable aligned_storage<sizeof(wrapper), alignment_of<wrapper>::value> x; mutable
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
typename
#endif
aligned_storage<sizeof(wrapper), alignment_of<wrapper>::value>::type x;
wrapper * wrapper_address() const
{
return static_cast<wrapper *>( static_cast<void*>(&x));
}
public : public :
value_initialized() value_initialized()
{ {
std::memset(x.address(), 0, sizeof(x)); std::memset(&x, 0, sizeof(x));
#ifdef BOOST_MSVC #ifdef BOOST_MSVC
#pragma warning(push) #pragma warning(push)
#if _MSC_VER >= 1310 #if _MSC_VER >= 1310
// When using MSVC 7.1 or higher, the following placement new expression may trigger warning C4345: // 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 () // "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) #pragma warning(disable: 4345)
#endif #endif
#endif #endif
new (x.address()) wrapper(); new (wrapper_address()) wrapper();
#ifdef BOOST_MSVC #ifdef BOOST_MSVC
#pragma warning(pop) #pragma warning(pop)
#endif #endif
@@ -72,25 +71,25 @@ class value_initialized
value_initialized(value_initialized const & arg) value_initialized(value_initialized const & arg)
{ {
new (x.address()) wrapper( *static_cast<wrapper const *>(arg.x.address()) ); new (wrapper_address()) wrapper( static_cast<wrapper const &>(*(arg.wrapper_address())));
} }
value_initialized & operator=(value_initialized const & arg) value_initialized & operator=(value_initialized const & arg)
{ {
T & this_data = this->data(); // Assignment is only allowed when T is non-const.
T const & arg_data = arg.data(); BOOST_STATIC_ASSERT( ! is_const<T>::value );
this_data = arg_data; *wrapper_address() = static_cast<wrapper const &>(*(arg.wrapper_address()));
return *this; return *this;
} }
~value_initialized() ~value_initialized()
{ {
static_cast<wrapper *>(x.address())->wrapper::~wrapper(); wrapper_address()->wrapper::~wrapper();
} }
T& data() const T& data() const
{ {
return static_cast<wrapper *>(x.address())->data; return wrapper_address()->data;
} }
operator T&() const { return this->data(); } operator T&() const { return this->data(); }
@@ -110,6 +109,18 @@ T& get ( value_initialized<T>& x )
return x.data() ; return x.data() ;
} }
class initialized_value
{
public :
template <class T> operator T() const
{
return get( value_initialized<T>() );
}
};
} // namespace boost } // namespace boost

View File

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

View File

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

View File

@@ -32,7 +32,8 @@
</dl> </dl>
<ul> <ul>
<li><a href="#val_init"><code>value_initialized&lt;T&gt;</code></a></li> <li><a href="#val_init"><code>template class value_initialized&lt;T&gt;</code></a></li>
<li><a href="#initialized_value"><code>class initialized_value</code></a></li>
</ul> </ul>
<a href="#acknowledgements">Acknowledgements</a><br> <a href="#acknowledgements">Acknowledgements</a><br>
@@ -52,6 +53,9 @@ union and class types.
Moreover, <code>value_initialized</code> offers a workaround to various Moreover, <code>value_initialized</code> offers a workaround to various
compiler issues regarding value-initialization. compiler issues regarding value-initialization.
Furthermore a convenience class, <code>initialized_value</code> is provided,
to avoid repeating the type name when retrieving the value from a
<code>value_initialized&lt;T&gt;</code> object.
<br> <br>
</p> </p>
@@ -117,6 +121,16 @@ constructed by the following declaration:
<pre> <pre>
value_initialized&lt;T&gt; var; value_initialized&lt;T&gt; var;
</pre> </pre>
</p>
<p>
The convenience class <a href="#initialized_value"><code>initialized_value</code></a>
allows value-initializing a variable as follows:
<pre>
T var = initialized_value();
</pre>
This form of initialization is also very similar to <code>T4 var4 = T4()</code>,
but robust against the aforementioned compiler issues.
</p> </p>
<h2><a name="details"></a>Details</h2> <h2><a name="details"></a>Details</h2>
@@ -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 <code>get()</code> idiom:</p> the wrapped object is always performed with the <code>get()</code> idiom:</p>
<pre>value_initialized&lt;int&gt; x ;<br>get(x) = 1 ; // OK<br><br>value_initialized&lt;int const&gt; cx ;<br>get(x) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized&lt;int&gt; const x_c ;<br>get(x_c) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized&lt;int const&gt; const cx_c ;<br>get(cx_c) = 1 ; // ERROR: Cannot modify a const object<br></pre> <pre>value_initialized&lt;int&gt; x ;<br>get(x) = 1 ; // OK<br><br>value_initialized&lt;int const&gt; cx ;<br>get(x) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized&lt;int&gt; const x_c ;<br>get(x_c) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized&lt;int const&gt; const cx_c ;<br>get(cx_c) = 1 ; // ERROR: Cannot modify a const object<br></pre>
<h2><a name="initialized_value"><code>class initialized_value</code></a></h2>
<pre>
namespace boost {
class initialized_value
{
public :
template &lt;class T&gt; operator T() const ;
};
} // namespace boost
</pre>
The class <code>initialized_value</code> provides a convenient way to get
an initialized value: its conversion operator provides an appropriate
<em>value-initialized</em> object for any CopyConstructible type.
Suppose you need to have an initialized variable of type <code>T</code>.
You could do it as follows:
<pre>
T var = T();
</pre>
But as mentioned before, this form suffers from various compiler issues.
The template <code>value_initialized</code> offers a workaround:
<pre>
T var = get( value_initialized&lt;T&gt;() );
</pre>
Unfortunately both forms repeat the type name, which
is rather short now (<code>T</code>), but could of course be
more like <code>Namespace::Template&lt;Arg&gt;::Type</code>.
Instead, one could use <code>initialized_value</code> as follows:
<pre>
T var = initialized_value();
</pre>
<h3><a name="references">References</a></h3> <h3><a name="references">References</a></h3>
[1] Bjarne Stroustrup, Gabriel Dos Reis, and J. Stephen Adamczyk wrote [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
</p> </p>
<hr> <hr>
<p>Revised 15 January 2008</p> <p>Revised 16 January 2008</p>
<p>&copy; Copyright Fernando Cacciola, 2002, 2008.</p> <p>&copy; Copyright Fernando Cacciola, 2002, 2008.</p>

View File

@@ -6,8 +6,8 @@
// //
// Test program for "boost/utility/value_init.hpp" // Test program for "boost/utility/value_init.hpp"
// //
// 21 Agu 2002 (Created) Fernando Cacciola // 21 Ago 2002 (Created) Fernando Cacciola
// 15 Jan 2008 (Added tests regarding compiler issues) Fernando Cacciola, Niels Dekker // 18 Feb 2008 (Added tests regarding compiler issues and initialized_value) Fernando Cacciola, Niels Dekker
#include <cstring> // For memcmp. #include <cstring> // For memcmp.
#include <iostream> #include <iostream>
@@ -52,7 +52,7 @@ struct NonPODBase
struct NonPOD : NonPODBase struct NonPOD : NonPODBase
{ {
NonPOD () : id() {} 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 ) friend std::ostream& operator << ( std::ostream& os, NonPOD const& npod )
{ return os << '(' << npod.id << ')' ; } { return os << '(' << npod.id << ')' ; }
@@ -180,6 +180,32 @@ struct CopyFunctionCallTester
}; };
template<class T>
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<T> for a specific type T. // This test function tests boost::value_initialized<T> for a specific type T.
// The first argument (y) is assumed have the value of a value-initialized object. // The first argument (y) is assumed have the value of a value-initialized object.
@@ -189,9 +215,13 @@ template<class T>
bool 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(); const boost::unit_test::counter_t counter_before_test = boost::minimal_test::errors_counter();
check_initialized_value(y);
boost::value_initialized<T> x ; boost::value_initialized<T> x ;
BOOST_CHECK ( y == x ) ; BOOST_CHECK ( y == x ) ;
BOOST_CHECK ( y == boost::get(x) ) ; BOOST_CHECK ( y == boost::get(x) ) ;
static_cast<T&>(x) = z ; static_cast<T&>(x) = z ;
boost::get(x) = z ; boost::get(x) = z ;
BOOST_CHECK ( x == z ) ; BOOST_CHECK ( x == z ) ;
@@ -275,6 +305,10 @@ int test_main(int, char **)
boost::value_initialized<ArrayOfBytes> valueInitializedArrayOfBytes; boost::value_initialized<ArrayOfBytes> valueInitializedArrayOfBytes;
BOOST_CHECK (std::memcmp(get(valueInitializedArrayOfBytes), zeroInitializedArrayOfBytes, sizeof(ArrayOfBytes)) == 0); BOOST_CHECK (std::memcmp(get(valueInitializedArrayOfBytes), zeroInitializedArrayOfBytes, sizeof(ArrayOfBytes)) == 0);
boost::value_initialized<ArrayOfBytes> valueInitializedArrayOfBytes2;
valueInitializedArrayOfBytes2 = valueInitializedArrayOfBytes;
BOOST_CHECK (std::memcmp(get(valueInitializedArrayOfBytes), get(valueInitializedArrayOfBytes2), sizeof(ArrayOfBytes)) == 0);
boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester1; boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester1;
BOOST_CHECK ( ! get(copyFunctionCallTester1).is_copy_constructed); BOOST_CHECK ( ! get(copyFunctionCallTester1).is_copy_constructed);
BOOST_CHECK ( ! get(copyFunctionCallTester1).is_assignment_called); BOOST_CHECK ( ! get(copyFunctionCallTester1).is_assignment_called);