From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-06-24 06:32:08
Joaquin M Lopez Munoz wrote:
>> This suggestion is very interesting! But I wonder, how you can detect for
>> that objects are the same using a hash. Two different object can hash to
>> the same value? Maybe, operator== is still needed?
> Admittedly, hash-based checking is not 100% safe, but
> I don't think resorting to operator== is doable because:
> * A serializable type need not be equality comparable.
> * Even if the type is equality comparable, you'd have
> to store a copy of the object first time you see it in
> order to check it later against later occurrences.
> This further imposes assignability on the type, and the
> overhead of copying and storing a whole object can be
I agree with you. While it's possible that an object is modified but gets
the same hash value, in most cases your approach will detect modification.
I'd say this is the way to go!
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk