
Daniel James wrote:
On 18 February 2011 19:40, Stewart, Robert <Robert.Stewart@sig.com> 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.)