名稱空間
變體
操作

std::experimental::shared_ptr

來自 cppreference.com
< 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
(類模板) [編輯]

[編輯] 示例