Boost logo

Boost :

From: Daniel James (daniel_james_at_[hidden])
Date: 2006-03-20 17:21:18


Daniel James wrote:
> Peter Dimov wrote:
>> For larger integer types, we probably need something along the lines of
>>
>> std::size_t hash_value( val )
>> {
>> size_t r = val;
>>
>> while( val >>= size_t_bits )
>> {
>> hash_combine( r, (size_t)val );
>> }
>>
>> return r;
>> }
>>
>> It has the property of preserving the hash_value of all _values_ that can
>> fit into a size_t, even though the underlying type is capable of holding
>> bigger integers.
>
> I don't think it does.

Actually, it does for positive number. Sorry I misread it. What you were
doing clicked a couple of seconds after I clicked on 'send'. But I'm not
sure it works for negative numbers.
Daniel


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