|
| | shared_ptr (nullptr_t np=nullptr) noexcept |
| | 默认构造函数
|
| template<typename U, enable_if_t< is_convertible_v< U *, T * >, int > = 0> |
| | shared_ptr (U *ptr) |
| | 从原始指针构造函数
|
| template<typename U, typename Deleter, enable_if_t< is_convertible_v< U *, T * >, int > = 0> |
| | shared_ptr (U *ptr, Deleter &&deleter) |
| | 从原始指针和自定义删除器构造函数
|
| template<typename U, typename Deleter, enable_if_t< is_convertible_v< U *, T * >, int > = 0> |
| | shared_ptr (unique_ptr< U, Deleter > &&ptr) |
| | 独享智能指针构造函数
|
| | shared_ptr (const shared_ptr &x) noexcept |
| | 拷贝构造函数
|
| shared_ptr & | operator= (const shared_ptr &x) noexcept |
| | 拷贝赋值运算符
|
| template<typename U, enable_if_t< is_convertible_v< U *, T * >, int > = 0> |
| | shared_ptr (const shared_ptr< U > &x) noexcept |
| | 类型转换拷贝构造函数
|
| | shared_ptr (shared_ptr &&x) noexcept |
| | 移动构造函数
|
| shared_ptr & | operator= (shared_ptr &&x) noexcept |
| | 移动赋值运算符
|
| template<typename U, enable_if_t< is_convertible_v< U *, T * >, int > = 0> |
| | shared_ptr (shared_ptr< U > &&x) noexcept |
| | 类型转换移动构造函数
|
| template<typename U> |
| | shared_ptr (const shared_ptr< U > &x, T *ptr) noexcept |
| | 从共享指针和别名指针别名构造函数
|
|
template<typename U> |
| | shared_ptr (shared_ptr< U > &&x, T *ptr) noexcept |
| | 移动别名构造函数
|
|
template<typename U, enable_if_t< is_convertible_v< U *, T * >, int > = 0> |
| shared_ptr & | operator= (const shared_ptr< U > &x) noexcept |
| | 类型转换拷贝赋值运算符
|
|
template<typename U, enable_if_t< is_convertible_v< U *, T * >, int > = 0> |
| shared_ptr & | operator= (shared_ptr< U > &&x) noexcept |
| | 类型转换移动赋值运算符
|
| | ~shared_ptr () noexcept |
| | 析构函数
|
|
void | reset () noexcept |
| | 重置共享指针
|
| template<typename U> |
| void | reset (U *ptr) |
| | 重置共享指针并管理新对象
|
| template<typename U, typename Deleter> |
| void | reset (U *ptr, Deleter deleter) |
| | 带自定义删除器重置共享指针并管理新对象
|
| MSTL_NODISCARD long | use_count () const noexcept |
| | 获取引用计数
|
| MSTL_NODISCARD bool | unique () const noexcept |
| | 检查是否独占所有权
|
| void | swap (shared_ptr &x) noexcept |
| | 交换两个共享指针
|
| MSTL_NODISCARD T * | get () const noexcept |
| | 获取原始指针
|
| MSTL_NODISCARD T * | operator-> () const noexcept |
| | 指针解引用运算符
|
| MSTL_NODISCARD add_lvalue_reference_t< T > | operator* () const noexcept |
| | 解引用运算符
|
| MSTL_NODISCARD | operator bool () const noexcept |
| | 布尔转换运算符
|
| template<typename U> |
| MSTL_NODISCARD bool | owner_equal (const shared_ptr< U > &rhs) const noexcept |
| | 检查所有权是否相等
|
|
template<typename U> |
| MSTL_NODISCARD bool | owner_equal (const weak_ptr< U > &rhs) const noexcept |
| | 与弱指针检查所有权是否相等
|
| template<typename U> |
| MSTL_NODISCARD bool | owner_before (const shared_ptr< U > &rhs) const noexcept |
| | 比较所有权顺序
|
|
template<typename U> |
| MSTL_NODISCARD bool | owner_before (const weak_ptr< U > &rhs) const noexcept |
| | 与弱指针比较所有权顺序
|
template<typename T>
class shared_ptr< T >
共享智能指针类模板
- 模板参数
-
实现引用计数的智能指针,多个实例可以共享同一对象的所有权。 当最后一个共享智能指针被销毁时,对象会被自动删除。
在文件 shared_ptr.hpp 第 272 行定义.