Does
std::make_unique<double[]>(1000)
始终对元素进行值初始化?我查看了实现,
clang
和g++
都在使用。new T[size]()
进行值初始化。
但我无法找到符合C++14 / 17标准的实现必须这样做的规定。
new T[size]
)。参考C++14 §20.8.1.4 [unique.ptr.create]/4:
template <class T> unique_ptr<T> make_unique(size_t n);
- 返回:
unique_ptr<T>(new remove_extent_t<T>[n]())
。