本文首发于个人博客https://kezunlin.me/post/b82753fc/,欢迎阅读最新内容! 5 methods for c++ shared_ptr point to an array Guide shared_ptr Prior to C++17, shared_ptr could not be used to manage dynamically allocated arrays. By default, shared_ptr will call delete on the
Q: 那个auto_ptr是什么东东啊?为什么没有auto_array?A: 哦,auto_ptr是一个很简单的资源封装类,是在<memory>头文件中定义的.它使用“资源分配即初始化”技术来保证资源在发生异常时也能被安全释放(“exception safety”).一个auto_ptr封装了一个指针,也可以被当作指针来使用.当其生命周期到了尽头,auto_ptr会自动释放指针.例如: #include<memory> using namespace std; struct X