Bug 1455891: Add move-{construction,assignment} to AutoTArray. r?froydnj
MozReview-Commit-ID: HWX0wgy6NS9
--- 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: