Bug 1359653: Part 3 - Add a clear() method and move asssignment operator to AutoCleanLinkedList. r=waldo
MozReview-Commit-ID: 2bUTMPviJzg
--- a/mfbt/LinkedList.h
+++ b/mfbt/LinkedList.h
@@ -643,16 +643,27 @@ private:
};
template <typename T>
class AutoCleanLinkedList : public LinkedList<T>
{
public:
~AutoCleanLinkedList()
{
+ clear();
+ }
+
+ AutoCleanLinkedList& operator=(AutoCleanLinkedList&& aOther)
+ {
+ LinkedList<T>::operator=(Forward<LinkedList<T>>(aOther));
+ return *this;
+ }
+
+ void clear()
+ {
while (T* element = this->popFirst()) {
delete element;
}
}
};
} /* namespace mozilla */