Bug 1119086 - already_AddRefed should define copy/move assignment operators. r=nfroyd
authorDonato Sciarra <sciarp@gmail.com>
Fri, 10 Apr 2015 14:03:00 +0200
changeset 270357 72c7745a331ae2bc88f072cc527cea556ff71083
parent 270356 331d71cabe1ef6ec803d3e6e8bb85b44d702a187
child 270358 8d1e4bfdbb9a5cb98f0b6b8fb013aa979461b8c6
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd
bugs1119086
milestone40.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 1119086 - already_AddRefed should define copy/move assignment operators. r=nfroyd
mfbt/AlreadyAddRefed.h
--- a/mfbt/AlreadyAddRefed.h
+++ b/mfbt/AlreadyAddRefed.h
@@ -61,21 +61,28 @@ struct already_AddRefed
 
   // The return and argument types here are arbitrarily selected so no
   // corresponding member function exists.
   typedef void (already_AddRefed::* MatchNullptr)(double, float);
   MOZ_IMPLICIT already_AddRefed(MatchNullptr aRawPtr) : mRawPtr(nullptr) {}
 
   explicit already_AddRefed(T* aRawPtr) : mRawPtr(aRawPtr) {}
 
-  // Disallowed. Use move semantics instead.
+  // Disallow copy constructor and copy assignment operator: move semantics used instead.
   already_AddRefed(const already_AddRefed<T>& aOther) = delete;
+  already_AddRefed<T>& operator=(const already_AddRefed<T>& aOther) = delete;
 
   already_AddRefed(already_AddRefed<T>&& aOther) : mRawPtr(aOther.take()) {}
 
+  already_AddRefed<T>& operator=(already_AddRefed<T>&& aOther)
+  {
+    mRawPtr = aOther.take();
+    return *this;
+  }
+
   /**
    * This helper is useful in cases like
    *
    *  already_AddRefed<BaseClass>
    *  Foo()
    *  {
    *    nsRefPtr<SubClass> x = ...;
    *    return x.forget();