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

时间:2017-08-01 20:39:24

标签: c++ boost shared-ptr smart-pointers c++17

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

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

我想知道为什么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

0 个答案:

没有答案