Boost logo

Boost Users :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2007-03-21 15:32:38


Hi Boris,

----- Mensaje original -----
De: Boris <boriss_at_[hidden]>
Fecha: Miércoles, Marzo 21, 2007 8:19 pm
Asunto: [Boost-users] [multi_index] problem with hashed index
Para: boost-users_at_[hidden]

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

Good luck,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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