}
};
+template<> struct hasher<std::string> {
+ size_t operator()(const std::string& key) const {
+ return hash::SpookyHashV2::Hash64(key.data(), key.size(), 0);
+ }
+};
+
template <class T>
struct hasher<T, typename std::enable_if<std::is_enum<T>::value, void>::type> {
size_t operator()(T key) const {
std::hash<tuple3>()(t3));
}
-TEST(Range, Hash) {
+TEST(Hash, Strings) {
using namespace folly;
StringPiece a1 = "10050517", b1 = "51107032",
EXPECT_NE(h2(w1), h2(w2));
EXPECT_NE(h2(w1), h2(w3));
EXPECT_NE(h2(w2), h2(w4));
+
+ // Check compatibility with std::string.
+ EXPECT_EQ(h2(a1), h2(a1.str()));
+ EXPECT_EQ(h2(a2), h2(a2.str()));
+ EXPECT_EQ(h2(a3), h2(a3.str()));
+ EXPECT_EQ(h2(a4), h2(a4.str()));
}