xref: /aosp_15_r20/external/libcxx/include/array (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===---------------------------- array -----------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_ARRAY
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_ARRAY
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker/*
15*58b9f456SAndroid Build Coastguard Worker    array synopsis
16*58b9f456SAndroid Build Coastguard Worker
17*58b9f456SAndroid Build Coastguard Workernamespace std
18*58b9f456SAndroid Build Coastguard Worker{
19*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N >
20*58b9f456SAndroid Build Coastguard Workerstruct array
21*58b9f456SAndroid Build Coastguard Worker{
22*58b9f456SAndroid Build Coastguard Worker    // types:
23*58b9f456SAndroid Build Coastguard Worker    typedef T & reference;
24*58b9f456SAndroid Build Coastguard Worker    typedef const T & const_reference;
25*58b9f456SAndroid Build Coastguard Worker    typedef implementation defined iterator;
26*58b9f456SAndroid Build Coastguard Worker    typedef implementation defined const_iterator;
27*58b9f456SAndroid Build Coastguard Worker    typedef size_t size_type;
28*58b9f456SAndroid Build Coastguard Worker    typedef ptrdiff_t difference_type;
29*58b9f456SAndroid Build Coastguard Worker    typedef T value_type;
30*58b9f456SAndroid Build Coastguard Worker    typedef T* pointer;
31*58b9f456SAndroid Build Coastguard Worker    typedef const T* const_pointer;
32*58b9f456SAndroid Build Coastguard Worker    typedef std::reverse_iterator<iterator> reverse_iterator;
33*58b9f456SAndroid Build Coastguard Worker    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
34*58b9f456SAndroid Build Coastguard Worker
35*58b9f456SAndroid Build Coastguard Worker    // No explicit construct/copy/destroy for aggregate type
36*58b9f456SAndroid Build Coastguard Worker    void fill(const T& u);
37*58b9f456SAndroid Build Coastguard Worker    void swap(array& a) noexcept(is_nothrow_swappable_v<T>);
38*58b9f456SAndroid Build Coastguard Worker
39*58b9f456SAndroid Build Coastguard Worker    // iterators:
40*58b9f456SAndroid Build Coastguard Worker    iterator begin() noexcept;
41*58b9f456SAndroid Build Coastguard Worker    const_iterator begin() const noexcept;
42*58b9f456SAndroid Build Coastguard Worker    iterator end() noexcept;
43*58b9f456SAndroid Build Coastguard Worker    const_iterator end() const noexcept;
44*58b9f456SAndroid Build Coastguard Worker
45*58b9f456SAndroid Build Coastguard Worker    reverse_iterator rbegin() noexcept;
46*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rbegin() const noexcept;
47*58b9f456SAndroid Build Coastguard Worker    reverse_iterator rend() noexcept;
48*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rend() const noexcept;
49*58b9f456SAndroid Build Coastguard Worker
50*58b9f456SAndroid Build Coastguard Worker    const_iterator cbegin() const noexcept;
51*58b9f456SAndroid Build Coastguard Worker    const_iterator cend() const noexcept;
52*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crbegin() const noexcept;
53*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crend() const noexcept;
54*58b9f456SAndroid Build Coastguard Worker
55*58b9f456SAndroid Build Coastguard Worker    // capacity:
56*58b9f456SAndroid Build Coastguard Worker    constexpr size_type size() const noexcept;
57*58b9f456SAndroid Build Coastguard Worker    constexpr size_type max_size() const noexcept;
58*58b9f456SAndroid Build Coastguard Worker    constexpr bool empty() const noexcept;
59*58b9f456SAndroid Build Coastguard Worker
60*58b9f456SAndroid Build Coastguard Worker    // element access:
61*58b9f456SAndroid Build Coastguard Worker    reference operator[](size_type n);
62*58b9f456SAndroid Build Coastguard Worker    const_reference operator[](size_type n) const; // constexpr in C++14
63*58b9f456SAndroid Build Coastguard Worker    const_reference at(size_type n) const; // constexpr in C++14
64*58b9f456SAndroid Build Coastguard Worker    reference at(size_type n);
65*58b9f456SAndroid Build Coastguard Worker
66*58b9f456SAndroid Build Coastguard Worker    reference front();
67*58b9f456SAndroid Build Coastguard Worker    const_reference front() const; // constexpr in C++14
68*58b9f456SAndroid Build Coastguard Worker    reference back();
69*58b9f456SAndroid Build Coastguard Worker    const_reference back() const; // constexpr in C++14
70*58b9f456SAndroid Build Coastguard Worker
71*58b9f456SAndroid Build Coastguard Worker    T* data() noexcept;
72*58b9f456SAndroid Build Coastguard Worker    const T* data() const noexcept;
73*58b9f456SAndroid Build Coastguard Worker};
74*58b9f456SAndroid Build Coastguard Worker
75*58b9f456SAndroid Build Coastguard Worker  template <class T, class... U>
76*58b9f456SAndroid Build Coastguard Worker    array(T, U...) -> array<T, 1 + sizeof...(U)>;
77*58b9f456SAndroid Build Coastguard Worker
78*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N>
79*58b9f456SAndroid Build Coastguard Worker  bool operator==(const array<T,N>& x, const array<T,N>& y);
80*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N>
81*58b9f456SAndroid Build Coastguard Worker  bool operator!=(const array<T,N>& x, const array<T,N>& y);
82*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N>
83*58b9f456SAndroid Build Coastguard Worker  bool operator<(const array<T,N>& x, const array<T,N>& y);
84*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N>
85*58b9f456SAndroid Build Coastguard Worker  bool operator>(const array<T,N>& x, const array<T,N>& y);
86*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N>
87*58b9f456SAndroid Build Coastguard Worker  bool operator<=(const array<T,N>& x, const array<T,N>& y);
88*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N>
89*58b9f456SAndroid Build Coastguard Worker  bool operator>=(const array<T,N>& x, const array<T,N>& y);
90*58b9f456SAndroid Build Coastguard Worker
91*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N >
92*58b9f456SAndroid Build Coastguard Worker  void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // C++17
93*58b9f456SAndroid Build Coastguard Worker
94*58b9f456SAndroid Build Coastguard Workertemplate <class T> struct tuple_size;
95*58b9f456SAndroid Build Coastguard Workertemplate <size_t I, class T> class tuple_element;
96*58b9f456SAndroid Build Coastguard Workertemplate <class T, size_t N> struct tuple_size<array<T, N>>;
97*58b9f456SAndroid Build Coastguard Workertemplate <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>;
98*58b9f456SAndroid Build Coastguard Workertemplate <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
99*58b9f456SAndroid Build Coastguard Workertemplate <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14
100*58b9f456SAndroid Build Coastguard Workertemplate <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14
101*58b9f456SAndroid Build Coastguard Workertemplate <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14
102*58b9f456SAndroid Build Coastguard Worker
103*58b9f456SAndroid Build Coastguard Worker}  // std
104*58b9f456SAndroid Build Coastguard Worker
105*58b9f456SAndroid Build Coastguard Worker*/
106*58b9f456SAndroid Build Coastguard Worker
107*58b9f456SAndroid Build Coastguard Worker#include <__config>
108*58b9f456SAndroid Build Coastguard Worker#include <__tuple>
109*58b9f456SAndroid Build Coastguard Worker#include <type_traits>
110*58b9f456SAndroid Build Coastguard Worker#include <utility>
111*58b9f456SAndroid Build Coastguard Worker#include <iterator>
112*58b9f456SAndroid Build Coastguard Worker#include <algorithm>
113*58b9f456SAndroid Build Coastguard Worker#include <stdexcept>
114*58b9f456SAndroid Build Coastguard Worker#include <cstdlib> // for _LIBCPP_UNREACHABLE
115*58b9f456SAndroid Build Coastguard Worker#include <version>
116*58b9f456SAndroid Build Coastguard Worker#include <__debug>
117*58b9f456SAndroid Build Coastguard Worker
118*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
119*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
120*58b9f456SAndroid Build Coastguard Worker#endif
121*58b9f456SAndroid Build Coastguard Worker
122*58b9f456SAndroid Build Coastguard Worker
123*58b9f456SAndroid Build Coastguard Worker
124*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
125*58b9f456SAndroid Build Coastguard Worker
126*58b9f456SAndroid Build Coastguard Worker
127*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Size>
128*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS array
129*58b9f456SAndroid Build Coastguard Worker{
130*58b9f456SAndroid Build Coastguard Worker    // types:
131*58b9f456SAndroid Build Coastguard Worker    typedef array __self;
132*58b9f456SAndroid Build Coastguard Worker    typedef _Tp                                   value_type;
133*58b9f456SAndroid Build Coastguard Worker    typedef value_type&                           reference;
134*58b9f456SAndroid Build Coastguard Worker    typedef const value_type&                     const_reference;
135*58b9f456SAndroid Build Coastguard Worker    typedef value_type*                           iterator;
136*58b9f456SAndroid Build Coastguard Worker    typedef const value_type*                     const_iterator;
137*58b9f456SAndroid Build Coastguard Worker    typedef value_type*                           pointer;
138*58b9f456SAndroid Build Coastguard Worker    typedef const value_type*                     const_pointer;
139*58b9f456SAndroid Build Coastguard Worker    typedef size_t                                size_type;
140*58b9f456SAndroid Build Coastguard Worker    typedef ptrdiff_t                             difference_type;
141*58b9f456SAndroid Build Coastguard Worker    typedef std::reverse_iterator<iterator>       reverse_iterator;
142*58b9f456SAndroid Build Coastguard Worker    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
143*58b9f456SAndroid Build Coastguard Worker
144*58b9f456SAndroid Build Coastguard Worker    _Tp __elems_[_Size];
145*58b9f456SAndroid Build Coastguard Worker
146*58b9f456SAndroid Build Coastguard Worker    // No explicit construct/copy/destroy for aggregate type
147*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) {
148*58b9f456SAndroid Build Coastguard Worker      _VSTD::fill_n(__elems_, _Size, __u);
149*58b9f456SAndroid Build Coastguard Worker    }
150*58b9f456SAndroid Build Coastguard Worker
151*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
152*58b9f456SAndroid Build Coastguard Worker    void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
153*58b9f456SAndroid Build Coastguard Worker      std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);
154*58b9f456SAndroid Build Coastguard Worker    }
155*58b9f456SAndroid Build Coastguard Worker
156*58b9f456SAndroid Build Coastguard Worker    // iterators:
157*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
158*58b9f456SAndroid Build Coastguard Worker    iterator begin() _NOEXCEPT {return iterator(data());}
159*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
160*58b9f456SAndroid Build Coastguard Worker    const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
161*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
162*58b9f456SAndroid Build Coastguard Worker    iterator end() _NOEXCEPT {return iterator(data() + _Size);}
163*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
164*58b9f456SAndroid Build Coastguard Worker    const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
165*58b9f456SAndroid Build Coastguard Worker
166*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
167*58b9f456SAndroid Build Coastguard Worker    reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
168*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
169*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
170*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
171*58b9f456SAndroid Build Coastguard Worker    reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
172*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
173*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
174*58b9f456SAndroid Build Coastguard Worker
175*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
176*58b9f456SAndroid Build Coastguard Worker    const_iterator cbegin() const _NOEXCEPT {return begin();}
177*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
178*58b9f456SAndroid Build Coastguard Worker    const_iterator cend() const _NOEXCEPT {return end();}
179*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
180*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
181*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
182*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
183*58b9f456SAndroid Build Coastguard Worker
184*58b9f456SAndroid Build Coastguard Worker    // capacity:
185*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
186*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return _Size;}
187*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
188*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
189*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
190*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return false; }
191*58b9f456SAndroid Build Coastguard Worker
192*58b9f456SAndroid Build Coastguard Worker    // element access:
193*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
194*58b9f456SAndroid Build Coastguard Worker    reference operator[](size_type __n)             {return __elems_[__n];}
195*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
196*58b9f456SAndroid Build Coastguard Worker    const_reference operator[](size_type __n) const {return __elems_[__n];}
197*58b9f456SAndroid Build Coastguard Worker
198*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_AFTER_CXX14       reference at(size_type __n);
199*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const;
200*58b9f456SAndroid Build Coastguard Worker
201*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front()             {return __elems_[0];}
202*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];}
203*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back()              {return __elems_[_Size - 1];}
204*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const  {return __elems_[_Size - 1];}
205*58b9f456SAndroid Build Coastguard Worker
206*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
207*58b9f456SAndroid Build Coastguard Worker    value_type* data() _NOEXCEPT {return __elems_;}
208*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
209*58b9f456SAndroid Build Coastguard Worker    const value_type* data() const _NOEXCEPT {return __elems_;}
210*58b9f456SAndroid Build Coastguard Worker};
211*58b9f456SAndroid Build Coastguard Worker
212*58b9f456SAndroid Build Coastguard Worker
213*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Size>
214*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX14
215*58b9f456SAndroid Build Coastguard Workertypename array<_Tp, _Size>::reference
216*58b9f456SAndroid Build Coastguard Workerarray<_Tp, _Size>::at(size_type __n)
217*58b9f456SAndroid Build Coastguard Worker{
218*58b9f456SAndroid Build Coastguard Worker    if (__n >= _Size)
219*58b9f456SAndroid Build Coastguard Worker        __throw_out_of_range("array::at");
220*58b9f456SAndroid Build Coastguard Worker
221*58b9f456SAndroid Build Coastguard Worker    return __elems_[__n];
222*58b9f456SAndroid Build Coastguard Worker}
223*58b9f456SAndroid Build Coastguard Worker
224*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Size>
225*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11
226*58b9f456SAndroid Build Coastguard Workertypename array<_Tp, _Size>::const_reference
227*58b9f456SAndroid Build Coastguard Workerarray<_Tp, _Size>::at(size_type __n) const
228*58b9f456SAndroid Build Coastguard Worker{
229*58b9f456SAndroid Build Coastguard Worker    if (__n >= _Size)
230*58b9f456SAndroid Build Coastguard Worker        __throw_out_of_range("array::at");
231*58b9f456SAndroid Build Coastguard Worker    return __elems_[__n];
232*58b9f456SAndroid Build Coastguard Worker}
233*58b9f456SAndroid Build Coastguard Worker
234*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
235*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
236*58b9f456SAndroid Build Coastguard Worker{
237*58b9f456SAndroid Build Coastguard Worker    // types:
238*58b9f456SAndroid Build Coastguard Worker    typedef array __self;
239*58b9f456SAndroid Build Coastguard Worker    typedef _Tp                                   value_type;
240*58b9f456SAndroid Build Coastguard Worker    typedef value_type&                           reference;
241*58b9f456SAndroid Build Coastguard Worker    typedef const value_type&                     const_reference;
242*58b9f456SAndroid Build Coastguard Worker    typedef value_type*                           iterator;
243*58b9f456SAndroid Build Coastguard Worker    typedef const value_type*                     const_iterator;
244*58b9f456SAndroid Build Coastguard Worker    typedef value_type*                           pointer;
245*58b9f456SAndroid Build Coastguard Worker    typedef const value_type*                     const_pointer;
246*58b9f456SAndroid Build Coastguard Worker    typedef size_t                                size_type;
247*58b9f456SAndroid Build Coastguard Worker    typedef ptrdiff_t                             difference_type;
248*58b9f456SAndroid Build Coastguard Worker    typedef std::reverse_iterator<iterator>       reverse_iterator;
249*58b9f456SAndroid Build Coastguard Worker    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
250*58b9f456SAndroid Build Coastguard Worker
251*58b9f456SAndroid Build Coastguard Worker    typedef typename conditional<is_const<_Tp>::value, const char,
252*58b9f456SAndroid Build Coastguard Worker                                char>::type _CharType;
253*58b9f456SAndroid Build Coastguard Worker
254*58b9f456SAndroid Build Coastguard Worker    struct  _ArrayInStructT { _Tp __data_[1]; };
255*58b9f456SAndroid Build Coastguard Worker    _ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)];
256*58b9f456SAndroid Build Coastguard Worker
257*58b9f456SAndroid Build Coastguard Worker    // No explicit construct/copy/destroy for aggregate type
258*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY void fill(const value_type&) {
259*58b9f456SAndroid Build Coastguard Worker      static_assert(!is_const<_Tp>::value,
260*58b9f456SAndroid Build Coastguard Worker                    "cannot fill zero-sized array of type 'const T'");
261*58b9f456SAndroid Build Coastguard Worker    }
262*58b9f456SAndroid Build Coastguard Worker
263*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
264*58b9f456SAndroid Build Coastguard Worker    void swap(array&) _NOEXCEPT {
265*58b9f456SAndroid Build Coastguard Worker      static_assert(!is_const<_Tp>::value,
266*58b9f456SAndroid Build Coastguard Worker                    "cannot swap zero-sized array of type 'const T'");
267*58b9f456SAndroid Build Coastguard Worker    }
268*58b9f456SAndroid Build Coastguard Worker
269*58b9f456SAndroid Build Coastguard Worker    // iterators:
270*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
271*58b9f456SAndroid Build Coastguard Worker    iterator begin() _NOEXCEPT {return iterator(data());}
272*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
273*58b9f456SAndroid Build Coastguard Worker    const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
274*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
275*58b9f456SAndroid Build Coastguard Worker    iterator end() _NOEXCEPT {return iterator(data());}
276*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
277*58b9f456SAndroid Build Coastguard Worker    const_iterator end() const _NOEXCEPT {return const_iterator(data());}
278*58b9f456SAndroid Build Coastguard Worker
279*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
280*58b9f456SAndroid Build Coastguard Worker    reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
281*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
282*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
283*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
284*58b9f456SAndroid Build Coastguard Worker    reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
285*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
286*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
287*58b9f456SAndroid Build Coastguard Worker
288*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
289*58b9f456SAndroid Build Coastguard Worker    const_iterator cbegin() const _NOEXCEPT {return begin();}
290*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
291*58b9f456SAndroid Build Coastguard Worker    const_iterator cend() const _NOEXCEPT {return end();}
292*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
293*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
294*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
295*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
296*58b9f456SAndroid Build Coastguard Worker
297*58b9f456SAndroid Build Coastguard Worker    // capacity:
298*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
299*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return 0; }
300*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
301*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return 0;}
302*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
303*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;}
304*58b9f456SAndroid Build Coastguard Worker
305*58b9f456SAndroid Build Coastguard Worker    // element access:
306*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
307*58b9f456SAndroid Build Coastguard Worker    reference operator[](size_type) {
308*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
309*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_UNREACHABLE();
310*58b9f456SAndroid Build Coastguard Worker    }
311*58b9f456SAndroid Build Coastguard Worker
312*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
313*58b9f456SAndroid Build Coastguard Worker    const_reference operator[](size_type) const {
314*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
315*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_UNREACHABLE();
316*58b9f456SAndroid Build Coastguard Worker    }
317*58b9f456SAndroid Build Coastguard Worker
318*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
319*58b9f456SAndroid Build Coastguard Worker    reference at(size_type) {
320*58b9f456SAndroid Build Coastguard Worker      __throw_out_of_range("array<T, 0>::at");
321*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_UNREACHABLE();
322*58b9f456SAndroid Build Coastguard Worker    }
323*58b9f456SAndroid Build Coastguard Worker
324*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
325*58b9f456SAndroid Build Coastguard Worker    const_reference at(size_type) const {
326*58b9f456SAndroid Build Coastguard Worker      __throw_out_of_range("array<T, 0>::at");
327*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_UNREACHABLE();
328*58b9f456SAndroid Build Coastguard Worker    }
329*58b9f456SAndroid Build Coastguard Worker
330*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
331*58b9f456SAndroid Build Coastguard Worker    reference front() {
332*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
333*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_UNREACHABLE();
334*58b9f456SAndroid Build Coastguard Worker    }
335*58b9f456SAndroid Build Coastguard Worker
336*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
337*58b9f456SAndroid Build Coastguard Worker    const_reference front() const {
338*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
339*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_UNREACHABLE();
340*58b9f456SAndroid Build Coastguard Worker    }
341*58b9f456SAndroid Build Coastguard Worker
342*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
343*58b9f456SAndroid Build Coastguard Worker    reference back() {
344*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
345*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_UNREACHABLE();
346*58b9f456SAndroid Build Coastguard Worker    }
347*58b9f456SAndroid Build Coastguard Worker
348*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
349*58b9f456SAndroid Build Coastguard Worker    const_reference back() const {
350*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
351*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_UNREACHABLE();
352*58b9f456SAndroid Build Coastguard Worker    }
353*58b9f456SAndroid Build Coastguard Worker
354*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
355*58b9f456SAndroid Build Coastguard Worker    value_type* data() _NOEXCEPT {return reinterpret_cast<value_type*>(__elems_);}
356*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
357*58b9f456SAndroid Build Coastguard Worker    const value_type* data() const _NOEXCEPT {return reinterpret_cast<const value_type*>(__elems_);}
358*58b9f456SAndroid Build Coastguard Worker};
359*58b9f456SAndroid Build Coastguard Worker
360*58b9f456SAndroid Build Coastguard Worker
361*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
362*58b9f456SAndroid Build Coastguard Workertemplate<class _Tp, class... _Args,
363*58b9f456SAndroid Build Coastguard Worker         class = typename enable_if<(is_same_v<_Tp, _Args> && ...), void>::type
364*58b9f456SAndroid Build Coastguard Worker         >
365*58b9f456SAndroid Build Coastguard Workerarray(_Tp, _Args...)
366*58b9f456SAndroid Build Coastguard Worker  -> array<_Tp, 1 + sizeof...(_Args)>;
367*58b9f456SAndroid Build Coastguard Worker#endif
368*58b9f456SAndroid Build Coastguard Worker
369*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Size>
370*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
371*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
372*58b9f456SAndroid Build Coastguard Workeroperator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
373*58b9f456SAndroid Build Coastguard Worker{
374*58b9f456SAndroid Build Coastguard Worker    return _VSTD::equal(__x.begin(), __x.end(), __y.begin());
375*58b9f456SAndroid Build Coastguard Worker}
376*58b9f456SAndroid Build Coastguard Worker
377*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Size>
378*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
379*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
380*58b9f456SAndroid Build Coastguard Workeroperator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
381*58b9f456SAndroid Build Coastguard Worker{
382*58b9f456SAndroid Build Coastguard Worker    return !(__x == __y);
383*58b9f456SAndroid Build Coastguard Worker}
384*58b9f456SAndroid Build Coastguard Worker
385*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Size>
386*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
387*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
388*58b9f456SAndroid Build Coastguard Workeroperator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
389*58b9f456SAndroid Build Coastguard Worker{
390*58b9f456SAndroid Build Coastguard Worker    return _VSTD::lexicographical_compare(__x.begin(), __x.end(),
391*58b9f456SAndroid Build Coastguard Worker                                          __y.begin(), __y.end());
392*58b9f456SAndroid Build Coastguard Worker}
393*58b9f456SAndroid Build Coastguard Worker
394*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Size>
395*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
396*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
397*58b9f456SAndroid Build Coastguard Workeroperator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
398*58b9f456SAndroid Build Coastguard Worker{
399*58b9f456SAndroid Build Coastguard Worker    return __y < __x;
400*58b9f456SAndroid Build Coastguard Worker}
401*58b9f456SAndroid Build Coastguard Worker
402*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Size>
403*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
404*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
405*58b9f456SAndroid Build Coastguard Workeroperator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
406*58b9f456SAndroid Build Coastguard Worker{
407*58b9f456SAndroid Build Coastguard Worker    return !(__y < __x);
408*58b9f456SAndroid Build Coastguard Worker}
409*58b9f456SAndroid Build Coastguard Worker
410*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Size>
411*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
412*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
413*58b9f456SAndroid Build Coastguard Workeroperator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
414*58b9f456SAndroid Build Coastguard Worker{
415*58b9f456SAndroid Build Coastguard Worker    return !(__x < __y);
416*58b9f456SAndroid Build Coastguard Worker}
417*58b9f456SAndroid Build Coastguard Worker
418*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Size>
419*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
420*58b9f456SAndroid Build Coastguard Workertypename enable_if
421*58b9f456SAndroid Build Coastguard Worker<
422*58b9f456SAndroid Build Coastguard Worker    _Size == 0 ||
423*58b9f456SAndroid Build Coastguard Worker    __is_swappable<_Tp>::value,
424*58b9f456SAndroid Build Coastguard Worker    void
425*58b9f456SAndroid Build Coastguard Worker>::type
426*58b9f456SAndroid Build Coastguard Workerswap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
427*58b9f456SAndroid Build Coastguard Worker                                  _NOEXCEPT_(noexcept(__x.swap(__y)))
428*58b9f456SAndroid Build Coastguard Worker{
429*58b9f456SAndroid Build Coastguard Worker    __x.swap(__y);
430*58b9f456SAndroid Build Coastguard Worker}
431*58b9f456SAndroid Build Coastguard Worker
432*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, size_t _Size>
433*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> >
434*58b9f456SAndroid Build Coastguard Worker    : public integral_constant<size_t, _Size> {};
435*58b9f456SAndroid Build Coastguard Worker
436*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip, class _Tp, size_t _Size>
437*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
438*58b9f456SAndroid Build Coastguard Worker{
439*58b9f456SAndroid Build Coastguard Worker    static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
440*58b9f456SAndroid Build Coastguard Workerpublic:
441*58b9f456SAndroid Build Coastguard Worker    typedef _Tp type;
442*58b9f456SAndroid Build Coastguard Worker};
443*58b9f456SAndroid Build Coastguard Worker
444*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip, class _Tp, size_t _Size>
445*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
446*58b9f456SAndroid Build Coastguard Worker_Tp&
447*58b9f456SAndroid Build Coastguard Workerget(array<_Tp, _Size>& __a) _NOEXCEPT
448*58b9f456SAndroid Build Coastguard Worker{
449*58b9f456SAndroid Build Coastguard Worker    static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)");
450*58b9f456SAndroid Build Coastguard Worker    return __a.__elems_[_Ip];
451*58b9f456SAndroid Build Coastguard Worker}
452*58b9f456SAndroid Build Coastguard Worker
453*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip, class _Tp, size_t _Size>
454*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
455*58b9f456SAndroid Build Coastguard Workerconst _Tp&
456*58b9f456SAndroid Build Coastguard Workerget(const array<_Tp, _Size>& __a) _NOEXCEPT
457*58b9f456SAndroid Build Coastguard Worker{
458*58b9f456SAndroid Build Coastguard Worker    static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)");
459*58b9f456SAndroid Build Coastguard Worker    return __a.__elems_[_Ip];
460*58b9f456SAndroid Build Coastguard Worker}
461*58b9f456SAndroid Build Coastguard Worker
462*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
463*58b9f456SAndroid Build Coastguard Worker
464*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip, class _Tp, size_t _Size>
465*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
466*58b9f456SAndroid Build Coastguard Worker_Tp&&
467*58b9f456SAndroid Build Coastguard Workerget(array<_Tp, _Size>&& __a) _NOEXCEPT
468*58b9f456SAndroid Build Coastguard Worker{
469*58b9f456SAndroid Build Coastguard Worker    static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)");
470*58b9f456SAndroid Build Coastguard Worker    return _VSTD::move(__a.__elems_[_Ip]);
471*58b9f456SAndroid Build Coastguard Worker}
472*58b9f456SAndroid Build Coastguard Worker
473*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip, class _Tp, size_t _Size>
474*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
475*58b9f456SAndroid Build Coastguard Workerconst _Tp&&
476*58b9f456SAndroid Build Coastguard Workerget(const array<_Tp, _Size>&& __a) _NOEXCEPT
477*58b9f456SAndroid Build Coastguard Worker{
478*58b9f456SAndroid Build Coastguard Worker    static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)");
479*58b9f456SAndroid Build Coastguard Worker    return _VSTD::move(__a.__elems_[_Ip]);
480*58b9f456SAndroid Build Coastguard Worker}
481*58b9f456SAndroid Build Coastguard Worker
482*58b9f456SAndroid Build Coastguard Worker#endif  // !_LIBCPP_CXX03_LANG
483*58b9f456SAndroid Build Coastguard Worker
484*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
485*58b9f456SAndroid Build Coastguard Worker
486*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_ARRAY
487