|
Boost-Commit : |
From: nielsdekker_at_[hidden]
Date: 2008-05-23 12:48:11
Author: niels_dekker
Date: 2008-05-23 12:48:10 EDT (Fri, 23 May 2008)
New Revision: 45686
URL: http://svn.boost.org/trac/boost/changeset/45686
Log:
Fixed value_init test + doc, according to change of boost::initialized_value, revision [45685]
Text files modified:
trunk/libs/utility/value_init.htm | 29 +++++++++++++++++------------
trunk/libs/utility/value_init_test.cpp | 5 +++--
2 files changed, 20 insertions(+), 14 deletions(-)
Modified: trunk/libs/utility/value_init.htm
==============================================================================
--- trunk/libs/utility/value_init.htm (original)
+++ trunk/libs/utility/value_init.htm 2008-05-23 12:48:10 EDT (Fri, 23 May 2008)
@@ -28,12 +28,12 @@
</ul>
<dl class="page-index">
- <dt>Types</dt>
+ <dt>Types and objects</dt>
</dl>
<ul>
<li>template class value_initialized<T>
</li>
- <li>class initialized_value
</li>
+ <li>initialized_value
</li>
</ul>
<a href="#acknowledgements">Acknowledgements</a><br>
@@ -53,7 +53,7 @@
Moreover, <code>value_initialized</code> offers a workaround to various
compiler issues regarding value-initialization.
-Furthermore a convenience class, <code>initialized_value</code> is provided,
+Furthermore, a <code>const</code> object, <code>initialized_value</code> is provided,
to avoid repeating the type name when retrieving the value from a
<code>value_initialized<T></code> object.
<br>
@@ -123,12 +123,12 @@
</pre>
</p>
<p>
-The convenience class initialized_value
+The <code>const</code> object initialized_value
allows value-initializing a variable as follows:
<pre>
- T var = initialized_value();
+ T var = initialized_value ;
</pre>
-This form of initialization is also very similar to <code>T4 var4 = T4()</code>,
+This form of initialization is semantically equivalent to <code>T4 var4 = T4()</code>,
but robust against the aforementioned compiler issues.
</p>
@@ -249,7 +249,7 @@
its internal data, prior to constructing the object that it contains.
</p>
-<h2><a name="types"></a>Types</h2>
+<h2><a name="types"></a>Types and objects</h2>
<h2><a name="val_init"><code>template class value_initialized<T></code></a></h2>
@@ -312,19 +312,22 @@
<pre>value_initialized<int> x ;<br>get(x) = 1 ; // OK<br><br>value_initialized<int const> cx ;<br>get(x) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized<int> const x_c ;<br>get(x_c) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized<int const> 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>
+<h2><a name="initialized_value"><code>initialized_value</code></a></h2>
<pre>
namespace boost {
-class initialized_value
+class initialized_value_t
{
public :
template <class T> operator T() const ;
};
+
+initialized_value_t const initialized_value = {} ;
+
} // namespace boost
</pre>
-The class <code>initialized_value</code> provides a convenient way to get
+<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.
@@ -343,7 +346,7 @@
more like <code>Namespace::Template<Arg>::Type</code>.
Instead, one could use <code>initialized_value</code> as follows:
<pre>
- T var = initialized_value();
+ T var = initialized_value ;
</pre>
<h3><a name="references">References</a></h3>
@@ -368,13 +371,15 @@
<p>value_initialized was reimplemented by Fernando Cacciola and Niels Dekker
for Boost release version 1.35 (2008), offering a workaround to various compiler issues.
</p>
+<p>initialized_value was written by Niels Dekker, and added to Boost release version 1.36 (2008).
+ </p>
<p>Developed by <a href="mailto:fernando_cacciola_at_[hidden]">Fernando Cacciola</a>,
the latest version of this file can be found at <a
href="http://www.boost.org">www.boost.org</a>.
</p>
<hr>
-<p>Revised 16 January 2008</p>
+<p>Revised 23 May 2008</p>
<p>© Copyright Fernando Cacciola, 2002, 2008.</p>
Modified: trunk/libs/utility/value_init_test.cpp
==============================================================================
--- trunk/libs/utility/value_init_test.cpp (original)
+++ trunk/libs/utility/value_init_test.cpp 2008-05-23 12:48:10 EDT (Fri, 23 May 2008)
@@ -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 <cstring> // For memcmp.
#include <iostream>
@@ -183,7 +184,7 @@
template<class T>
void check_initialized_value ( T const& y )
{
- T initializedValue = boost::initialized_value() ;
+ T initializedValue = boost::initialized_value ;
BOOST_CHECK ( y == initializedValue ) ;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk