Sfoglia il codice sorgente

fix(vector): does nothing if size() == n

greatbridf 1 anno fa
parent
commit
94d7406520
1 ha cambiato i file con 3 aggiunte e 0 eliminazioni
  1. 3 0
      include/types/vector.hpp

+ 3 - 0
include/types/vector.hpp

@@ -173,6 +173,9 @@ public:
 
     constexpr void resize(size_type n)
     {
+        if (m_size == n)
+            return;
+
         value_type* new_ptr = allocator_traits<allocator_type>::allocate(n);
         assert(!n || (n && new_ptr));