
On Fri, Dec 6, 2024 at 4:21 PM Peter Dimov via Boost
A std::hash specialization isn't a good way to do it because you can't pass an initial seed, which is a poor practice in 2025.
std::hash only requires DefaultConstructible, CopyConstructible, and Destructible. And it doesn't say anything about not also being constructible with additional parameters. Couldn't this be made to work: struct std::hash<MyT> { hash( std::size_t seed ); ... All std containers allow construction from an instance of a suitable hash function, and they take ownership by copy: https://en.cppreference.com/w/cpp/container/unordered_map/unordered_map It does look like specializations of std::hash for user-defined types can construct from seeds. Disclaimer: I did not actually read the text of the standard, and only looked at cppreference.com. Thanks