Warning, /include/c++/v1/__cxx03/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___CXX03_ARRAY
0011 #define _LIBCPP___CXX03_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 typedef T & reference;
0023 typedef const T & const_reference;
0024 typedef implementation defined iterator;
0025 typedef implementation defined const_iterator;
0026 typedef size_t size_type;
0027 typedef ptrdiff_t difference_type;
0028 typedef T value_type;
0029 typedef T* pointer;
0030 typedef const T* const_pointer;
0031 typedef std::reverse_iterator<iterator> reverse_iterator;
0032 typedef std::reverse_iterator<const_iterator> const_reverse_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 #include <__cxx03/__algorithm/equal.h>
0115 #include <__cxx03/__algorithm/fill_n.h>
0116 #include <__cxx03/__algorithm/lexicographical_compare.h>
0117 #include <__cxx03/__algorithm/lexicographical_compare_three_way.h>
0118 #include <__cxx03/__algorithm/swap_ranges.h>
0119 #include <__cxx03/__assert>
0120 #include <__cxx03/__config>
0121 #include <__cxx03/__fwd/array.h>
0122 #include <__cxx03/__iterator/reverse_iterator.h>
0123 #include <__cxx03/__iterator/wrap_iter.h>
0124 #include <__cxx03/__tuple/sfinae_helpers.h>
0125 #include <__cxx03/__type_traits/conditional.h>
0126 #include <__cxx03/__type_traits/conjunction.h>
0127 #include <__cxx03/__type_traits/is_array.h>
0128 #include <__cxx03/__type_traits/is_const.h>
0129 #include <__cxx03/__type_traits/is_constructible.h>
0130 #include <__cxx03/__type_traits/is_nothrow_constructible.h>
0131 #include <__cxx03/__type_traits/is_same.h>
0132 #include <__cxx03/__type_traits/is_swappable.h>
0133 #include <__cxx03/__type_traits/is_trivially_relocatable.h>
0134 #include <__cxx03/__type_traits/remove_cv.h>
0135 #include <__cxx03/__utility/empty.h>
0136 #include <__cxx03/__utility/integer_sequence.h>
0137 #include <__cxx03/__utility/move.h>
0138 #include <__cxx03/__utility/unreachable.h>
0139 #include <__cxx03/stdexcept>
0140 #include <__cxx03/version>
0141
0142 // standard-mandated includes
0143
0144 // [iterator.range]
0145 #include <__cxx03/__iterator/access.h>
0146 #include <__cxx03/__iterator/data.h>
0147 #include <__cxx03/__iterator/empty.h>
0148 #include <__cxx03/__iterator/reverse_access.h>
0149 #include <__cxx03/__iterator/size.h>
0150
0151 // [array.syn]
0152 #include <__cxx03/compare>
0153 #include <__cxx03/initializer_list>
0154
0155 // [tuple.helper]
0156 #include <__cxx03/__tuple/tuple_element.h>
0157 #include <__cxx03/__tuple/tuple_size.h>
0158
0159 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0160 # pragma GCC system_header
0161 #endif
0162
0163 _LIBCPP_PUSH_MACROS
0164 #include <__cxx03/__undef_macros>
0165
0166 _LIBCPP_BEGIN_NAMESPACE_STD
0167
0168 template <class _Tp, size_t _Size>
0169 struct _LIBCPP_TEMPLATE_VIS array {
0170 using __trivially_relocatable = __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>;
0171
0172 // types:
0173 using __self = array;
0174 using value_type = _Tp;
0175 using reference = value_type&;
0176 using const_reference = const value_type&;
0177 using pointer = value_type*;
0178 using const_pointer = const value_type*;
0179 #if defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY)
0180 using iterator = __wrap_iter<pointer>;
0181 using const_iterator = __wrap_iter<const_pointer>;
0182 #else
0183 using iterator = pointer;
0184 using const_iterator = const_pointer;
0185 #endif
0186 using size_type = size_t;
0187 using difference_type = ptrdiff_t;
0188 using reverse_iterator = std::reverse_iterator<iterator>;
0189 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
0190
0191 _Tp __elems_[_Size];
0192
0193 // No explicit construct/copy/destroy for aggregate type
0194 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void fill(const value_type& __u) {
0195 std::fill_n(data(), _Size, __u);
0196 }
0197
0198 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable_v<_Tp>) {
0199 std::swap_ranges(data(), data() + _Size, __a.data());
0200 }
0201
0202 // iterators:
0203 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT { return iterator(data()); }
0204 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT {
0205 return const_iterator(data());
0206 }
0207 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT { return iterator(data() + _Size); }
0208 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT {
0209 return const_iterator(data() + _Size);
0210 }
0211
0212 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT {
0213 return reverse_iterator(end());
0214 }
0215 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rbegin() const _NOEXCEPT {
0216 return const_reverse_iterator(end());
0217 }
0218 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rend() _NOEXCEPT {
0219 return reverse_iterator(begin());
0220 }
0221 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rend() const _NOEXCEPT {
0222 return const_reverse_iterator(begin());
0223 }
0224
0225 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cbegin() const _NOEXCEPT { return begin(); }
0226 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cend() const _NOEXCEPT { return end(); }
0227 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crbegin() const _NOEXCEPT {
0228 return rbegin();
0229 }
0230 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
0231
0232 // capacity:
0233 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return _Size; }
0234 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return _Size; }
0235 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return _Size == 0; }
0236
0237 // element access:
0238 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type __n) _NOEXCEPT {
0239 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < _Size, "out-of-bounds access in std::array<T, N>");
0240 return __elems_[__n];
0241 }
0242 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference operator[](size_type __n) const _NOEXCEPT {
0243 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < _Size, "out-of-bounds access in std::array<T, N>");
0244 return __elems_[__n];
0245 }
0246
0247 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type __n) {
0248 if (__n >= _Size)
0249 __throw_out_of_range("array::at");
0250 return __elems_[__n];
0251 }
0252
0253 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type __n) const {
0254 if (__n >= _Size)
0255 __throw_out_of_range("array::at");
0256 return __elems_[__n];
0257 }
0258
0259 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference front() _NOEXCEPT { return (*this)[0]; }
0260 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference front() const _NOEXCEPT { return (*this)[0]; }
0261 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference back() _NOEXCEPT { return (*this)[_Size - 1]; }
0262 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference back() const _NOEXCEPT {
0263 return (*this)[_Size - 1];
0264 }
0265
0266 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 value_type* data() _NOEXCEPT { return __elems_; }
0267 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const value_type* data() const _NOEXCEPT { return __elems_; }
0268 };
0269
0270 template <class _Tp>
0271 struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {
0272 // types:
0273 typedef array __self;
0274 typedef _Tp value_type;
0275 typedef value_type& reference;
0276 typedef const value_type& const_reference;
0277 typedef value_type* iterator;
0278 typedef const value_type* const_iterator;
0279 typedef value_type* pointer;
0280 typedef const value_type* const_pointer;
0281 typedef size_t size_type;
0282 typedef ptrdiff_t difference_type;
0283 typedef std::reverse_iterator<iterator> reverse_iterator;
0284 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
0285
0286 typedef __conditional_t<is_const<_Tp>::value, const __empty, __empty> _EmptyType;
0287
0288 struct _ArrayInStructT {
0289 _Tp __data_[1];
0290 };
0291 _ALIGNAS_TYPE(_ArrayInStructT) _EmptyType __elems_[sizeof(_ArrayInStructT)];
0292
0293 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 value_type* data() _NOEXCEPT { return nullptr; }
0294 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const value_type* data() const _NOEXCEPT { return nullptr; }
0295
0296 // No explicit construct/copy/destroy for aggregate type
0297 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void fill(const value_type&) {
0298 static_assert(!is_const<_Tp>::value, "cannot fill zero-sized array of type 'const T'");
0299 }
0300
0301 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array&) _NOEXCEPT {
0302 static_assert(!is_const<_Tp>::value, "cannot swap zero-sized array of type 'const T'");
0303 }
0304
0305 // iterators:
0306 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT { return iterator(data()); }
0307 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT {
0308 return const_iterator(data());
0309 }
0310 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT { return iterator(data()); }
0311 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT {
0312 return const_iterator(data());
0313 }
0314
0315 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT {
0316 return reverse_iterator(end());
0317 }
0318 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rbegin() const _NOEXCEPT {
0319 return const_reverse_iterator(end());
0320 }
0321 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rend() _NOEXCEPT {
0322 return reverse_iterator(begin());
0323 }
0324 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rend() const _NOEXCEPT {
0325 return const_reverse_iterator(begin());
0326 }
0327
0328 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cbegin() const _NOEXCEPT { return begin(); }
0329 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cend() const _NOEXCEPT { return end(); }
0330 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crbegin() const _NOEXCEPT {
0331 return rbegin();
0332 }
0333 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
0334
0335 // capacity:
0336 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return 0; }
0337 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return 0; }
0338 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; }
0339
0340 // element access:
0341 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type) _NOEXCEPT {
0342 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
0343 __libcpp_unreachable();
0344 }
0345
0346 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference operator[](size_type) const _NOEXCEPT {
0347 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
0348 __libcpp_unreachable();
0349 }
0350
0351 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type) {
0352 __throw_out_of_range("array<T, 0>::at");
0353 __libcpp_unreachable();
0354 }
0355
0356 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type) const {
0357 __throw_out_of_range("array<T, 0>::at");
0358 __libcpp_unreachable();
0359 }
0360
0361 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference front() _NOEXCEPT {
0362 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::front() on a zero-sized array");
0363 __libcpp_unreachable();
0364 }
0365
0366 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference front() const _NOEXCEPT {
0367 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::front() on a zero-sized array");
0368 __libcpp_unreachable();
0369 }
0370
0371 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference back() _NOEXCEPT {
0372 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::back() on a zero-sized array");
0373 __libcpp_unreachable();
0374 }
0375
0376 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference back() const _NOEXCEPT {
0377 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::back() on a zero-sized array");
0378 __libcpp_unreachable();
0379 }
0380 };
0381
0382 #if _LIBCPP_STD_VER >= 17
0383 template <class _Tp, class... _Args, class = enable_if_t<__all<_IsSame<_Tp, _Args>::value...>::value> >
0384 array(_Tp, _Args...) -> array<_Tp, 1 + sizeof...(_Args)>;
0385 #endif
0386
0387 template <class _Tp, size_t _Size>
0388 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
0389 operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0390 return std::equal(__x.begin(), __x.end(), __y.begin());
0391 }
0392
0393 #if _LIBCPP_STD_VER <= 17
0394
0395 template <class _Tp, size_t _Size>
0396 inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0397 return !(__x == __y);
0398 }
0399
0400 template <class _Tp, size_t _Size>
0401 inline _LIBCPP_HIDE_FROM_ABI bool operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0402 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
0403 }
0404
0405 template <class _Tp, size_t _Size>
0406 inline _LIBCPP_HIDE_FROM_ABI bool operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0407 return __y < __x;
0408 }
0409
0410 template <class _Tp, size_t _Size>
0411 inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0412 return !(__y < __x);
0413 }
0414
0415 template <class _Tp, size_t _Size>
0416 inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0417 return !(__x < __y);
0418 }
0419
0420 #else // _LIBCPP_STD_VER <= 17
0421
0422 template <class _Tp, size_t _Size>
0423 _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
0424 operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
0425 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
0426 }
0427
0428 #endif // _LIBCPP_STD_VER <= 17
0429
0430 template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable_v<_Tp>, int> = 0>
0431 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
0432 _NOEXCEPT_(noexcept(__x.swap(__y))) {
0433 __x.swap(__y);
0434 }
0435
0436 template <class _Tp, size_t _Size>
0437 struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> > : public integral_constant<size_t, _Size> {};
0438
0439 template <size_t _Ip, class _Tp, size_t _Size>
0440 struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> > {
0441 static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
0442 typedef _Tp type;
0443 };
0444
0445 template <size_t _Ip, class _Tp, size_t _Size>
0446 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& get(array<_Tp, _Size>& __a) _NOEXCEPT {
0447 static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)");
0448 return __a.__elems_[_Ip];
0449 }
0450
0451 template <size_t _Ip, class _Tp, size_t _Size>
0452 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& get(const array<_Tp, _Size>& __a) _NOEXCEPT {
0453 static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)");
0454 return __a.__elems_[_Ip];
0455 }
0456
0457 template <size_t _Ip, class _Tp, size_t _Size>
0458 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp&& get(array<_Tp, _Size>&& __a) _NOEXCEPT {
0459 static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)");
0460 return std::move(__a.__elems_[_Ip]);
0461 }
0462
0463 template <size_t _Ip, class _Tp, size_t _Size>
0464 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&& __a) _NOEXCEPT {
0465 static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)");
0466 return std::move(__a.__elems_[_Ip]);
0467 }
0468
0469 #if _LIBCPP_STD_VER >= 20
0470
0471 template <typename _Tp, size_t _Size, size_t... _Index>
0472 _LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>
0473 __to_array_lvalue_impl(_Tp (&__arr)[_Size], index_sequence<_Index...>) {
0474 return {{__arr[_Index]...}};
0475 }
0476
0477 template <typename _Tp, size_t _Size, size_t... _Index>
0478 _LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>
0479 __to_array_rvalue_impl(_Tp (&&__arr)[_Size], index_sequence<_Index...>) {
0480 return {{std::move(__arr[_Index])...}};
0481 }
0482
0483 template <typename _Tp, size_t _Size>
0484 _LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>
0485 to_array(_Tp (&__arr)[_Size]) noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) {
0486 static_assert(!is_array_v<_Tp>, "[array.creation]/1: to_array does not accept multidimensional arrays.");
0487 static_assert(is_constructible_v<_Tp, _Tp&>, "[array.creation]/1: to_array requires copy constructible elements.");
0488 return std::__to_array_lvalue_impl(__arr, make_index_sequence<_Size>());
0489 }
0490
0491 template <typename _Tp, size_t _Size>
0492 _LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>
0493 to_array(_Tp (&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) {
0494 static_assert(!is_array_v<_Tp>, "[array.creation]/4: to_array does not accept multidimensional arrays.");
0495 static_assert(is_move_constructible_v<_Tp>, "[array.creation]/4: to_array requires move constructible elements.");
0496 return std::__to_array_rvalue_impl(std::move(__arr), make_index_sequence<_Size>());
0497 }
0498
0499 #endif // _LIBCPP_STD_VER >= 20
0500
0501 _LIBCPP_END_NAMESPACE_STD
0502
0503 _LIBCPP_POP_MACROS
0504
0505 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
0506 # include <__cxx03/algorithm>
0507 # include <__cxx03/concepts>
0508 # include <__cxx03/cstdlib>
0509 # include <__cxx03/iterator>
0510 # include <__cxx03/type_traits>
0511 # include <__cxx03/utility>
0512 #endif
0513
0514 #endif // _LIBCPP___CXX03_ARRAY