#include #include #include #include #include using namespace boost; using namespace boost::multi_index; using namespace std; typedef unsigned long tID; class Test { public: Test(tID id): uID(id) {} tID getID() const { return uID; } private: tID uID; }; struct by_index; struct by_id; typedef multi_index_container< Test, indexed_by< random_access< tag >, hashed_unique< tag, const_mem_fun > > // indexed_by > container; typedef container::index::type hashedView; typedef container::index::type indexedView; void foo (Test &t) { cout << t.getID() << "\n"; } // foo int main () { container c; Test t(10); hashedView& hashed_index = c.get(); indexedView &idx = c.get(); // first try std::pair p = hashed_index.insert(t); foo(*p.first); // second try hashedView::iterator it = hashed_index.find(t.getID()); foo(*it); // third try foo(idx[0]); } // main