[libc-commits] [PATCH] D118954: [libc] add a vector internal class

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Feb 9 11:44:15 PST 2022


sivachandra added inline comments.


================
Comment at: libc/src/__support/CPP/vector.h:50
+  // undefined.
+  constexpr void resize(size_t new_size) {
+    if (new_size >= array_size)
----------------
I still don't understand the argument for having a resize method. Also, it is not inserting any elements for a size increase. So, it is different from `std::vector` behavior.


================
Comment at: libc/src/__support/CPP/vector.h:65
+    if (pos >= num_elements)
+      num_elements = pos + 1;
+    return data_array[pos];
----------------
I don't think is still correct. For one, `std::vector::operator[]` does not insert a new element.


================
Comment at: libc/src/__support/CPP/vector.h:90
+      if (temp_size == 0)
+        ++temp_size;
+      while (temp_size <= new_size)
----------------
Nit: `temp_size = 1`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118954/new/

https://reviews.llvm.org/D118954



More information about the libc-commits mailing list