new int[100]
performs default initialization, all the elements would be initialized to indeterminate values. Note that reading from them leads to UB, anything is possible.
- otherwise, nothing is done: the objects with automatic storage duration (and their subobjects) are initialized to indeterminate values.
new int[100]()
performs value initialization, as the effect all the elements would be zero-initialized to 0
.
3) if T
is an array type, each element of the array is value-initialized;
4) otherwise, the object is zero-initialized.
EDIT
std::make_unique
takes the 2nd way for initializing.
2) Constructs an array of unknown bound T
. This overload only
participates in overload resolution if T
is an array of unknown bound.
The function is equivalent to:
unique_ptr<T>(new typename std::remove_extent<T>::type[size]())
PS: std::make_unique_for_overwrite
takes the 1st way.
5) Same as (2), except that the array is default-initialized. This
overload only participates in overload resolution if T
is an array of
unknown bound. The function is equivalent to:
unique_ptr<T>(new typename std::remove_extent<T>::type[size])