std::shared_ptr<T>::owner_hash

来自cppreference.com
< cpp‎ | memory‎ | shared ptr

 
 
内存管理库
(仅用于阐述*)
分配器
未初始化内存算法
受约束的未初始化内存算法
内存资源
未初始化存储 (C++20 前)
(C++17 弃用)
(C++17 弃用)
垃圾收集器支持 (C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
 
 
std::size_t owner_hash() const noexcept;
(C++26 起)

返回未指定的值,使得对于任何 owner_equal(other)true 的对象 otherowner_hash() == other.owner_hash() 均为 true

此散列函数常通过 std::owner_hash 使用,使得共享指针与弱指针能用作无序关联容器的键。

返回值

对于任何共享同一所有权的 std::shared_ptrstd::weak_ptr 对象相等的值。

注解

功能特性测试标准功能特性
__cpp_lib_smart_ptr_owner_equality202306L(C++26)启用以 std::shared_ptr无序关联容器中的键

示例

参阅

对共享指针与弱指针提供基于所有者的散列器
(类)