
After some playing around I got now this code to compile (based on boost::multi_index::detail::const_member_base): template<class Class,typename Type,Type Class::*PtrToMember,Type (*func)(const Type&)> struct my_member { typedef Type result_type; template<typename ChainedPtr> Type& operator()(const ChainedPtr& x)const { return operator()(*x); } Type operator()(const Class& x)const { return func(x.*PtrToMember); } Type& operator()(const reference_wrapper<const Class>& x)const { return operator()(x.get()); } Type& operator()(const reference_wrapper<Class> x,int=0)const { return operator()(x.get()); } }; std::string test(const std::string &s) { return boost::algorithm::to_lower_copy(s); } typedef multi_index_container< employee, indexed_by< hashed_unique< my_member<employee, std::string, &employee::name, &test> >
mi;
mi employees; I don't know if it can be more generalized or if it is of any help for anybody else except me. But now I don't have the time to play around some more with key extractors unfortunately. :) Boris