Bug 1204790 - Prefer deleted function with public access specifiers instead of private in UniquePtr. r=nfroyd
authorJames Cheng <jacheng@mozilla.com>
Tue, 15 Sep 2015 19:18:00 +0200
changeset 297084 c4333afa007fa4dce1a5a415b0da33a505805d4c
parent 297083 370cf163a1f3058ad42f9aafb9fcac8d6fc1ef3d
child 297085 15e860fa81e36d399c7160623ac37f53ba5ee363
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd
bugs1204790
milestone43.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 1204790 - Prefer deleted function with public access specifiers instead of private in UniquePtr. r=nfroyd
mfbt/UniquePtr.h
--- a/mfbt/UniquePtr.h
+++ b/mfbt/UniquePtr.h
@@ -310,17 +310,16 @@ public:
     }
   }
 
   void swap(UniquePtr& aOther)
   {
     mTuple.swap(aOther.mTuple);
   }
 
-private:
   UniquePtr(const UniquePtr& aOther) = delete; // construct using Move()!
   void operator=(const UniquePtr& aOther) = delete; // assign using Move()!
 };
 
 // In case you didn't read the comment by the main definition (you should!): the
 // UniquePtr<T[]> specialization exists to manage array pointers.  It deletes
 // such pointers using delete[], it will reject construction and modification
 // attempts using U* or U[].  Otherwise it works like the normal UniquePtr.
@@ -351,30 +350,28 @@ public:
    */
   explicit UniquePtr(Pointer aPtr)
     : mTuple(aPtr, DeleterType())
   {
     static_assert(!IsPointer<D>::value, "must provide a deleter instance");
     static_assert(!IsReference<D>::value, "must provide a deleter instance");
   }
 
-private:
   // delete[] knows how to handle *only* an array of a single class type.  For
   // delete[] to work correctly, it must know the size of each element, the
   // fields and base classes of each element requiring destruction, and so on.
   // So forbid all overloads which would end up invoking delete[] on a pointer
   // of the wrong type.
   template<typename U>
   UniquePtr(U&& aU,
             typename EnableIf<IsPointer<U>::value &&
                               IsConvertible<U, Pointer>::value,
                               int>::Type aDummy = 0)
   = delete;
 
-public:
   UniquePtr(Pointer aPtr,
             typename Conditional<IsReference<D>::value,
                                  D,
                                  const D&>::Type aD1)
     : mTuple(aPtr, aD1)
   {}
 
   // If you encounter an error with MSVC10 about RemoveReference below, along
@@ -384,26 +381,24 @@ public:
   UniquePtr(Pointer aPtr,
             typename RemoveReference<D>::Type&& aD2)
     : mTuple(aPtr, Move(aD2))
   {
     static_assert(!IsReference<D>::value,
                   "rvalue deleter can't be stored by reference");
   }
 
-private:
   // Forbidden for the same reasons as stated above.
   template<typename U, typename V>
   UniquePtr(U&& aU, V&& aV,
             typename EnableIf<IsPointer<U>::value &&
                               IsConvertible<U, Pointer>::value,
                               int>::Type aDummy = 0)
   = delete;
 
-public:
   UniquePtr(UniquePtr&& aOther)
     : mTuple(aOther.release(), Forward<DeleterType>(aOther.getDeleter()))
   {}
 
   MOZ_IMPLICIT
   UniquePtr(decltype(nullptr))
     : mTuple(nullptr, DeleterType())
   {
@@ -454,24 +449,21 @@ public:
   {
     Pointer old = mTuple.first();
     mTuple.first() = nullptr;
     if (old != nullptr) {
       mTuple.second()(old);
     }
   }
 
-private:
   template<typename U>
   void reset(U) = delete;
 
-public:
   void swap(UniquePtr& aOther) { mTuple.swap(aOther.mTuple); }
 
-private:
   UniquePtr(const UniquePtr& aOther) = delete; // construct using Move()!
   void operator=(const UniquePtr& aOther) = delete; // assign using Move()!
 };
 
 /** A default deletion policy using plain old operator delete. */
 template<typename T>
 class DefaultDelete
 {
@@ -499,17 +491,16 @@ public:
   MOZ_CONSTEXPR DefaultDelete() {}
 
   void operator()(T* aPtr) const
   {
     static_assert(sizeof(T) > 0, "T must be complete");
     delete[] aPtr;
   }
 
-private:
   template<typename U>
   void operator()(U* aPtr) const = delete;
 };
 
 template<typename T, class D>
 void
 Swap(UniquePtr<T, D>& aX, UniquePtr<T, D>& aY)
 {