Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-03-22 07:36:44


Dave Harris wrote:
> In-Reply-To: <d1na66$6p2$1_at_[hidden]>
> daniel_at_[hidden] (Daniel James) wrote (abridged):
>>> 5. change implementation of hash values for pointers so undefined
>>> behavior is gone (and consider adding x + (x >> 3) )
>>
>> I'm going to do that.
>
> Is it worth considering using x + x / sizeof(*p) instead?

This will not work for incomplete types, including void. I'd prefer equal
hash_values for an incomplete T*, complete T*, and void* with the same
value.

We'll lose one potential bit of enthropy when alignof(x) == 16, but this
seems sufficiently rare in practice.


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