Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2024-12-07 00:21:20


Andrey Semashev wrote:
> 3. Since there is already the std::hash infrastructure that is supported by std
> unordered containers and more, have you considered providing means to
> simplify integration of user types supporting Boost.Hash2 protocol with
> std::hash?

There are several ways in which you can produce a std::hash-compatible
adaptor using the library - there are examples showing them - and I haven't
yet settled on which one is the correct one to provide.

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.

But in principle, if we have (settled on) a particular adaptor hash<T, H>,
providing the std::hash specialization is a one liner:

template<> struct std::hash<MyType>: hash<MyType, MyFavoriteHash> {};

There's not much point in automating or macroizing it.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk