return 0;
}
+template <
+ class Iter,
+ class Hash = std::hash<typename std::iterator_traits<Iter>::value_type>>
+uint64_t hash_range(Iter begin,
+ Iter end,
+ uint64_t hash = 0,
+ Hash hasher = Hash()) {
+ for (; begin != end; ++begin) {
+ hash = hash_128_to_64(hash, hasher(*begin));
+ }
+ return hash;
+}
+
template <class Hasher, typename T, typename... Ts>
size_t hash_combine_generic(const T& t, const Ts&... ts) {
size_t seed = Hasher::hash(t);
EXPECT_EQ("bar", m[t]);
}
+namespace {
+template <class T>
+size_t hash_vector(const std::vector<T>& v) {
+ return hash_range(v.begin(), v.end());
+}
+}
+
+TEST(Hash, hash_range) {
+ EXPECT_EQ(hash_vector<int32_t>({1, 2}), hash_vector<int16_t>({1, 2}));
+ EXPECT_NE(hash_vector<int>({2, 1}), hash_vector<int>({1, 2}));
+ EXPECT_EQ(hash_vector<int>({}), hash_vector<float>({}));
+}
+
TEST(Hash, std_tuple_different_hash) {
typedef std::tuple<int64_t, std::string, int32_t> tuple3;
tuple3 t1(42, "foo", 1);