diff --git a/mfbt/RefPtr.h b/mfbt/RefPtr.h index dc7eaa754f6d..2eba465ccfb1 100644 --- a/mfbt/RefPtr.h +++ b/mfbt/RefPtr.h @@ -13,6 +13,7 @@ #include "mozilla/Assertions.h" #include "mozilla/Atomics.h" #include "mozilla/Attributes.h" +#include "mozilla/Move.h" #include "mozilla/RefCountType.h" #include "mozilla/TypeTraits.h" #if defined(MOZILLA_INTERNAL_API) @@ -327,7 +328,13 @@ class TemporaryRef typedef typename RefPtr::DontRef DontRef; public: - MOZ_IMPLICIT TemporaryRef(T* aVal) : mPtr(RefPtr::ref(aVal)) {} + // Please see already_AddRefed for a description of what these constructors + // do. + TemporaryRef() : mPtr(nullptr) {} + typedef void (TemporaryRef::* MatchNullptr)(double, float); + MOZ_IMPLICIT TemporaryRef(MatchNullptr aRawPtr) : mPtr(nullptr) {} + explicit TemporaryRef(T* aVal) : mPtr(RefPtr::ref(aVal)) {} + TemporaryRef(const TemporaryRef& aOther) : mPtr(aOther.take()) {} template @@ -347,7 +354,6 @@ private: mutable T* MOZ_OWNING_REF mPtr; - TemporaryRef() = delete; void operator=(const TemporaryRef&) = delete; };