|
|
Defined in header <memory> | ||
struct owner_hash; | (since C++26) | |
This function object provides owner-based (as opposed to value-based) hashing of bothstd::weak_ptr andstd::shared_ptr.
Contents |
Nested type | Definition |
is_transparent | unspecified |
operator() | calculates the hash of the shared-ownership pointer (function) |
template<class T> std::size_t operator()(conststd::shared_ptr<T>& key)constnoexcept; | (1) | (since C++26) |
template<class T> std::size_t operator()(conststd::weak_ptr<T>& key)constnoexcept; | (2) | (since C++26) |
Equivalent toreturn key.owner_hash();.
key | - | shared-ownership pointer to be hashed |
A hash value that is identical for anystd::shared_ptr orstd::weak_ptr object sharing the same ownership.
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_smart_ptr_owner_equality | 202306L | (C++26) | Enabling the use ofstd::shared_ptr andstd::weak_ptr as keys inunordered associative containers |
(C++26) | provides owner-based hashing of shared pointers (public member function of std::shared_ptr<T> )[edit] |
(C++26) | provides owner-based hashing of weak pointers (public member function of std::weak_ptr<T> )[edit] |