相关疑难解决方法(0)

std::make_unique_for_overwrite() 相对于 std::make_unique() 做什么?

似乎在 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);
Run Code Online (Sandbox Code Playgroud)

std::make_sharedwith 一样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);
Run Code Online (Sandbox Code Playgroud)

足够的?现有的不使用对象的默认构造函数吗?

注意:在这些函数的早​​期提案中,名称是make_unique_default_init().

c++ smart-pointers c++20

10
推荐指数
2
解决办法
1537
查看次数

标签 统计

c++ ×1

c++20 ×1

smart-pointers ×1