Skip to content

Commit

Permalink
Removing broken specialization of std::hash<std::tuple>
Browse files Browse the repository at this point in the history
Summary: ^

Test Plan: Unit tests

Reviewed By: delong.j@fb.com

FB internal diff: D543586
  • Loading branch information
ddrcoder authored and tudor committed Aug 26, 2012
1 parent be7be7e commit cc1518d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 0 additions & 9 deletions folly/Hash.h
Expand Up @@ -338,15 +338,6 @@ namespace std {
return folly::hash::hash_combine(x.first, x.second); 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 } // namespace std


#endif #endif
11 changes: 11 additions & 0 deletions folly/test/HashTest.cpp
Expand Up @@ -19,6 +19,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <stdint.h> #include <stdint.h>
#include <unordered_map> #include <unordered_map>
#include <utility>


using namespace folly::hash; using namespace folly::hash;


Expand Down Expand Up @@ -172,6 +173,16 @@ TEST(Hash, hasher) {
EXPECT_EQ(get_default(m, 4), 5); 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) { TEST(Hash, hash_combine) {
EXPECT_NE(hash_combine(1, 2), hash_combine(2, 1)); EXPECT_NE(hash_combine(1, 2), hash_combine(2, 1));
} }

0 comments on commit cc1518d

Please sign in to comment.