Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-03-09 08:10:55


Daniel James wrote:
> Joaquín Mª López Muñoz wrote:
>> 1. If this lib is going to claim adherence to Peter Dimov's
>> proposal, the reference should state what the algortihms are for
>> overloads of hash_value for:
>>
>> int
>> unsigned int
>> long
>> unsigned long
>> std::pair
>> std::basic_string
>> STL containers
>>
>> Currently all these overloads appear without a mention of what their
>> exact behavior is. A mention to Peter's proposal is included, but I
>> think it'd be better to replicate the spec entirely rather than rely
>> on an external paper.
>
> I didn't document these because I might change them in the future
> (I'll consult the list for opinions before I make any such change).

It is a deliberate design decision that the algorithms are fully specified.
The goal is precisely to not allow you (as an implementor) to change them.
;-)

As usual, this is a tradeoff between giving more freedom to implementors to
improve the behavior and giving more portability guarantees to users.
Varying the hash function can lead to dramatic changes in performance and
not specifying the exact algorithm will mean that an application using the
default hash functions would need to be benchmarked again after every change
of the standard library.

Of course the fact that hash_range gives the same result as hash_value on
the corresponding container is no accident, either.


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