#include #include #include #include #include #include #include #include struct foo { std::string s; foo(std::string s):s(s){} }; #define DEFINE_BIND_TYPE(name,expr) \ typedef boost::remove_reference< \ boost::remove_cv::type>::type name##_expr_type; \ \ struct name:name##_expr_type \ { \ name():name##_expr_type(expr){} \ }; using namespace boost::multi_index; DEFINE_BIND_TYPE( extractor, boost::bind(&std::string::size,boost::bind(&foo::s,_1))) typedef multi_index_container< foo, indexed_by< hashed_unique > > mi_t; int main() { mi_t m; m.insert(foo("hello")); m.insert(foo("goodbye")); m.insert(foo("C++")); std::cout<s<