Bug 1455891: Add move-{construction,assignment} to AutoTArray. r?froydnj draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 03 Jul 2018 10:10:06 +0200
changeset 813480 f11d6645684c86f7070714f235668873d553d4e8
parent 813468 402747a100cf7b357ca492f85cd37aeffda280a2
child 813481 9aa73fbe9437095d9cfee7b6a506150faa9b6c14
child 813916 38f319f756a311a2545fc1162e2157bb6d739bbc
push id114911
push userbmo:emilio@crisal.io
push dateTue, 03 Jul 2018 08:15:50 +0000
reviewersfroydnj
bugs1455891
milestone63.0a1
Bug 1455891: Add move-{construction,assignment} to AutoTArray. r?froydnj MozReview-Commit-ID: HWX0wgy6NS9
xpcom/ds/nsTArray.h
--- a/xpcom/ds/nsTArray.h
+++ b/xpcom/ds/nsTArray.h
@@ -2462,16 +2462,23 @@ public:
 
   explicit AutoTArray(const base_type& aOther)
     : mAlign()
   {
     Init();
     this->AppendElements(aOther);
   }
 
+  AutoTArray(self_type&& aOther)
+    : mAlign()
+  {
+    Init();
+    this->SwapElements(aOther);
+  }
+
   explicit AutoTArray(base_type&& aOther)
     : mAlign()
   {
     Init();
     this->SwapElements(aOther);
   }
 
   template<typename Allocator>
@@ -2489,16 +2496,23 @@ public:
   }
 
   self_type& operator=(const self_type& aOther)
   {
     base_type::operator=(aOther);
     return *this;
   }
 
+  self_type& operator=(self_type&& aOther)
+  {
+    this->~self_type();
+    new (this) self_type(std::move(aOther));
+    return *this;
+  }
+
   template<typename Allocator>
   self_type& operator=(const nsTArray_Impl<elem_type, Allocator>& aOther)
   {
     base_type::operator=(aOther);
     return *this;
   }
 
 private: