Skip to content

Instantly share code, notes, and snippets.

@geneotech
Last active November 29, 2016 12:47
Show Gist options
  • Save geneotech/b76ad0568eb7c3e86b5fee59df6c1f6d to your computer and use it in GitHub Desktop.
Save geneotech/b76ad0568eb7c3e86b5fee59df6c1f6d to your computer and use it in GitHub Desktop.
#include <unordered_map>
namespace std {
template <class T>
struct member_hash {
std::size_t operator()(const T& t) const {
return t.hash();
}
};
template <class Key, class Value>
using unordered_map_member_hash = std::unordered_map<Key, Value, member_hash<Key>>;
}
struct Vertex {
std::size_t hash() const {
return 1337;
}
};
struct Dupa {
};
int main() {
std::unordered_map_member_hash<Vertex, Dupa> m;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment