std::weak_ptr<T>::owner_hash
来自 cppreference.cn
std::size_t owner_hash() const noexcept; |
(since C++26) | |
返回一个未指定的值,使得对于任何对象 other
,其中 owner_equal(other) 为 true,owner_hash() == other.owner_hash() 也为 true。
此哈希用于使 shared 和 weak 指针可用作无序关联容器中的键,通常通过 std::owner_hash。
目录 |
[edit] 返回值
对于任何共享相同所有权的 std::shared_ptr
或 std::weak_ptr
对象,此函数返回相同的值。
[edit] 注解
特性测试 宏 | 值 | Std | 特性 |
---|---|---|---|
__cpp_lib_smart_ptr_owner_equality |
202306L |
(C++26) | 启用 std::weak_ptr 作为 无序关联容器中键的使用 |
[edit] 示例
本节尚不完整 原因:示例 |
[edit] 参见
(C++26) |
为 shared 和 weak 指针提供基于所有者的哈希 (类) |