Sfoglia il codice sorgente

feat(vector): add move assignment func.

greatbridf 2 anni fa
parent
commit
14c830a22c
1 ha cambiato i file con 12 aggiunte e 0 eliminazioni
  1. 12 0
      include/types/vector.hpp

+ 12 - 0
include/types/vector.hpp

@@ -140,6 +140,18 @@ public:
         arr.m_size = 0;
     }
 
+    vector& operator=(vector&& arr)
+    {
+        resize(0);
+        m_arr = arr.m_arr;
+        m_capacity = arr.m_capacity;
+        m_size = arr.m_size;
+
+        arr.m_arr = nullptr;
+        arr.m_capacity = 0;
+        arr.m_size = 0;
+    }
+
     ~vector() noexcept
     {
         resize(0);