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

Unified Diff: Source/wtf/HashFunctions.h

Issue 183833009: Oilpan: Allowing hashing of RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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: Source/wtf/HashFunctions.h
diff --git a/Source/wtf/HashFunctions.h b/Source/wtf/HashFunctions.h
index a9eb156fbc6f67b2475297cfacd99fff6e10031c..f58f8e6699ff21132044cc489834e399cf035007 100644
--- a/Source/wtf/HashFunctions.h
+++ b/Source/wtf/HashFunctions.h
@@ -143,6 +143,14 @@ namespace WTF {
static bool equal(P* a, const RefPtr<P>& b) { return a == b; }
static bool equal(const RefPtr<P>& a, P* b) { return a == b; }
};
+ template<typename P> struct PtrHash<RawPtr<P> > : PtrHash<P*> {
+ using PtrHash<P*>::hash;
+ static unsigned hash(const RawPtr<P>& key) { return hash(key.get()); }
+ using PtrHash<P*>::equal;
+ static bool equal(const RawPtr<P>& a, const RawPtr<P>& b) { return a == b; }
+ static bool equal(P* a, const RawPtr<P>& b) { return a == b; }
+ static bool equal(const RawPtr<P>& a, P* b) { return a == b; }
+ };
// default hash function for each type
@@ -189,6 +197,7 @@ namespace WTF {
template<typename P> struct DefaultHash<P*> { typedef PtrHash<P*> Hash; };
template<typename P> struct DefaultHash<RefPtr<P> > { typedef PtrHash<RefPtr<P> > Hash; };
+ template<typename P> struct DefaultHash<RawPtr<P> > { typedef PtrHash<RawPtr<P> > Hash; };
// make IntPairHash the default hash function for pairs of (at most) 32-bit integers.
« no previous file with comments | « Source/heap/HeapTest.cpp ('k') | Source/wtf/HashTraits.h » ('j') | Source/wtf/HashTraits.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698