|
Boost-Commit : |
From: nielsdekker_at_[hidden]
Date: 2008-01-14 16:46:20
Author: niels_dekker
Date: 2008-01-14 16:46:20 EST (Mon, 14 Jan 2008)
New Revision: 42779
URL: http://svn.boost.org/trac/boost/changeset/42779
Log:
Minor "beautifications" of value_init documentation, inc. placing references in order of appearance
Text files modified:
trunk/libs/utility/value_init.htm | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
Modified: trunk/libs/utility/value_init.htm
==============================================================================
--- trunk/libs/utility/value_init.htm (original)
+++ trunk/libs/utility/value_init.htm 2008-01-14 16:46:20 EST (Mon, 14 Jan 2008)
@@ -32,7 +32,7 @@
</dl>
<ul>
- <li>value_initialized<>
</li>
+ <li>value_initialized<T>
</li>
</ul>
<a href="#acknowledgements">Acknowledgements</a><br>
@@ -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. <code>value_initialized</code> provides
+this problem must be addressed. The template <code>value_initialized</code> provides
a solution with consistent syntax for value initialization of scalar,
union and class types.
Moreover, <code>value_initialized</code> offers a workaround to various
@@ -84,7 +84,7 @@
initializes an aggregate, typically a "C-style" <code>struct</code> 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, <code>T4 var4 = T4()</code>, should be read
@@ -98,7 +98,7 @@
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.
</p>
<p>
There is another, less obvious disadvantage to the fourth form, <code>T4 var4 = T4()</code>:
@@ -120,11 +120,11 @@
</p>
<h2><a name="details"></a>Details</h2>
-<p>The C++ standard [1] contains the definitions
+<p>The C++ standard [3] contains the definitions
of <code>zero-initialization</code> and <code>default-initialization</code>.
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
<i>declaration</i> can contain an <i>initializer</i>, which specifies the
object's initial value. The initializer can be just '()', which states that
@@ -225,7 +225,7 @@
<br>
<a href="http://qc.codegear.com/wc/qcmain.aspx?d=51854">
Borland Report 51854 - Value-initialization: POD struct should be zero-initialized</a>
-<br>Reported by Niels Dekker (LKEB, Leiden University Medical Center), 2007-11-09
+<br>Reported by Niels Dekker (LKEB, Leiden University Medical Center), 2007-09-11
<br>
</td></tr></table>
</p><p>
@@ -299,23 +299,23 @@
<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>
<h3><a name="references">References</a></h3>
- [1] The C++ Standard, Second edition (2003), ISO/IEC 14882:2003 <br>
- [2] POD stands for "Plain Old Data" <br>
- [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 <em>initializer lists</em>
in the next version of C++.
This would allow a variable <code>var</code> of any DefaultConstructible type
<code>T</code> to be <em>value-initialized</em> by doing <code>T var = {}</code>.
The papers are listed at Bjarne's web page,
<a href="http://www.research.att.com/~bs/WG21.html">My C++ Standards committee papers</a> <br>
- [4] Scott Meyers, Effective C++, Third Edition, item 6,
+ [2] Scott Meyers, Effective C++, Third Edition, item 6,
<em>Explicitly disallow the use of compiler-generated functions you do not want</em>,
- Scott Meyers: Books and CDs
+ Scott Meyers: Books and CDs <br>
+ [3] The C++ Standard, Second edition (2003), ISO/IEC 14882:2003 <br>
+ [4] POD stands for "Plain Old Data"
<h3><a name="acknowledgements"></a>Acknowledgements</h3>
value_initialized was developed by Fernando Cacciola, with help and
suggestions from David Abrahams and Darin Adler.<br>
-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.
<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.
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