return folly::hash::hash_combine(x.first, x.second);
}
};
-
- // Same as above, but for arbitrary tuples.
- template <typename... Ts>
- class hash<std::tuple<Ts...> > {
- public:
- size_t operator()(const Ts&... ts) const {
- return folly::hash::hash_combine(ts...);
- }
- };
} // namespace std
#endif
#include <gtest/gtest.h>
#include <stdint.h>
#include <unordered_map>
+#include <utility>
using namespace folly::hash;
EXPECT_EQ(get_default(m, 4), 5);
}
+TEST(Hash, pair) {
+ auto a = std::make_pair(1, 2);
+ auto b = std::make_pair(3, 4);
+ auto c = std::make_pair(1, 2);
+ EXPECT_EQ(hash_combine(a),
+ hash_combine(c));
+ EXPECT_NE(hash_combine(b),
+ hash_combine(c));
+}
+
TEST(Hash, hash_combine) {
EXPECT_NE(hash_combine(1, 2), hash_combine(2, 1));
}