@ForEveR
В астрале
7991 / 4750 / 321
Регистрация: 24.06.2010
Сообщений: 10,547
|
26.04.2013, 09:46
|
|
vxg, Вот цитата из стандарта. Если проследить путь - получается ровно то же, что и в ответе на SO.
A new-expression that creates an object of type T initializes that object as follows:
— If the new-initializer is omitted, the object is default-initialized (8.5); if no initialization is performed,
the object has indeterminate value.
— Otherwise, the new-initializer is interpreted according to the initialization rules of 8.5 for direct-
initialization.
To default-initialize an object of type T means:
— if T is a (possibly cv-qualified) class type (Clause 9), the default constructor for T is called (and the
initialization is ill-formed if T has no accessible default constructor);
— if T is an array type, each element is default-initialized;
— otherwise, no initialization is performed.
The initialization that occurs in the forms
T x(a);
T x{a};
is called direct-initialization.
— If the initializer is (), the object is value-initialized.
To value-initialize an object of type T means:
— if T is a (possibly cv-qualified) class type (Clause 9) with either no default constructor (12.1) or a
default constructor that is user-provided or deleted, then the object is default-initialized;
— if T is a (possibly cv-qualified) non-union class type without a user-provided or deleted default construc-
tor, then the object is zero-initialized and, if T has a non-trivial default constructor, default-initialized;
— if T is an array type, then each element is value-initialized;
— otherwise, the object is zero-initialized.
To zero-initialize an object or reference of type T means:
— if T is a scalar type (3.9), the object is set to the value 0 (zero), taken as an integral constant expression,
converted to T;103
— if T is a (possibly cv-qualified) non-union class type, each non-static data member and each base-class
subobject is zero-initialized and padding is initialized to zero bits;
— if T is a (possibly cv-qualified) union type, the object’s first non-static named data member is zero-
initialized and padding is initialized to zero bits;
— if T is an array type, each element is zero-initialized;
— if T is a reference type, no initialization is performed.
1
|