From 67f3ca090aeea6fae4b41aa06c4838e4dca5e131 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Fri, 23 May 2008 16:48:10 +0000 Subject: [PATCH] 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 ) ; }