std::weak_ptr<T>::owner_hash
來自 cppreference.com
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_ptr
或 std::weak_ptr
物件,返回值是相同的。
[編輯] 注意
特性測試宏 | 值 | 標準 | 特性 |
---|---|---|---|
__cpp_lib_smart_ptr_owner_equality |
202306L |
(C++26) | 允許將 std::weak_ptr 用作無序關聯容器中的鍵 |
[編輯] 示例
本節不完整 原因:示例 |
[編輯] 參閱
(C++26) |
為共享指標和弱指標提供基於所有者的雜湊 (類) |