
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? Boris -- struct foo { int i, j; foo(int i, int j) : i(i), j(j) { } }; std::size_t hash_value(const shared_ptr<foo> &f) { std::size_t seed = 0; boost::hash_combine(seed, f->i); boost::hash_combine(seed, f->j); return seed; } typedef multi_index_container< shared_ptr<foo>, indexed_by<hashed_unique<identity<shared_ptr<foo> > > >
mi_t;
shared_ptr<foo> f1(new foo(0, 0)); shared_ptr<foo> f2(new foo(0, 0)); mi_t mi; cout << mi.insert(f1).second << endl; // Returns 1. cout << mi.insert(f2).second << endl; // Returns again 1?! cout << mi.size() << endl; // Returns 2?!