[libc-commits] [libc] [libc] Implement forward iterators (PR #93916)

via libc-commits libc-commits at lists.llvm.org
Fri May 31 06:19:44 PDT 2024


================
@@ -63,6 +63,10 @@ template <typename T, size_t CAPACITY> class FixedVector {
     return reverse_iterator{&store[item_count]};
   }
   LIBC_INLINE constexpr reverse_iterator rend() { return store.rend(); }
+
+  using iterator = typename cpp::array<T, CAPACITY>::iterator;
+  LIBC_INLINE constexpr iterator begin() { return store.begin(); }
+  LIBC_INLINE constexpr iterator end() { return iterator{&store[item_count]}; }
----------------
jameshu15869 wrote:

Would that account for the size of the objects themselves when doing the pointer arithmetic? i.e. if an int is 4 bytes and you have 4 elements would you want `end()` to be at `store.begin() + 4*4`?

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


More information about the libc-commits mailing list