Boost logo

Boost :

From: Dave Harris (brangdon_at_[hidden])
Date: 2005-03-13 10:11:13


In-Reply-To: <007e01c52597$b62c1980$6601a8c0_at_pdimov>
pdimov_at_[hidden] (Peter Dimov) wrote (abridged):
> pair<int, int>, int[2], struct { int a; int b; } are different
> representations of the same thing; it is not strictly necessary for
> them to use the same algorithm, but it's desirable and will eliminate a
> source of confusion and mistakes.

Really? What kind of mistakes?

In my experience, if you want two different things to hash the same, you
need to write their hash functions with that in mind. It is a special case
which justifies not using the default hash function.

> void hash_range( size_t & seed, It first, It last );
>
> should this function be added. You are welcome to spell the above as
>
> size_t hash_range( size_t seed, It first, It last );

I am also tempted by:

     size_t hash_range( It first, It last, size_t seed=0 );

perhaps replacing the 0 with some other default value. So people can
ignore it if they don't need it.

But doesn't this mean that hash_value( pair<int,int> ) also needs a seed
argument, if you want it to match hash_range( int[2] ) ?

-- Dave Harris, Nottingham, UK


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