智能指针shared_ptr<T>
2018-03-09 21:12
190 查看
shared_ptr<T>中有两个成员变量T* p 和 shared_count pn,
pn中有个成员指针sp_count_base* pi_,
“包装”同一指针T*的shared_ptr对象的shared_count成员pn的sp_count_base* pi_指向同一对象。即sp_counted_impl_p对象。sp_counted_impl_p对象中有个成员变量use_count_用于计数。
详细代码见C++的boost库。
pn中有个成员指针sp_count_base* pi_,
“包装”同一指针T*的shared_ptr对象的shared_count成员pn的sp_count_base* pi_指向同一对象。即sp_counted_impl_p对象。sp_counted_impl_p对象中有个成员变量use_count_用于计数。
详细代码见C++的boost库。
相关文章推荐
- 从零开始学C++之boost库(一):详解 boost 库智能指针(scoped_ptr<T> 、shared_ptr<T> 、weak_ptr<T> 源码分析)
- 详解 boost 库智能指针(scoped_ptr<T> 、shared_ptr<T> 、weak_ptr<T> 源码分析)
- [置顶] 从零开始学C++之boost库(一):详解 boost 库智能指针(scoped_ptr<T> 、shared_ptr<T> 、weak_ptr<T> 源码分析)
- C++智能指针(scoped_ptr<T> 、shared_ptr<T> 、weak_ptr<T> )
- [置顶] 从零开始学C++之boost库(一):详解 boost 库智能指针(scoped_ptr<T> 、shared_ptr<T> 、weak_ptr<T> 源码分析)
- 详解 boost 库智能指针(scoped_ptr<T> 、shared_ptr<T> 、weak_ptr<T> 源码分析)
- C/C++:智能指针原理(运算符重载)、使用auto_ptr<A>
- weak_ptr<T>智能指针
- 智能指针里弱引用应该如何实现?(WeakReference/WeakPtr<T>)
- 一个类似auto_ptr<>用于动态分配数组的智能指针
- 仿shared_ptr的二维智能数组指针TwoDimesionArray<T>
- C++ 11智能指针之shared_ptr
- Hat’s Words (字典树 + 智能指针shared_ptr)
- 【C++】智能指针的作用,模拟实现auto_ptr,scoped_ptr,shared_ptr,scoped_array,shared_array
- 智能指针(二):shared_ptr实现原理
- C++11 FAQ中文版:共享资源的智能指针——shared_ptr
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- 【C++】智能指针shared_ptr 定位删除器(仿函数)
- C++:智能指针之shared_ptr
- 智能指针auto_ptr & shared_ptr