
Hello David,
----- Mensaje original -----
De: David Brownell
When comparing the results of the find method to the end iterator in the code below, it appears that find is finding elements that are not in the container. Am I using multi-index in the wrong way?
Thanks for the help! [...] struct CompareFunc { bool operator()(MyObject const &o, int i) const { return(i == o.Get());} bool operator()(int i, MyObject const &o) const { return(o.Get() == i);} };
Here's the problem: your comparison functor must have less-than rather than equality semantics. Try rewriting it as follows: struct CompareFunc { bool operator()(MyObject const &o, int i) const { return(o.Get() < i);} bool operator()(int i, MyObject const &o) const { return(i < o.Get());} }; Hope this helps. Thank you for using Boost.MultiIndex. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo