#include #include #include #include #include #include #include #include namespace mpl = boost::mpl; namespace te = boost::type_erasure; template struct hashable { static std::size_t apply(const C& c) { return std::hash()(c); } }; typedef mpl::vector< te::copy_constructible<>, hashable > requirements; typedef te::any test; namespace std { template<> class hash { public : size_t operator()(const test &t ) const { return te::call(hashable<>(), t); } }; }; struct C { std::size_t hash() const { //coord is a member std::vector return boost::hash_range(coord.begin(), coord.end()); } std::vector coord; }; namespace std { template<> class hash { public : size_t operator()(const C& c) { return c.hash(); } }; } int main() { C c = { { 1, 2 } }; test t(c); std::cout << std::hash()(t) << std::endl; }