std::hash<std::unique_ptr> (3) - Linux Manuals
std::hash<std::unique_ptr>: std::hash<std::unique_ptr>
NAME
std::hash<std::unique_ptr> - std::hash<std::unique_ptr>
Synopsis
template<class T, class Deleter> struct hash<unique_ptr<T, Deleter>>; (since C++11)
The template specialization of std::hash for std::unique_ptr<T, Deleter> allows users to obtain hashes of objects of type std::unique_ptr<T, Deleter>.
The specialization std::hash<std::unique_ptr<T,D>> is enabled (see std::hash) if std::hash<typename std::unique_ptr<T,D>::pointer> is enabled, and is disabled otherwise. (since C++17)
When enabled,
(since C++17) for a given std::unique_ptr<T, D> p, this specialization ensures that std::hash<std::unique_ptr<T, D>>()(p) == std::hash<typename std::unique_ptr<T, D>::pointer>()(p.get()).
The member functions of this specialization are not guaranteed to be noexcept because the pointer may be a fancy pointer and its hash might throw.
Example
// Run this code
Output:
See also
hash hash function object
(C++11)