This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: unordered_map with valarray as key
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: David Fang <fang at csl dot cornell dot edu>
- Cc: Daniel Krügler <daniel dot kruegler at gmail dot com>, Daniel Molina García <unomas at correo dot ugr dot es>, "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 29 Oct 2013 00:40:26 +0000
- Subject: Re: unordered_map with valarray as key
- Authentication-results: sourceware.org; auth=none
- References: <1382964043 dot 2909 dot 10 dot camel at do-what-u-should> <CAGNvRgALW8Wt-xfEb48Pj7GFKoiewAcz=3q4wPTq3dCpDr0fww at mail dot gmail dot com> <Pine dot LNX dot 4 dot 64 dot 1310281915350 dot 5295 at hal-00 dot csl dot cornell dot edu>
On 28 October 2013 23:18, David Fang wrote:
>
> 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.