Boost logo

Boost :

Subject: Re: [boost] [functional] [shared_ptr] boost::hash<shared_ptr<T>> Returns Only Two Values
From: Peter Dimov (pdimov_at_[hidden])
Date: 2011-02-27 14:54:32


Daniel James wrote:
> On 24 February 2011 22:25, Peter Dimov <pdimov_at_[hidden]> wrote:
> >
> > But why is there a definition of hash_value( bool ) when this macro
> > isn't
> > defined? Shouldn't the largest integral types be enough? Even if they
> > aren't, everything below int shouldn't be necessary - it's a standard
> > promotion and it shouldn't be ambiguous to omit bool/char/short.
>
> It looks like it was required for Borland.
>
> From http://article.gmane.org/gmane.comp.lib.boost.devel/119513/

This has led me to question the hash_value design altogether (even though I
am the one who came up with it). Relying solely on boost::hash
specializations and not on hash_value overloads has the side effect of not
allowing conversions, and as this case demonstrates, an unwanted conversion
in this context can cause substantial harm, because the code still compiles
and runs, causing a 100% collision rate. It seems better to just require an
exact specialization.


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