Boost logo

Boost Users :

From: Boris (boriss_at_[hidden])
Date: 2007-03-21 15:39:20


On Wed, 21 Mar 2007 21:32:38 +0200, JOAQUIN LOPEZ MU?Z <joaquin_at_[hidden]>
wrote:

Hi Joaquín,

>> I've been using Boost Multiindex quite a lot but don't understand
>> why the code below inserts two items. The container has a unique
>> hash index and the two items return the same hash value. Is this
>> is a bug in the library or in my code?
> [...]
>> indexed_by<hashed_unique<identity<shared_ptr<foo> > > >
>
> Here's the problem: your key is shared_ptr<foo>, i.e.,
> you compare *the pointers* rather than the pointed to
> foo objects. What you want is this instead:
>
> indexed_by<hashed_unique<identity<foo > > >

thanks for your fast answer! But the hash function is still
hash_value(const shared_ptr<foo> &f) or hash_value(const foo &f)?

Boris


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net