Namespaces
Variants

std::weak_ptr<T>:: owner_hash

From cppreference.net

Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
std:: size_t owner_hash ( ) const noexcept ;
(自 C++26 起)

返回一个未指定的值,使得对于任何满足 owner_equal ( other ) true 的对象 other 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)
为共享指针和弱指针提供基于所有者的哈希功能
(类)