【发布时间】:2020-01-22 20:10:55
【问题描述】:
似乎在 C++20 中,我们获得了一些额外的智能指针实用功能,包括:
template<class T> unique_ptr<T> make_unique_for_overwrite();
template<class T> unique_ptr<T> make_unique_for_overwrite(size_t n);
std::make_shared 和 std::shared_ptr 也是如此。为什么不是现有功能:
template<class T, class... Args> unique_ptr<T> make_unique(Args&&... args); // with empty Args
template<class T> unique_ptr<T> make_unique(size_t n);
够了吗?现有的不使用对象的默认构造函数吗?
注意:在这些函数的早期提案中,名称为make_unique_default_init()。
【问题讨论】:
标签: c++ smart-pointers c++20