#include #include #include #include #include #include using boost::multi_index_container; using namespace boost::multi_index; struct employee { int id; std::string name; int ssnumber; employee(int id,const std::string& name,int ssnumber): id(id),name(name),ssnumber(ssnumber){} bool operator<(const employee& e)const{return id hasher; return hasher(wstr); } }; struct name{} ; // just for boost tags typedef multi_index_container< employee, indexed_by< // hashed on name hashed_unique, member, ustring_hasher > > > employee_set; typedef employee_set::index::type employee_set_by_name; #define StrConst1 "Foobar!@##$%%^&Yavapai@QuuxQUUX@@27" #define StrConst2 "CabbagesAndTurnips$haveDrivenMeAway" void testBasic() { employee_set testSet; std::string s(StrConst1); employee e1(1, s, 100); testSet.insert(e1); s = std::string(StrConst2); employee e2(2, s, 101); testSet.insert(e2); employee_set_by_name const& name_index = testSet.get(); s = std::string(StrConst1); employee_set::index_iterator::type it = name_index.find(s); s = std::string("Hello There"); it = name_index.find(s); }