Warning, /include/c++/v1/array is written in an unsupported language. File is not indexed.
0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009
0010 #ifndef _LIBCPP_ARRAY
0011 #define _LIBCPP_ARRAY
0012
0013 /*
0014 array synopsis
0015
0016 namespace std
0017 {
0018 template <class T, size_t N >
0019 struct array
0020 {
0021 // types:
0022 using value_type = T;
0023 using pointer = T*;
0024 using const_pointer = const T*;
0025 using reference = T&;
0026 using const_reference = const T&;
0027 using size_type = size_t;
0028 using difference_type = ptrdiff_t;
0029 using iterator = implementation-defined;
0030 using const_iterator = implementation-defined;
0031 using reverse_iterator = std::reverse_iterator<iterator>;
0032 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
0033
0034 // No explicit construct/copy/destroy for aggregate type
0035 void fill(const T& u); // constexpr in C++20
0036 void swap(array& a) noexcept(is_nothrow_swappable_v<T>); // constexpr in C++20
0037
0038 // iterators:
0039 iterator begin() noexcept; // constexpr in C++17
0040 const_iterator begin() const noexcept; // constexpr in C++17
0041 iterator end() noexcept; // constexpr in C++17
0042 const_iterator end() const noexcept; // constexpr in C++17
0043
0044 reverse_iterator rbegin() noexcept; // constexpr in C++17
0045 const_reverse_iterator rbegin() const noexcept; // constexpr in C++17
0046 reverse_iterator rend() noexcept; // constexpr in C++17
0047 const_reverse_iterator rend() const noexcept; // constexpr in C++17
0048
0049 const_iterator cbegin() const noexcept; // constexpr in C++17
0050 const_iterator cend() const noexcept; // constexpr in C++17
0051 const_reverse_iterator crbegin() const noexcept; // constexpr in C++17
0052 const_reverse_iterator crend() const noexcept; // constexpr in C++17
0053
0054 // capacity:
0055 constexpr size_type size() const noexcept;
0056 constexpr size_type max_size() const noexcept;
0057 constexpr bool empty() const noexcept;
0058
0059 // element access:
0060 reference operator[](size_type n); // constexpr in C++17
0061 const_reference operator[](size_type n) const; // constexpr in C++14
0062 reference at(size_type n); // constexpr in C++17
0063 const_reference at(size_type n) const; // constexpr in C++14
0064
0065 reference front(); // constexpr in C++17
0066 const_reference front() const; // constexpr in C++14
0067 reference back(); // constexpr in C++17
0068 const_reference back() const; // constexpr in C++14
0069
0070 T* data() noexcept; // constexpr in C++17
0071 const T* data() const noexcept; // constexpr in C++17
0072 };
0073
0074 template <class T, class... U>
0075 array(T, U...) -> array<T, 1 + sizeof...(U)>; // C++17
0076
0077 template <class T, size_t N>
0078 bool operator==(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20
0079 template <class T, size_t N>
0080 bool operator!=(const array<T,N>& x, const array<T,N>& y); // removed in C++20
0081 template <class T, size_t N>
0082 bool operator<(const array<T,N>& x, const array<T,N>& y); // removed in C++20
0083 template <class T, size_t N>
0084 bool operator>(const array<T,N>& x, const array<T,N>& y); // removed in C++20
0085 template <class T, size_t N>
0086 bool operator<=(const array<T,N>& x, const array<T,N>& y); // removed in C++20
0087 template <class T, size_t N>
0088 bool operator>=(const array<T,N>& x, const array<T,N>& y); // removed in C++20
0089 template<class T, size_t N>
0090 constexpr synth-three-way-result<T>
0091 operator<=>(const array<T, N>& x, const array<T, N>& y); // since C++20
0092
0093 template <class T, size_t N >
0094 void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // constexpr in C++20
0095
0096 template <class T, size_t N>
0097 constexpr array<remove_cv_t<T>, N> to_array(T (&a)[N]); // C++20
0098 template <class T, size_t N>
0099 constexpr array<remove_cv_t<T>, N> to_array(T (&&a)[N]); // C++20
0100
0101 template <class T> struct tuple_size;
0102 template <size_t I, class T> struct tuple_element;
0103 template <class T, size_t N> struct tuple_size<array<T, N>>;
0104 template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>;
0105 template <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
0106 template <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14
0107 template <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14
0108 template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14
0109
0110 } // std
0111
0112 */
0113
0114 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0115 # include <__cxx03/array>
0116 #else
0117 # include <__algorithm/equal.h>
0118 # include <__algorithm/fill_n.h>
0119 # include <__algorithm/lexicographical_compare.h>
0120 # include <__algorithm/lexicographical_compare_three_way.h>
0121 # include <__algorithm/swap_ranges.h>
0122 # include <__assert>
0123 # include <__config>
0124 # include <__cstddef/ptrdiff_t.h>
0125 # include <__fwd/array.h>
0126 # include <__iterator/reverse_iterator.h>
0127 # include <__iterator/static_bounded_iter.h>
0128 # include <__iterator/wrap_iter.h>
0129 # include <__tuple/sfinae_helpers.h>
0130 # include <__type_traits/conditional.h>
0131 # include <__type_traits/conjunction.h>
0132 # include <__type_traits/enable_if.h>
0133 # include <__type_traits/is_array.h>
0134 # include <__type_traits/is_const.h>
0135 # include <__type_traits/is_constructible.h>
0136 # include <__type_traits/is_nothrow_constructible.h>
0137 # include <__type_traits/is_same.h>
0138 # include <__type_traits/is_swappable.h>
0139 # include <__type_traits/is_trivially_relocatable.h>
0140 # include <__type_traits/remove_cv.h>
0141 # include <__utility/empty.h>
0142 # include <__utility/integer_sequence.h>
0143 # include <__utility/move.h>
0144 # include <__utility/unreachable.h>
0145 # include <stdexcept>
0146 # include <version>
0147
0148 // standard-mandated includes
0149
0150 // [iterator.range]
0151 # include <__iterator/access.h>
0152 # include <__iterator/data.h>
0153 # include <__iterator/empty.h>
0154 # include <__iterator/reverse_access.h>
0155 # include <__iterator/size.h>
0156
0157 // [array.syn]
0158 # include <compare>
0159 # include <initializer_list>
0160
0161 // [tuple.helper]
0162 # include <__tuple/tuple_element.h>
0163 # include <__tuple/tuple_size.h>
0164
0165 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0166 # pragma GCC system_header
0167 # endif
0168
0169 _LIBCPP_PUSH_MACROS
0170 # include <__undef_macros>
0171
0172 _LIBCPP_BEGIN_NAMESPACE_STD
0173
0174 template <class _Tp, size_t _Size>
0175 struct _LIBCPP_TEMPLATE_VIS array {
0176 using __trivially_relocatable _LIBCPP_NODEBUG =
0177 __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>;
0178
0179 // types:
0180 using __self _LIBCPP_NODEBUG = array;
0181 using value_type = _Tp;
0182 using reference = value_type&;
0183 using const_reference = const value_type&;
0184 using pointer = value_type*;
0185 using const_pointer = const value_type*;
0186 # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
0187 using iterator = __static_bounded_iter<pointer, _Size>;
0188 using const_iterator = __static_bounded_iter<const_pointer, _Size>;
0189 # elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY)
0190 using iterator = __wrap_iter<pointer>;
0191 using const_iterator = __wrap_iter<const_pointer>;
0192 # else
0193 using iterator = pointer;
0194 using const_iterator = const_pointer;
0195 # endif
0196 using size_type = size_t;
0197 using difference_type = ptrdiff_t;
0198 using reverse_iterator = std::reverse_iterator<iterator>;
0199 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
0200
0201 _Tp __elems_[_Size];
0202
0203 // No explicit construct/copy/destroy for aggregate type
0204 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void fill(const value_type& __u) {
0205 std::fill_n(data(), _Size, __u);
0206 }
0207
0208 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable_v<_Tp>) {
0209 std::swap_ranges(data(), data() + _Size, __a.data());
0210 }
0211
0212 // iterators:
0213 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT {
0214 # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
0215 return std::__make_static_bounded_iter<_Size>(data(), data());
0216 # else
0217 return iterator(data());
0218 # endif
0219 }
0220 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT {
0221 # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
0222 return std::__make_static_bounded_iter<_Size>(data(), data());
0223 # else
0224 return const_iterator(data());
0225 # endif
0226 }
0227 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT {
0228 # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
0229 return std::__make_static_bounded_iter<_Size>(data() + _Size, data());
0230 # else
0231 return iterator(data() + _Size);
0232 # endif
0233 }
0234 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT {
0235 # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
0236 return std::__make_static_bounded_iter<_Size>(data() + _Size, data());
0237 # else
0238 return const_iterator(data() + _Size);
0239 # endif
0240 }
0241
0242 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT {
0243 return reverse_iterator(end());
0244 }
0245 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rbegin() const _NOEXCEPT {
0246 return const_reverse_iterator(end());
0247 }
0248 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rend() _NOEXCEPT {
0249 return reverse_iterator(begin());
0250 }
0251 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rend() const _NOEXCEPT {
0252 return const_reverse_iterator(begin());
0253 }
0254
0255 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cbegin() const _NOEXCEPT { return begin(); }
0256 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cend() const _NOEXCEPT { return end(); }
0257 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crbegin() const _NOEXCEPT {
0258 return rbegin();
0259 }
0260 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
0261
0262 // capacity:
0263 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return _Size; }
0264 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return _Size; }
0265 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return _Size == 0; }
0266
0267 // element access:
0268 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type __n) _NOEXCEPT {
0269 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < _Size, "out-of-bounds access in std::array<T, N>");
0270 return __elems_[__n];
0271 }
0272 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference operator[](size_type __n) const _NOEXCEPT {
0273 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < _Size, "out-of-bounds access in std::array<T, N>");
0274 return __elems_[__n];
0275 }
0276
0277 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type __n) {
0278 if (__n >= _Size)
0279 __throw_out_of_range("array::at");
0280 return __elems_[__n];
0281 }
0282
0283 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type __n) const {
0284 if (__n >= _Size)
0285 __throw_out_of_range("array::at");
0286 return __elems_[__n];
0287 }
0288
0289 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference front() _NOEXCEPT { return (*this)[0]; }
0290 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference front() const _NOEXCEPT { return (*this)[0]; }
0291 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference back() _NOEXCEPT { return (*this)[_Size - 1]; }
0292 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference back() const _NOEXCEPT {
0293 return (*this)[_Size - 1];
0294 }
0295
0296 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 value_type* data() _NOEXCEPT { return __elems_; }
0297 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const value_type* data() const _NOEXCEPT { return __elems_; }
0298 };
0299
0300 template <class _Tp>
0301 struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {
0302 // types:
0303 using __self _LIBCPP_NODEBUG = array;
0304 using value_type = _Tp;
0305 using reference = value_type&;
0306 using const_reference = const value_type&;
0307 using pointer = value_type*;
0308 using const_pointer = const value_type*;
0309 # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
0310 using iterator = __static_bounded_iter<pointer, 0>;
0311 using const_iterator = __static_bounded_iter<const_pointer, 0>;
0312 # elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY)
0313 using iterator = __wrap_iter<pointer>;
0314 using const_iterator = __wrap_iter<const_pointer>;
0315 # else
0316 using iterator = pointer;
0317 using const_iterator = const_pointer;
0318 # endif
0319 using size_type = size_t;
0320 using difference_type = ptrdiff_t;
0321 using reverse_iterator = std::reverse_iterator<iterator>;
0322 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
0323
0324 using _EmptyType _LIBCPP_NODEBUG = __conditional_t<is_const<_Tp>::value, const __empty, __empty>;
0325
0326 struct _ArrayInStructT {
0327 _Tp __data_[1];
0328 };
0329 _ALIGNAS_TYPE(_ArrayInStructT) _EmptyType __elems_[sizeof(_ArrayInStructT)];
0330
0331 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 value_type* data() _NOEXCEPT { return nullptr; }
0332 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const value_type* data() const _NOEXCEPT { return nullptr; }
0333
0334 // No explicit construct/copy/destroy for aggregate type
0335 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void fill(const value_type&) {
0336 static_assert(!is_const<_Tp>::value, "cannot fill zero-sized array of type 'const T'");
0337 }
0338
0339 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array&) _NOEXCEPT {
0340 static_assert(!is_const<_Tp>::value, "cannot swap zero-sized array of type 'const T'");
0341 }
0342
0343 // iterators:
0344 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT {
0345 # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
0346 return std::__make_static_bounded_iter<0>(data(), data());
0347 # else
0348 return iterator(data());
0349 # endif
0350 }
0351 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT {
0352 # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
0353 return std::__make_static_bounded_iter<0>(data(), data());
0354 # else
0355 return const_iterator(data());
0356 # endif
0357 }
0358 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT {
0359 # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
0360 return std::__make_static_bounded_iter<0>(data(), data());
0361 # else
0362 return iterator(data());
0363 # endif
0364 }
0365 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT {
0366 # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
0367 return std::__make_static_bounded_iter<0>(data(), data());
0368 # else
0369 return const_iterator(data());
0370 # endif
0371 }
0372
0373 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT {
0374 return reverse_iterator(end());
0375 }
0376 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rbegin() const _NOEXCEPT {
0377 return const_reverse_iterator(end());
0378 }
0379 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rend() _NOEXCEPT {
0380 return reverse_iterator(begin());
0381 }
0382 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rend() const _NOEXCEPT {
0383 return const_reverse_iterator(begin());
0384 }
0385
0386 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cbegin() const _NOEXCEPT { return begin(); }
0387 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cend() const _NOEXCEPT { return end(); }
0388 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crbegin() const _NOEXCEPT {
0389 return rbegin();
0390 }
0391 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
0392
0393 // capacity:
0394 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return 0; }
0395 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return 0; }
0396 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; }
0397
0398 // element access:
0399 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type) _NOEXCEPT {
0400 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
0401 __libcpp_unreachable();
0402 }
0403
0404 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference operator[](size_type) const _NOEXCEPT {
0405 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
0406 __libcpp_unreachable();
0407 }
0408
0409 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type) {
0410 __throw_out_of_range("array<T, 0>::at");
0411 __libcpp_unreachable();
0412 }
0413
0414 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type) const {
0415 __throw_out_of_range("array<T, 0>::at");
0416 __libcpp_unreachable();
0417 }
0418
0419 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference front() _NOEXCEPT {
0420 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::front() on a zero-sized array");
0421 __libcpp_unreachable();
0422 }
0423
0424 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference front() const _NOEXCEPT {
0425 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::front() on a zero-sized array");
0426 __libcpp_unreachable();
0427 }
0428
0429 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference back() _NOEXCEPT {
0430 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::back() on a zero-sized array");
0431 __libcpp_unreachable();
0432 }
0433
0434 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference back() const _NOEXCEPT {
0435 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::back() on a zero-sized array");
0436 __libcpp_unreachable();
0437 }
0438 };
0439
0440 # if _LIBCPP_STD_VER >= 17
0441 template <class _Tp, class... _Args, class = enable_if_t<__all<_IsSame<_Tp, _Args>::value...>::value> >
0442 array(_Tp, _Args...) -> array<_Tp, 1 + sizeof...(_Args)>;
0443 # endif
0444
0445 template <class _Tp, size_t _Size>
0446 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
0447 operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0448 return std::equal(__x.begin(), __x.end(), __y.begin());
0449 }
0450
0451 # if _LIBCPP_STD_VER <= 17
0452
0453 template <class _Tp, size_t _Size>
0454 inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0455 return !(__x == __y);
0456 }
0457
0458 template <class _Tp, size_t _Size>
0459 inline _LIBCPP_HIDE_FROM_ABI bool operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0460 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
0461 }
0462
0463 template <class _Tp, size_t _Size>
0464 inline _LIBCPP_HIDE_FROM_ABI bool operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0465 return __y < __x;
0466 }
0467
0468 template <class _Tp, size_t _Size>
0469 inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0470 return !(__y < __x);
0471 }
0472
0473 template <class _Tp, size_t _Size>
0474 inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0475 return !(__x < __y);
0476 }
0477
0478 # else // _LIBCPP_STD_VER <= 17
0479
0480 template <class _Tp, size_t _Size>
0481 _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
0482 operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0483 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
0484 }
0485
0486 # endif // _LIBCPP_STD_VER <= 17
0487
0488 template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable_v<_Tp>, int> = 0>
0489 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
0490 _NOEXCEPT_(noexcept(__x.swap(__y))) {
0491 __x.swap(__y);
0492 }
0493
0494 template <class _Tp, size_t _Size>
0495 struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> > : public integral_constant<size_t, _Size> {};
0496
0497 template <size_t _Ip, class _Tp, size_t _Size>
0498 struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> > {
0499 static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
0500 using type = _Tp;
0501 };
0502
0503 template <size_t _Ip, class _Tp, size_t _Size>
0504 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& get(array<_Tp, _Size>& __a) _NOEXCEPT {
0505 static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)");
0506 return __a.__elems_[_Ip];
0507 }
0508
0509 template <size_t _Ip, class _Tp, size_t _Size>
0510 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& get(const array<_Tp, _Size>& __a) _NOEXCEPT {
0511 static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)");
0512 return __a.__elems_[_Ip];
0513 }
0514
0515 template <size_t _Ip, class _Tp, size_t _Size>
0516 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp&& get(array<_Tp, _Size>&& __a) _NOEXCEPT {
0517 static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)");
0518 return std::move(__a.__elems_[_Ip]);
0519 }
0520
0521 template <size_t _Ip, class _Tp, size_t _Size>
0522 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&& __a) _NOEXCEPT {
0523 static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)");
0524 return std::move(__a.__elems_[_Ip]);
0525 }
0526
0527 # if _LIBCPP_STD_VER >= 20
0528
0529 template <typename _Tp, size_t _Size, size_t... _Index>
0530 _LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>
0531 __to_array_lvalue_impl(_Tp (&__arr)[_Size], index_sequence<_Index...>) {
0532 return {{__arr[_Index]...}};
0533 }
0534
0535 template <typename _Tp, size_t _Size, size_t... _Index>
0536 _LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>
0537 __to_array_rvalue_impl(_Tp (&&__arr)[_Size], index_sequence<_Index...>) {
0538 return {{std::move(__arr[_Index])...}};
0539 }
0540
0541 template <typename _Tp, size_t _Size>
0542 _LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>
0543 to_array(_Tp (&__arr)[_Size]) noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) {
0544 static_assert(!is_array_v<_Tp>, "[array.creation]/1: to_array does not accept multidimensional arrays.");
0545 static_assert(is_constructible_v<_Tp, _Tp&>, "[array.creation]/1: to_array requires copy constructible elements.");
0546 return std::__to_array_lvalue_impl(__arr, make_index_sequence<_Size>());
0547 }
0548
0549 template <typename _Tp, size_t _Size>
0550 _LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>
0551 to_array(_Tp (&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) {
0552 static_assert(!is_array_v<_Tp>, "[array.creation]/4: to_array does not accept multidimensional arrays.");
0553 static_assert(is_move_constructible_v<_Tp>, "[array.creation]/4: to_array requires move constructible elements.");
0554 return std::__to_array_rvalue_impl(std::move(__arr), make_index_sequence<_Size>());
0555 }
0556
0557 # endif // _LIBCPP_STD_VER >= 20
0558
0559 _LIBCPP_END_NAMESPACE_STD
0560
0561 _LIBCPP_POP_MACROS
0562
0563 # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
0564 # include <algorithm>
0565 # include <concepts>
0566 # include <cstdlib>
0567 # include <iterator>
0568 # include <new>
0569 # include <type_traits>
0570 # include <utility>
0571 # endif
0572 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0573
0574 #endif // _LIBCPP_ARRAY