#include typedef void *Type; struct EntryType { EntryType(Type id) : id(id) {} Type id; typedef boost::intrusive::avl_set_member_hook <> AvlHook; AvlHook avl_by_id_hook; struct CompareById { bool operator()(const EntryType &a,const EntryType &b) const {return (a.id < b.id);} }; struct KeyCompareById { bool operator()(const Type &id,const EntryType &b) const {return (id < b.id);} bool operator()(const EntryType &a,const Type &id) const {return (a.id < id);} }; }; typedef boost::intrusive::avl_set< EntryType, boost::intrusive::member_hook< EntryType, EntryType::AvlHook, &EntryType::avl_by_id_hook >, boost::intrusive::compare > SetById; void foo(SetById &s,const Type &x) { s.find(x,EntryType::KeyCompareById()); }