[libcxx-commits] [libcxx] d067062 - [libc++] fix `array<T, 0>` under `USE_WRAP_ITER` (#101156)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 30 11:24:14 PDT 2024
Author: nicole mazzuca
Date: 2024-07-30T11:24:11-07:00
New Revision: d067062a42b0ce591f03c15cb76fe0fb27d1d9c1
URL: https://github.com/llvm/llvm-project/commit/d067062a42b0ce591f03c15cb76fe0fb27d1d9c1
DIFF: https://github.com/llvm/llvm-project/commit/d067062a42b0ce591f03c15cb76fe0fb27d1d9c1.diff
LOG: [libc++] fix `array<T, 0>` under `USE_WRAP_ITER` (#101156)
`array<T, 0>::iterator` was always a pointer even when
`_LIBCXX_ABI_USE_WRAP_ITER_IN_STD_ARRAY` was defined. This patch fixes
that minor bug.
Discovered as part of [#100603][].
Drive-by: switch from `typedef` to `using` in `<array>`
[#100603]: https://github.com/llvm/llvm-project/pull/100603
Added:
Modified:
libcxx/include/array
Removed:
################################################################################
diff --git a/libcxx/include/array b/libcxx/include/array
index 6ffde852f4802..4db0cb7bd7e3b 100644
--- a/libcxx/include/array
+++ b/libcxx/include/array
@@ -19,17 +19,17 @@ template <class T, size_t N >
struct array
{
// types:
- typedef T & reference;
- typedef const T & const_reference;
- typedef implementation defined iterator;
- typedef implementation defined const_iterator;
- typedef size_t size_type;
- typedef ptr
diff _t
diff erence_type;
- typedef T value_type;
- typedef T* pointer;
- typedef const T* const_pointer;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ using value_type = T;
+ using pointer = T*;
+ using const_pointer = const T*;
+ using reference = T&;
+ using const_reference = const T&;
+ using size_type = size_t;
+ using
diff erence_type = ptr
diff _t;
+ using iterator = implementation-defined;
+ using const_iterator = implementation-defined;
+ using reverse_iterator = std::reverse_iterator<iterator>;
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
// No explicit construct/copy/destroy for aggregate type
void fill(const T& u); // constexpr in C++20
@@ -270,20 +270,25 @@ 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 ptr
diff _t
diff erence_type;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-
- typedef __conditional_t<is_const<_Tp>::value, const __empty, __empty> _EmptyType;
+ 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
+ using size_type = size_t;
+ using
diff erence_type = ptr
diff _t;
+ using reverse_iterator = std::reverse_iterator<iterator>;
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
+
+ using _EmptyType = __conditional_t<is_const<_Tp>::value, const __empty, __empty>;
struct _ArrayInStructT {
_Tp __data_[1];
@@ -440,7 +445,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> > : public integral_con
template <size_t _Ip, class _Tp, size_t _Size>
struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> > {
static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
- typedef _Tp type;
+ using type = _Tp;
};
template <size_t _Ip, class _Tp, size_t _Size>
More information about the libcxx-commits
mailing list