Selaa lähdekoodia

AK: Fix erroneous move operators for SinglyLinkedList

This patch provides a proper implementation of the move operator and
delete the move assignment operator.

Those operators were introduced in #11888
Lucas CHOLLET 3 vuotta sitten
vanhempi
commit
b0d51a6f36
1 muutettua tiedostoa jossa 8 lisäystä ja 2 poistoa
  1. 8 2
      AK/SinglyLinkedList.h

+ 8 - 2
AK/SinglyLinkedList.h

@@ -81,9 +81,15 @@ private:
 public:
 public:
     SinglyLinkedList() = default;
     SinglyLinkedList() = default;
     SinglyLinkedList(const SinglyLinkedList& other) = delete;
     SinglyLinkedList(const SinglyLinkedList& other) = delete;
-    SinglyLinkedList(SinglyLinkedList&&) = default;
+    SinglyLinkedList(SinglyLinkedList&& other)
+        : m_head(other.m_head)
+        , m_tail(other.m_tail)
+    {
+        other.m_head = nullptr;
+        other.m_tail = nullptr;
+    }
     SinglyLinkedList& operator=(const SinglyLinkedList& other) = delete;
     SinglyLinkedList& operator=(const SinglyLinkedList& other) = delete;
-    SinglyLinkedList& operator=(SinglyLinkedList&&) = default;
+    SinglyLinkedList& operator=(SinglyLinkedList&&) = delete;
 
 
     ~SinglyLinkedList() { clear(); }
     ~SinglyLinkedList() { clear(); }