细分shared_ptr智能指针在各个版本的使用情况

#include <memory>
#include <iostream>

class A
{
public:
    A(int value) :value_(value)
    {

    }
private:
    int value_;
};
int main()
{
    //c++17之前语法
    std::shared_ptr<int> shared_good(new int[10],std::default_delete<int[]>());
    std::shared_ptr<int[]> sp3(new int[10]()); //c++17语法

    //auto ptr_arry = std::make_shared<A[]>(10,1);//c++20语法
    int value = 10;
}

猜你喜欢

转载自blog.csdn.net/qq_53332653/article/details/115124048