Bug 1294161 - Add operator== overloads for comparing HandlRefPtrs to their raw Handles. r=bholley a=lizzard
authorCameron McCormack <cam@mcc.id.au>
Fri, 26 Aug 2016 14:02:45 +0800
changeset 342538 057ddf18f231f38a3bd7139c487cad958fb9f88b
parent 342537 33fa756e769e1548b8f81aee313843eca0de09cf
child 342539 fbb6e7fa7e55e04667c83dde25790221fae8b4a7
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley, lizzard
bugs1294161
milestone49.0
Bug 1294161 - Add operator== overloads for comparing HandlRefPtrs to their raw Handles. r=bholley a=lizzard MozReview-Commit-ID: jTQZXyNbqM
layout/style/HandleRefPtr.h
--- a/layout/style/HandleRefPtr.h
+++ b/layout/style/HandleRefPtr.h
@@ -59,26 +59,16 @@ public:
   ~HandleRefPtr() { assign(nullptr); }
 
   explicit operator bool() const { return !!mHandle; }
   bool operator!() const { return !mHandle; }
 
   operator T() const { return mHandle; }
   T operator->() const { return mHandle; }
 
-  bool operator==(const HandleRefPtr<T>& aOther) const
-  {
-    return mHandle == aOther.mHandle;
-  }
-
-  bool operator!=(const HandleRefPtr<T>& aOther) const
-  {
-    return !(*this == aOther);
-  }
-
   void swap(HandleRefPtr<T>& aOther)
   {
     std::swap(mHandle, aOther.mHandle);
   }
 
 private:
   void assign(T aPtr)
   {
@@ -97,11 +87,47 @@ private:
     if (aPtr) {
       aPtr->Release();
     }
   }
 
   T mHandle;
 };
 
+template<typename T>
+inline bool operator==(const HandleRefPtr<T>& aLHS, const HandleRefPtr<T>& aRHS)
+{
+  return static_cast<T>(aLHS) == static_cast<T>(aRHS);
+}
+
+template<typename T>
+inline bool operator==(const HandleRefPtr<T>& aLHS, T aRHS)
+{
+  return static_cast<T>(aLHS) == aRHS;
+}
+
+template<typename T>
+inline bool operator==(T aLHS, const HandleRefPtr<T>& aRHS)
+{
+  return aLHS == static_cast<T>(aRHS);
+}
+
+template<typename T>
+inline bool operator!=(const HandleRefPtr<T>& aLHS, const HandleRefPtr<T>& aRHS)
+{
+  return !(aLHS == aRHS);
+}
+
+template<typename T>
+inline bool operator!=(const HandleRefPtr<T>& aLHS, T aRHS)
+{
+  return !(aLHS == aRHS);
+}
+
+template<typename T>
+inline bool operator!=(T aLHS, const HandleRefPtr<T>& aRHS)
+{
+  return !(aLHS == aRHS);
+}
+
 } // namespace mozilla
 
 #endif // mozilla_HandleRefPtr_h