Chromium Code Reviews| Index: third_party/WebKit/Source/platform/wtf/HashFunctions.h |
| diff --git a/third_party/WebKit/Source/platform/wtf/HashFunctions.h b/third_party/WebKit/Source/platform/wtf/HashFunctions.h |
| index 37f195696767ccf5b5c60142b5322bc49f288500..dbcac614f5d406373f537bb7bcdbed58aff1c10f 100644 |
| --- a/third_party/WebKit/Source/platform/wtf/HashFunctions.h |
| +++ b/third_party/WebKit/Source/platform/wtf/HashFunctions.h |
| @@ -284,6 +284,30 @@ struct DefaultHash<std::pair<T, U>> { |
| using Hash = PairHash<T, U>; |
| }; |
| +template <typename T, typename U, typename V> |
| +struct TupleHash { |
|
Nico
2017/04/11 15:41:05
If we must have a TupleHash, consider making it a
msarett1
2017/04/11 20:52:05
Seems fine to write a custom hashing implementatio
|
| + static unsigned GetHash(const std::tuple<T, U, V>& p) { |
| + return HashInts(HashInts(DefaultHash<T>::Hash::GetHash(std::get<0>(p)), |
| + DefaultHash<U>::Hash::GetHash(std::get<1>(p))), |
| + DefaultHash<V>::Hash::GetHash(std::get<2>(p))); |
| + } |
| + static bool Equal(const std::tuple<T, U, V>& a, |
| + const std::tuple<T, U, V>& b) { |
| + return DefaultHash<T>::Hash::Equal(std::get<0>(a), std::get<0>(b)) && |
| + DefaultHash<U>::Hash::Equal(std::get<1>(a), std::get<1>(b)) && |
| + DefaultHash<V>::Hash::Equal(std::get<2>(a), std::get<2>(b)); |
| + } |
| + static const bool safe_to_compare_to_empty_or_deleted = |
| + DefaultHash<T>::Hash::safe_to_compare_to_empty_or_deleted && |
| + DefaultHash<U>::Hash::safe_to_compare_to_empty_or_deleted && |
| + DefaultHash<V>::Hash::safe_to_compare_to_empty_or_deleted; |
| +}; |
| + |
| +template <typename T, typename U, typename V> |
| +struct DefaultHash<std::tuple<T, U, V>> { |
| + using Hash = TupleHash<T, U, V>; |
| +}; |
| + |
| } // namespace WTF |
| using WTF::DefaultHash; |