30#define _GLIBCXX_ARRAY 1
32#pragma GCC system_header
34#if __cplusplus < 201103L
48#define __glibcxx_want_array_constexpr
49#define __glibcxx_want_freestanding_array
50#define __glibcxx_want_nonmember_container_access
51#define __glibcxx_want_to_array
54namespace std _GLIBCXX_VISIBILITY(default)
56_GLIBCXX_BEGIN_NAMESPACE_VERSION
58 template<
typename _Tp,
size_t _Nm>
61 using _Type = _Tp[_Nm];
62 using _Is_swappable = __is_swappable<_Tp>;
63 using _Is_nothrow_swappable = __is_nothrow_swappable<_Tp>;
66 template<
typename _Tp>
67 struct __array_traits<_Tp, 0>
73 __attribute__((__always_inline__,__noreturn__))
74 _Tp& operator[](
size_t)
const noexcept { __builtin_trap(); }
77 __attribute__((__always_inline__))
78 constexpr explicit operator _Tp*()
const noexcept {
return nullptr; }
99 template<
typename _Tp, std::
size_t _Nm>
102 typedef _Tp value_type;
103 typedef value_type* pointer;
104 typedef const value_type* const_pointer;
105 typedef value_type& reference;
106 typedef const value_type& const_reference;
107 typedef value_type* iterator;
108 typedef const value_type* const_iterator;
109 typedef std::size_t size_type;
110 typedef std::ptrdiff_t difference_type;
115 typename __array_traits<_Tp, _Nm>::_Type _M_elems;
120 _GLIBCXX20_CONSTEXPR
void
121 fill(
const value_type& __u)
122 { std::fill_n(begin(), size(), __u); }
124 _GLIBCXX20_CONSTEXPR
void
126 noexcept(__array_traits<_Tp, _Nm>::_Is_nothrow_swappable::value)
127 { std::swap_ranges(begin(), end(), __other.begin()); }
130 [[__gnu__::__const__, __nodiscard__]]
131 _GLIBCXX17_CONSTEXPR iterator
133 {
return iterator(data()); }
136 _GLIBCXX17_CONSTEXPR const_iterator
137 begin()
const noexcept
138 {
return const_iterator(data()); }
140 [[__gnu__::__const__, __nodiscard__]]
141 _GLIBCXX17_CONSTEXPR iterator
143 {
return iterator(data() + _Nm); }
146 _GLIBCXX17_CONSTEXPR const_iterator
148 {
return const_iterator(data() + _Nm); }
150 [[__gnu__::__const__, __nodiscard__]]
157 rbegin()
const noexcept
160 [[__gnu__::__const__, __nodiscard__]]
167 rend()
const noexcept
171 _GLIBCXX17_CONSTEXPR const_iterator
172 cbegin()
const noexcept
173 {
return const_iterator(data()); }
176 _GLIBCXX17_CONSTEXPR const_iterator
177 cend()
const noexcept
178 {
return const_iterator(data() + _Nm); }
182 crbegin()
const noexcept
187 crend()
const noexcept
191 [[__nodiscard__, __gnu__::__const__, __gnu__::__always_inline__]]
193 size()
const noexcept {
return _Nm; }
195 [[__nodiscard__, __gnu__::__const__, __gnu__::__always_inline__]]
197 max_size()
const noexcept {
return _Nm; }
199 [[__nodiscard__, __gnu__::__const__, __gnu__::__always_inline__]]
201 empty()
const noexcept {
return size() == 0; }
205 _GLIBCXX17_CONSTEXPR reference
206 operator[](size_type __n)
noexcept
208 __glibcxx_requires_subscript(__n);
209 return _M_elems[__n];
213 constexpr const_reference
214 operator[](size_type __n)
const noexcept
216#if __cplusplus >= 201402L
217 __glibcxx_requires_subscript(__n);
219 return _M_elems[__n];
222 _GLIBCXX17_CONSTEXPR reference
226 std::__throw_out_of_range_fmt(__N(
"array::at: __n (which is %zu) "
227 ">= _Nm (which is %zu)"),
229 return _M_elems[__n];
232 constexpr const_reference
233 at(size_type __n)
const
237 return __n < _Nm ? _M_elems[__n]
238 : (std::__throw_out_of_range_fmt(__N(
"array::at: __n (which is %zu) "
239 ">= _Nm (which is %zu)"),
245 _GLIBCXX17_CONSTEXPR reference
248 __glibcxx_requires_nonempty();
249 return _M_elems[(size_type)0];
253 constexpr const_reference
254 front()
const noexcept
256#if __cplusplus >= 201402L
257 __glibcxx_requires_nonempty();
259 return _M_elems[(size_type)0];
263 _GLIBCXX17_CONSTEXPR reference
266 __glibcxx_requires_nonempty();
267 return _M_elems[_Nm - 1];
271 constexpr const_reference
272 back()
const noexcept
274#if __cplusplus >= 201402L
275 __glibcxx_requires_nonempty();
277 return _M_elems[_Nm - 1];
280 [[__nodiscard__, __gnu__::__const__, __gnu__::__always_inline__]]
281 _GLIBCXX17_CONSTEXPR pointer
283 {
return static_cast<pointer
>(_M_elems); }
286 _GLIBCXX17_CONSTEXPR const_pointer
287 data()
const noexcept
288 {
return static_cast<const_pointer
>(_M_elems); }
291#if __cpp_deduction_guides >= 201606
292 template<
typename _Tp,
typename... _Up>
299 template<
typename _Tp, std::
size_t _Nm>
304 {
return std::equal(__one.begin(), __one.end(), __two.begin()); }
306#if __cpp_lib_three_way_comparison
307 template<
typename _Tp,
size_t _Nm>
309 constexpr __detail::__synth3way_t<_Tp>
310 operator<=>(
const array<_Tp, _Nm>& __a,
const array<_Tp, _Nm>& __b)
312 if constexpr (_Nm && __is_memcmp_ordered<_Tp>::__value)
313 if (!std::__is_constant_evaluated())
315 constexpr size_t __n = _Nm *
sizeof(_Tp);
316 return __builtin_memcmp(__a.data(), __b.data(), __n) <=> 0;
319 for (
size_t __i = 0; __i < _Nm; ++__i)
321 auto __c = __detail::__synth3way(__a[__i], __b[__i]);
325 return strong_ordering::equal;
328 template<
typename _Tp, std::
size_t _Nm>
332 operator!=(
const array<_Tp, _Nm>& __one,
const array<_Tp, _Nm>& __two)
333 {
return !(__one == __two); }
335 template<
typename _Tp, std::
size_t _Nm>
339 operator<(
const array<_Tp, _Nm>& __a,
const array<_Tp, _Nm>& __b)
341 return std::lexicographical_compare(__a.begin(), __a.end(),
342 __b.begin(), __b.end());
345 template<
typename _Tp, std::
size_t _Nm>
349 operator>(
const array<_Tp, _Nm>& __one,
const array<_Tp, _Nm>& __two)
350 {
return __two < __one; }
352 template<
typename _Tp, std::
size_t _Nm>
356 operator<=(
const array<_Tp, _Nm>& __one,
const array<_Tp, _Nm>& __two)
357 {
return !(__one > __two); }
359 template<
typename _Tp, std::
size_t _Nm>
363 operator>=(
const array<_Tp, _Nm>& __one,
const array<_Tp, _Nm>& __two)
364 {
return !(__one < __two); }
368 template<
typename _Tp, std::
size_t _Nm>
371#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
373 __enable_if_t<__array_traits<_Tp, _Nm>::_Is_swappable::value>
377 swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
378 noexcept(
noexcept(__one.swap(__two)))
379 { __one.swap(__two); }
381#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
382 template<
typename _Tp, std::
size_t _Nm>
383 __enable_if_t<!__array_traits<_Tp, _Nm>::_Is_swappable::value>
384 swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&) =
delete;
387 template<std::
size_t _Int,
typename _Tp, std::
size_t _Nm>
390 get(array<_Tp, _Nm>& __arr)
noexcept
392 static_assert(_Int < _Nm,
"array index is within bounds");
393 return __arr._M_elems[_Int];
396 template<std::
size_t _Int,
typename _Tp, std::
size_t _Nm>
399 get(array<_Tp, _Nm>&& __arr)
noexcept
401 static_assert(_Int < _Nm,
"array index is within bounds");
405 template<std::
size_t _Int,
typename _Tp, std::
size_t _Nm>
408 get(
const array<_Tp, _Nm>& __arr)
noexcept
410 static_assert(_Int < _Nm,
"array index is within bounds");
411 return __arr._M_elems[_Int];
414 template<std::
size_t _Int,
typename _Tp, std::
size_t _Nm>
416 constexpr const _Tp&&
417 get(
const array<_Tp, _Nm>&& __arr)
noexcept
419 static_assert(_Int < _Nm,
"array index is within bounds");
423#ifdef __cpp_lib_to_array
424 template<
typename _Tp,
size_t _Nm>
426 constexpr array<remove_cv_t<_Tp>, _Nm>
428 noexcept(is_nothrow_constructible_v<_Tp, _Tp&>)
430 static_assert(!is_array_v<_Tp>);
431 static_assert(is_constructible_v<_Tp, _Tp&>);
432 if constexpr (is_constructible_v<_Tp, _Tp&>)
434 if constexpr (is_trivially_copyable_v<_Tp>
435 && is_trivially_default_constructible_v<_Tp>
436 && is_copy_assignable_v<_Tp>)
438 array<remove_cv_t<_Tp>, _Nm> __arr;
439 if (!__is_constant_evaluated() && _Nm != 0)
440 __builtin_memcpy((
void*)__arr.data(), (
void*)__a,
sizeof(__a));
442 for (
size_t __i = 0; __i < _Nm; ++__i)
443 __arr._M_elems[__i] = __a[__i];
448 return array<remove_cv_t<_Tp>, _Nm>{{ __a[_Idx]... }};
449 }(make_index_sequence<_Nm>{});
452 __builtin_unreachable();
455 template<
typename _Tp,
size_t _Nm>
457 constexpr array<remove_cv_t<_Tp>, _Nm>
459 noexcept(is_nothrow_move_constructible_v<_Tp>)
461 static_assert(!is_array_v<_Tp>);
462 static_assert(is_move_constructible_v<_Tp>);
463 if constexpr (is_move_constructible_v<_Tp>)
465 if constexpr (is_trivially_copyable_v<_Tp>
466 && is_trivially_default_constructible_v<_Tp>
467 && is_copy_assignable_v<_Tp>)
469 array<remove_cv_t<_Tp>, _Nm> __arr;
470 if (!__is_constant_evaluated() && _Nm != 0)
471 __builtin_memcpy((
void*)__arr.data(), (
void*)__a,
sizeof(__a));
473 for (
size_t __i = 0; __i < _Nm; ++__i)
474 __arr._M_elems[__i] = __a[__i];
479 return array<remove_cv_t<_Tp>, _Nm>{{
std::move(__a[_Idx])... }};
480 }(make_index_sequence<_Nm>{});
483 __builtin_unreachable();
490 template<
typename _Tp,
size_t _Nm>
495 template<
size_t _Ind,
typename _Tp,
size_t _Nm>
498 static_assert(_Ind < _Nm,
"array index is in range");
502#if __cplusplus >= 201703L
503 template<
typename _Tp,
size_t _Nm>
504 inline constexpr size_t tuple_size_v<array<_Tp, _Nm>> = _Nm;
506 template<
typename _Tp,
size_t _Nm>
507 inline constexpr size_t tuple_size_v<const array<_Tp, _Nm>> = _Nm;
510 template<
typename _Tp,
size_t _Nm>
514_GLIBCXX_END_NAMESPACE_VERSION
constexpr bool operator<=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator<(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr array< remove_cv_t< _Tp >, _Nm > to_array(_Tp(&__a)[_Nm]) noexcept(is_nothrow_constructible< remove_cv_t< _Tp >, _Tp & >::value)
Create a std::array from an array.
ISO C++ entities toplevel namespace is std.
integer_sequence< size_t, _Idx... > index_sequence
Alias template index_sequence.
A standard container for storing a fixed size sequence of elements.
Finds the size of a given tuple type.
Gives the type of the ith element of a given tuple type.