为什么C++ 17不提供make_shared <T []>而C++ 17 shared_ptr提供operator []?

san*_*orn 7 c++ boost smart-pointers shared-ptr c++17

尽管如此,人们可以通过提升获得好处.

#include "boost/smart_ptr/make_shared_array.hpp"
auto int_arr_ptr = boost::make_shared<int[]>(100);
Run Code Online (Sandbox Code Playgroud)

我想知道为什么C++ 17标准不提供std::make_shared<T[]>它提供的shared_ptr::operator[]


std::shared_ptr::operator[] http://en.cppreference.com/w/cpp/memory/shared_ptr/operator_at

std::make_shared http://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared

  • std::shared_ptr支持数组类型(从C++ 17开始),但std::make_shared不支持.支持此功能boost::make_shared

allocate_sharedmake_shared数组
http://www.boost.org/doc/libs/release/libs/smart_ptr/make_shared_array.html