std::shared_ptr<T>::owner_hash

< cpp‎ | memory‎ | shared ptr

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_equality 202306L (C++26) 启用以 std::shared_ptr无序关联容器中的键

示例

参阅

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