名稱空間
變體
操作

std::weak_ptr<T>::owner_hash

來自 cppreference.com
< cpp‎ | memory‎ | weak_ptr
 
 
記憶體管理庫
(僅作說明*)
未初始化記憶體演算法
(C++17)
(C++17)
(C++17)
受約束的未初始化
記憶體演算法
C 庫

分配器
記憶體資源
垃圾回收支援
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
未初始化儲存
(直到 C++20*)
(直到 C++20*)
顯式生命週期管理
 
 
std::size_t owner_hash() const noexcept;
(C++26 起)

返回一個未指定的值,使得對於任何物件 other,如果 owner_equal(other)true,則 owner_hash() == other.owner_hash() 也為 true

此雜湊用於使共享指標和弱指標可用作無序關聯容器中的鍵,通常透過 std::owner_hash

目錄

[編輯] 返回值

對於共享相同所有權的任何 std::shared_ptrstd::weak_ptr 物件,返回值是相同的。

[編輯] 注意

特性測試 標準 特性
__cpp_lib_smart_ptr_owner_equality 202306L (C++26) 允許將 std::weak_ptr 用作無序關聯容器中的鍵

[編輯] 示例

[編輯] 參閱

為共享指標和弱指標提供基於所有者的雜湊
(類) [編輯]