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-24 17:25:55

Daniel James wrote:
> On 18 February 2011 19:40, Stewart, Robert <Robert.Stewart_at_[hidden]> wrote:
> > The following is a program that demonstrates that a null shared_ptr<int>
> > produces a hash value of zero and that (ostensibly) all non-null
> > instances produce a hash value of one.
> This is known, it happens because shared_ptr can be implicitly cast to
> bool, so it uses that. If you set BOOST_HASH_NO_IMPLICIT_CASTS it won't
> happen.

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.

(I'll still fix this on shared_ptr's side, just wondering.)

Boost list run by bdawes at, gregod at, cpdaniel at, john at