
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!
#include
MyContainer;
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); } }; int main(void) { MyContainer c; c.push_back(boost::shared_ptr<MyObject>(new MyObject(3))); c.push_back(boost::shared_ptr<MyObject>(new MyObject(4))); c.push_back(boost::shared_ptr<MyObject>(new MyObject(1))); MyContainer::nth_index<1>::type const & r = c.get<1>(); std::cout << (r.find(1, CompareFunc()) == r.end() ? "Not found" : "found") << "\n"; std::cout << (r.find(13, CompareFunc()) == r.end() ? "Not found" : "found") << "\n"; // This should not be found return(0); }