Boost logo

Boost :

Subject: Re: [boost] [hash] regular behaviour of hash function for double values
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2012-02-01 12:20:33


2012/2/1 Andrey Semashev <andrey.semashev_at_[hidden]>

> On Wednesday, February 01, 2012 10:57:18 Howard Hinnant wrote:
> >
> > As a judgement call, I calculated that I would have *many* more clients
> who
> > are casual users of the std::unordered containers, defaulting most
> options
> > such as the hash function, than I would have clients interested in using
> > std::hash<scalar> in their own containers, or in other places a hash
> > function might be useful.
>
> Thank you for your careful answer. As I understand, in order to compensate
> the
> std::hash simplicity you do additional hashing (bit mixing or modulus) in
> the
> container. May I ask, have you considered the other approach - to make the
> container simpler but add bit mixing to std::hash? Why you chose not to
> follow
> this path?

std::hash can be specialized for user defined types. If unordered
containers were to assume that std::has does bit mixing, users would have
harder time specializing std::hash which could lead to performance bugs.

Roman Perepelitsa.


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