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

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

Issue 1839003002: WTF: De-specialize PtrHash<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/RetainPtr.h
diff --git a/third_party/WebKit/Source/wtf/RetainPtr.h b/third_party/WebKit/Source/wtf/RetainPtr.h
index 53b4d424cdd709eebd9f49593695f8d787db12e9..aaef9d93c5c54bd7e5b8f89c631b972fcec790d9 100644
--- a/third_party/WebKit/Source/wtf/RetainPtr.h
+++ b/third_party/WebKit/Source/wtf/RetainPtr.h
@@ -25,6 +25,7 @@
#include "wtf/HashTraits.h"
#include "wtf/TypeTraits.h"
#include <algorithm>
+#include <type_traits>
#include <utility>
#if USE(CF)
@@ -297,18 +298,24 @@ template <typename T> inline RetainPtr<T> retainPtr(T o)
return RetainPtr<T>(o);
}
-template <typename P> struct HashTraits<RetainPtr<P>> : SimpleClassHashTraits<RetainPtr<P>> { };
+template <typename T>
+struct HashTraits<RetainPtr<T>> : SimpleClassHashTraits<RetainPtr<T>> { };
-template <typename P> struct PtrHash<RetainPtr<P>> : PtrHash<typename RetainPtr<P>::PtrType> {
- using PtrHash<typename RetainPtr<P>::PtrType>::hash;
- static unsigned hash(const RetainPtr<P>& key) { return hash(key.get()); }
- using PtrHash<typename RetainPtr<P>::PtrType>::equal;
- static bool equal(const RetainPtr<P>& a, const RetainPtr<P>& b) { return a == b; }
- static bool equal(typename RetainPtr<P>::PtrType a, const RetainPtr<P>& b) { return a == b; }
- static bool equal(const RetainPtr<P>& a, typename RetainPtr<P>::PtrType b) { return a == b; }
+template <typename T>
+struct RetainPtrHash : PtrHash<typename std::remove_pointer<typename RetainPtr<T>::PtrType>::type> {
+ using Base = PtrHash<typename std::remove_pointer<typename RetainPtr<T>::PtrType>::type>;
+ using Base::hash;
+ static unsigned hash(const RetainPtr<T>& key) { return hash(key.get()); }
+ using Base::equal;
+ static bool equal(const RetainPtr<T>& a, const RetainPtr<T>& b) { return a == b; }
+ static bool equal(typename RetainPtr<T>::PtrType a, const RetainPtr<T>& b) { return a == b; }
+ static bool equal(const RetainPtr<T>& a, typename RetainPtr<T>::PtrType b) { return a == b; }
};
-template <typename P> struct DefaultHash<RetainPtr<P>> { typedef PtrHash<RetainPtr<P>> Hash; };
+template <typename T>
+struct DefaultHash<RetainPtr<T>> {
+ using Hash = RetainPtrHash;
+};
} // namespace WTF

Powered by Google App Engine
This is Rietveld 408576698