Boost logo

Boost :

From: Daniel James (daniel_at_[hidden])
Date: 2005-03-22 14:38:33

Thorsten Ottosen wrote:
> My point has been that it is up to the programmer to
> make sure that equal objects has the same hash value.

But the programmer might be oblivious to the hash library (remember that
it's used by default in both Boost.MultiIndex and my unordered
containers). The object might have been written by one person, and then
inserted into a hash table by another who, on seeing that it compiles,
thinks that everything has been sorted out in advance.

> Your point is that it could be the wrong hash value.
> I don't see why we should guard against this; the user must always make sure
> that equal objects have the same hash value; consider just what happens when
> the user adds a new data member to the class and updates equality but forgets
> to
> update the hash value or vice versa.

When someone writes a custom hash function they're assuming
responsibility for its upkeep. But that only happens when they write it.


Boost list run by bdawes at, gregod at, cpdaniel at, john at