[libcxx-commits] [libcxx] [libc++] Add support for bounded iterators in std::array (PR #110729)
Konstantin Varlamov via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Oct 5 18:11:26 PDT 2024
================
@@ -309,13 +336,33 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {
}
// iterators:
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT { return iterator(data()); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT {
+#if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
+ return std::__make_static_bounded_iter<0>(data(), data());
----------------
var-const wrote:
This iterator is always invalid to dereference, right? Would specializing `static_bounded_iterator` to avoid storing the position altogether make any sense? (It can also unconditionally assert in dereference, although given that the size is static, perhaps the compiler should be able to figure it out on its own) I'm not sure it's worth doing (assuming it makes any difference), though, since it's presumably a very niche case.
https://github.com/llvm/llvm-project/pull/110729
More information about the libcxx-commits
mailing list