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 @@
Acknowledgementsvalue_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:
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
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 value_initialized was reimplemented by Fernando Cacciola and Niels Dekker for Boost release version 1.35 (2008), offering a workaround to various compiler issues.