Bug 1262970 - Allow nsMainThreadPtrHandle to be constructed by and compared to nullptr. r=froydnj
authorAndreas Pehrson <pehrsons@gmail.com>
Thu, 14 Apr 2016 11:38:04 +0200
changeset 331270 6bbf05ba56d8d6eac6474d1ed678c8acfb160467
parent 331269 9f90060e64a0980803e85e6b2d475eece7f402fa
child 331271 24eb2f310602f25dbc75103b631adfbcc9d7d1d1
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1262970
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1262970 - Allow nsMainThreadPtrHandle to be constructed by and compared to nullptr. r=froydnj MozReview-Commit-ID: HQgRhJc9AwG
xpcom/glue/nsProxyRelease.h
--- a/xpcom/glue/nsProxyRelease.h
+++ b/xpcom/glue/nsProxyRelease.h
@@ -219,16 +219,17 @@ private:
 
 template<class T>
 class nsMainThreadPtrHandle
 {
   RefPtr<nsMainThreadPtrHolder<T>> mPtr;
 
 public:
   nsMainThreadPtrHandle() : mPtr(nullptr) {}
+  MOZ_IMPLICIT nsMainThreadPtrHandle(decltype(nullptr)) : mPtr(nullptr) {}
   explicit nsMainThreadPtrHandle(nsMainThreadPtrHolder<T>* aHolder)
     : mPtr(aHolder)
   {
   }
   nsMainThreadPtrHandle(const nsMainThreadPtrHandle& aOther)
     : mPtr(aOther.mPtr)
   {
   }
@@ -271,14 +272,16 @@ public:
       return mPtr == aOther.mPtr;
     }
     return *mPtr == *aOther.mPtr;
   }
   bool operator!=(const nsMainThreadPtrHandle<T>& aOther) const
   {
     return !operator==(aOther);
   }
+  bool operator==(decltype(nullptr)) const { return mPtr == nullptr; }
+  bool operator!=(decltype(nullptr)) const { return mPtr != nullptr; }
   bool operator!() const {
     return !mPtr || !*mPtr;
   }
 };
 
 #endif