This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Hashing standard containers
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: Christopher Jefferson <caj at cs dot st-andrews dot ac dot uk>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 27 Oct 2009 01:35:13 +0100
- Subject: Re: Hashing standard containers
- References: <submission.1N1cd1-0003JQ-P4@mail.cs.st-andrews.ac.uk>
Hi,
> Unfortunately both TR1 and it looks like C++0x don't provide an
> overload of std::hash for most templated types, including vector,
> list, pair and tuple.
>
> I find this annoying, as (I believe) while it is legal to overload
> std::hash for my own types, it isn't legal to overload it for standard
> types.
>
> I am not sure if technically it is allows as a QoI issue for standard
> libraries to overload std::hash for the standard containers and
> friends, but it does not seem like an unreasonable thing to do, and I
> would like to do it.
You mean, specialize, right? I don't see why it should be illegal. Note,
I just filed DR 1245, will be in R68, because I don't think it makes
sense to pass by value class types. Besides that, which will require
reworking a bit the existing specializations (I'm also thinking moving a
few inline, at least experimentally, people reported a large performance
improvement for <string> if I remember correctly), I would be certainly
interested in seeing such additional specializations, C++0x only please,
let's try to fiddle as little as possible with TR1 at this point. I
would definitely suggest starting with the mandated ones, thus
std::bitset, and std::vector<bool>...
Paolo.