unordered_map with valarray as key
David Fang
fang@csl.cornell.edu
Tue Oct 29 00:58:00 GMT 2013
>> However, nothing stops one from providing a specialization of
>> std::hash<std::valarray<> >. You could look at hash<std::string> ro
>> hash<const char*> as a starting point.
>
> That's not true, it's undefined behaviour to specialize templates from
> namespace std unless the specialization depends on one or more
> user-defined types, so it is not allowed to specialize
> std::hash<std::valarray<long>>. The alternative is to define your own
> hash function (not a specialization of std::hash) and use that with
> the unordered container.
Yes, passing a custom Hash to unordered_map is much
cleaner,safer,more-legal than polluting std::.
Fang
More information about the Libstdc++
mailing list