Boost logo

Boost :

From: Dave Harris (brangdon_at_[hidden])
Date: 2005-03-16 12:07:14


In-Reply-To: <012301c5299e$0e2b2f90$6501a8c0_at_pdimov2>
pdimov_at_[hidden] (Peter Dimov) wrote (abridged):
> This is because you ignored the "use_a" member when computing the hash
> value.

I didn't ignore it; hash_value uses it, albeit not in the best way.

> We can't prevent these mistakes in general; if you omit a member
> (that affects the equivalence relation) when computing the hash value,
> the computation is just wrong.

In this case the computation was correct, and indeed carefully chosen, but
produced needlessly many collisions.

> A hash_value that encodes the type will just hide the error from you if
> a and b have different types

The point is that even the corrected version is needlessly throwing away
some valuable entropy. It's not about hiding the error, it's about having
the best possible hash function.

-- 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