Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(604)

Unified Diff: third_party/WebKit/Source/wtf/HashFunctions.h

Issue 2687923002: WTF: Support enums in DefaultHash and HashTraits by casting to integral types. (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/HashFunctions.h
diff --git a/third_party/WebKit/Source/wtf/HashFunctions.h b/third_party/WebKit/Source/wtf/HashFunctions.h
index c3d90d02655a162d8249f943f79fab200715aa95..207c409a0d8583e43e9ba274822a87f95030c27c 100644
--- a/third_party/WebKit/Source/wtf/HashFunctions.h
+++ b/third_party/WebKit/Source/wtf/HashFunctions.h
@@ -198,21 +198,23 @@ struct DefaultHash;
// Actual implementation of DefaultHash.
//
-// The case of |isIntegral| == false is not implemented. If you see a compile
-// error saying DefaultHashImpl<T, false> is not defined, that's because the
-// default hash functions for T are not defined. You need to implement them
+// The case of |isIntegralOrEnum| == false is not implemented. If you see a
+// compile error saying DefaultHashImpl<T, false> is not defined, that's because
+// the default hash functions for T are not defined. You need to implement them
// yourself.
-template <typename T, bool isIntegral>
+template <typename T, bool isIntegralOrEnum>
struct DefaultHashImpl;
template <typename T>
struct DefaultHashImpl<T, true> {
- using Hash = IntHash<typename std::make_unsigned<T>::type>;
+ using Hash = IntHash<T>;
};
// Canonical implementation of DefaultHash.
template <typename T>
-struct DefaultHash : DefaultHashImpl<T, std::is_integral<T>::value> {};
+struct DefaultHash
+ : DefaultHashImpl<T, std::is_integral<T>::value || std::is_enum<T>::value> {
+};
// Specializations of DefaultHash follow.
template <>
« no previous file with comments | « third_party/WebKit/Source/platform/weborigin/SchemeRegistry.cpp ('k') | third_party/WebKit/Source/wtf/HashTraits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698