Advertisement
Guest User

Untitled

a guest
Apr 16th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace std {
  2. enum hash_traits_result {
  3. always_true,
  4. always_false,
  5. runtime
  6. };
  7. template<typename T> struct hash_traits {
  8. template<typename A, typename B> struct heterogenous {
  9. static constexpr hash_traits_result result = always_false;
  10. };
  11. };
  12. template<> struct hash_traits<std::hash<>> {
  13. template<typename A, typename B> struct heterogenous;
  14. };
  15. template<typename T> struct hash_traits<std::hash<>>::heterogenous<std::unique_ptr<T>, T*> {
  16. static constexpr hash_traits_result result = always_true;
  17. };
  18. }
  19. struct mah_hasher {
  20. bool do_the_right_thing;
  21. };
  22. template<> struct hash_traits<mah_hasher>::heterogenous<X, Y> {
  23. static constexpr hash_traits_result result = runtime;
  24. bool operator()(const mah_hasher& ref) {
  25. return ref.do_the_right_thing;
  26. }
  27. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement