[libcxx-commits] [libcxx] [libcxx][test] Do not assume array::iterator is a pointer (PR #100603)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jul 27 10:17:33 PDT 2024


================
@@ -270,18 +270,23 @@ struct _LIBCPP_TEMPLATE_VIS array {
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {
   // types:
-  typedef array __self;
-  typedef _Tp value_type;
-  typedef value_type& reference;
-  typedef const value_type& const_reference;
-  typedef value_type* iterator;
-  typedef const value_type* const_iterator;
-  typedef value_type* pointer;
-  typedef const value_type* const_pointer;
-  typedef size_t size_type;
-  typedef ptrdiff_t difference_type;
-  typedef std::reverse_iterator<iterator> reverse_iterator;
-  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+  using __self          = array;
+  using value_type      = _Tp;
+  using reference       = value_type&;
+  using const_reference = const value_type&;
+  using pointer         = value_type*;
+  using const_pointer   = const value_type*;
+#if defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY)
+  using iterator       = __wrap_iter<pointer>;
+  using const_iterator = __wrap_iter<const_pointer>;
+#else
+  using iterator       = pointer;
+  using const_iterator = const_pointer;
+#endif
----------------
philnik777 wrote:

Can we put this in a separate patch? Technically this could be ABI breaking, since we change the meaning of `_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY`. I'm pretty sure it's fine in this case, since we've only introduced this macro recently, but this is potentially API breaking for people (see this very patch). It's also not dependent on the rest of this patch or vice versa.

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


More information about the libcxx-commits mailing list