std::owner_hash
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Memory management library
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
Garbage collector support (until C++23)
(exposition only*)
(C++11)
(C++23)
(C++11)
(C++17)
(C++11)
(C++11)
(C++20)
(C++20)
(C++17)
(C++11)
(C++17)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(until C++20*)
(until C++20*)
(until C++20*)
(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)
(C++11)
(C++11)
(C++17)
(C++20)
(C++17)
(C++11)
(C++11)
(C++11)
(until C++17*)
(C++11)
(C++17)
owner_hash
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++11)
(C++20)
(C++11)
(C++11)
(C++20)
(C++26)
Defined in header
<memory>
struct owner_hash;
(since C++26)
This function object provides owner-based (as opposed to value-based) hashing of both std::weak_ptr and std::shared_ptr .
Contents
[edit] Nested types
Nested type
Definition
is_transparent
unspecified
[edit] Member functions
operator()
(function)
std::owner_hash::operator()
template< class T >
std::size_t operator()( const std::shared_ptr <T>& key ) const noexcept;
(1)
(since C++26)
std::size_t operator()( const std::shared_ptr <T>& key ) const noexcept;
template< class T >
std::size_t operator()( const std::weak_ptr <T>& key ) const noexcept;
(2)
(since C++26)
std::size_t operator()( const std::weak_ptr <T>& key ) const noexcept;
Equivalent to return key.owner_hash();.
Parameters
key
-
shared-ownership pointer to be hashed
Return value
A hash value that is identical for any std::shared_ptr or std::weak_ptr object sharing the same ownership.
[edit] Notes
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_smart_ptr_owner_equality |
202306L |
(C++26) | Enabling the use of std::shared_ptr and std::weak_ptr as keys in unordered associative containers
|
[edit] See also
(C++26)
(public member function of
std::shared_ptr<T>
) [edit]
(C++26)
(public member function of
std::weak_ptr<T>
) [edit]