命名空间
变体
操作

std::experimental::shared_ptr

来自 cppreference.cn
< cpp‎ | 实验性
 
 
实验性
技术规范
文件系统库 (文件系统 TS)
库基础 (库基础 TS)
库基础 2 (库基础 TS v2)
库基础 3 (库基础 TS v3)
并行性扩展 (并行性 TS)
并行性扩展 2 (并行性 TS v2)
并发性扩展 (并发性 TS)
并发扩展 2 (并发 TS v2)
概念 (概念 TS)
范围 (范围 TS)
反射 (反射 TS)
数学特殊函数 (特殊函数 TR)
实验性非 TS
模式匹配
线性代数
std::execution
契约
2D 图形
 
 
 
定义于头文件 <experimental/memory>
template< class T > class shared_ptr;
(库基础 TS)

std::experimental::shared_ptrstd::shared_ptr 的修改版本,增加了对数组的支持。

目录

[编辑] 成员类型

成员类型 定义
element_type std::remove_extent_t<T>

[编辑] 成员函数

构造新的 shared_ptr
(公共成员函数) [编辑]
观察器
返回存储的指针
(公共成员函数) [编辑]
解引用存储的指针
(公共成员函数) [编辑]
提供对数组的索引访问
(公共成员函数) [编辑]

[编辑] 非成员函数

对存储的指针应用 static_castdynamic_castconst_castreinterpret_cast
(函数模板) [编辑]

[编辑] 辅助类

std::experimental::shared_ptr 的哈希支持
(类模板特化) [编辑]

成员和非成员与 std::shared_ptr 相同

成员函数

以下成员函数使用 std::experimental::shared_ptr 而非 std::shared_ptr,使用 std::experimental::weak_ptr 而非 std::weak_ptr。其行为在其他方面相同。

如果没有更多的 shared_ptr 链接到它,则销毁所拥有的对象。
(std::shared_ptr<T> 的公共成员函数) [编辑]
赋值 shared_ptr
(std::shared_ptr<T> 的公共成员函数) [编辑]
修改器
替换托管对象
(std::shared_ptr<T> 的公共成员函数) [编辑]
交换管理对象
(std::shared_ptr<T> 的公共成员函数) [编辑]
观察器
返回引用同一管理对象的 shared_ptr 对象的数量
(std::shared_ptr<T> 的公共成员函数) [编辑]
(C++20 前)
检查管理对象是否仅由当前的 shared_ptr 对象管理
(std::shared_ptr<T> 的公共成员函数) [编辑]
检查存储的指针是否不为空
(std::shared_ptr<T> 的公共成员函数) [编辑]
提供共享指针的基于所有权的排序
(std::shared_ptr<T> 的公共成员函数) [编辑]

非成员函数

这些非成员函数在 std::experimental 命名空间中声明,并使用 std::experimental::shared_ptr 而非 std::shared_ptr,但在其他方面与对应的 C++14 函数行为相同。

创建一个管理新对象的共享指针
(函数模板) [编辑]
创建一个共享指针,该指针管理使用分配器分配的新对象
(函数模板) [编辑]
如果拥有,则返回指定类型的删除器
(函数模板) [编辑]
(C++20 中移除)(C++20 中移除)(C++20 中移除)(C++20 中移除)(C++20 中移除)(C++20)
与另一个 shared_ptrnullptr 比较
(函数模板) [编辑]
将存储的指针值输出到输出流
(函数模板) [编辑]
特化 std::swap 算法
(函数模板) [编辑]
特化 std::shared_ptr 的原子操作
(函数模板) [编辑]

辅助类模板

这些类模板在 std::experimental 命名空间中声明,并使用 std::experimental::shared_ptrstd::experimental::weak_ptr 而非 std::shared_ptrstd::weak_ptr,但在其他方面与对应的 C++14 类模板行为相同。

提供基于所有者的共享指针和弱指针的混合类型排序
(类模板) [编辑]
允许对象创建指向自身的 shared_ptr
(类模板) [编辑]

[编辑] 示例