
struct employee { std::string name; }; typedef multi_index_container< employee, indexed_by< hashed_unique<member<employee, std::string, &employee::name> >
mi;
If I want to change the index to make it case-insensitive I have to write my own key extractor, right? Would the following code then be correct (it is based on boost::multi_index::member)? template<class Class, std::string Class::*PtrToMember> struct caseinsensitive_string { typedef std::string result_type; template<typename ChainedPtr> std::string operator()(const ChainedPtr& x) const { return operator()(*x); } std::string operator()(const Class& x) const { return boost::algorithm::to_lower_copy(x.*PtrToMember); } std::string operator()(Class& x) const { return boost::algorithm::to_lower_copy(x.*PtrToMember); } std::string operator()(const boost::reference_wrapper<const Class>& x) const { return operator()(x.get()); } std::string operator()(const boost::reference_wrapper<Class> x) const { return operator()(x.get()); } }; With the following typedef I get a container which does not change the name of an employee (I want to retain the name without making it lower- or uppercase) but refuses items with the same case-insensitive name? typedef multi_index_container< employee, indexed_by< hashed_unique<caseinsensitive_string<employee, &employee::name> >
mi2;
Boris