[libcxx-commits] [libcxx] [libc++] Add support for bounded iterators in std::array (PR #110729)

Adrian Vogelsgesang via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 2 02:56:06 PDT 2024


================
@@ -176,6 +176,12 @@
 // ABI impact: changes the iterator type of `vector` (except `vector<bool>`).
 // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
 
+// Changes the iterator type of `array` to a bounded iterator that keeps track of whether it's within the bounds of the
+// container and asserts it on every dereference and when performing iterator arithmetic.
+//
+// ABI impact: changes the iterator type of `array`.
+// #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY
----------------
vogelsgesang wrote:

would it make sense to enable this setting by default under ABI v2?

By enabling this by default in ABI v2, users could control bounds checks for `std::array` iterators through `_LIBCPP_HARDENING_MODE`, without an additional ABI flag.

On the other hand, there is no negative runtime overhead of using the new bounded iterators, afaict, and the only thing that changes is the ABI name of the iterator?

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


More information about the libcxx-commits mailing list