std::make_shared 和 std::shared_ptr 有什么区别和联系?
时间: 2023-11-09 16:16:21 浏览: 96
std::make_shared 和 std::shared_ptr 是 C++ 中的两个关联的概念,它们都与管理动态分配的内存有关。
std::make_shared 是一个函数模板,它用<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [条款20:当std::shared_ptr可能悬空时使用std::weak_ptr](https://blog.csdn.net/u012069234/article/details/129642658)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [linux C++共享指针(std::shared_ptr、std::make_shared)共享对象,reset()重置共享指针,use_count()查看...](https://blog.csdn.net/Dontla/article/details/129027429)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文