std::weak_ptr<T>::owner_hash
来自 cppreference.cn
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) |
为共享指针和弱指针提供基于所有者的哈希 (类) |