[libc-commits] [libc] [libc] Add front() and erase() to FixedVector (PR #213866)

via libc-commits libc-commits at lists.llvm.org
Tue Aug 4 10:56:00 PDT 2026


================
@@ -75,6 +85,14 @@ template <typename T, size_t CAPACITY> class FixedVector {
     return true;
   }
 
+  LIBC_INLINE constexpr iterator erase(iterator pos) {
+    LIBC_ASSERT(pos >= begin() && pos < end());
+    for (iterator it = pos; it + 1 != end(); ++it)
+      *it = *(it + 1);
----------------
PiJoules wrote:

I think if we want FixedVector methods to match semantics of the std::vector methods then this should probably use `std::move`.

Also I think as it stands now I think `pop_back` technically is incorrect since it it should invoke the dtor for the underlying object, so there could be some bugs if a FixedVector element has a dtor that wouldn't be invoked. This doesn't have to be done here but something to keep note of.

https://github.com/llvm/llvm-project/pull/213866


More information about the libc-commits mailing list