|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2024-12-04 10:15:51
Alexander Grund wrote:
> > On the other hand, it makes it trivial to generate collisions
> >
> > pair<string, string>( "foo", "bar" )
> > pair<string, string>( "foob", "ar" )
> > pair<string, string>( "fooba", "r" )
> I can imagine an argument that the "collision" is intentional here, i.e.
> that the `data` really is just "foobarfoobarfoobar"
I'm sure you can, but there are actual rules governing the behavior
of hash functions that don't depend on people imagining things.
Equal arguments must produce the same hash value, and unequal
arguments should produce different hash values.
Since the arguments above are distinct (with respect to operator==),
they should produce distinct hash values.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk