xref: /minix3/external/bsd/libc++/dist/libcxx/include/array (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*4684ddb6SLionel Sambuc// -*- C++ -*-
2*4684ddb6SLionel Sambuc//===---------------------------- array -----------------------------------===//
3*4684ddb6SLionel Sambuc//
4*4684ddb6SLionel Sambuc//                     The LLVM Compiler Infrastructure
5*4684ddb6SLionel Sambuc//
6*4684ddb6SLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open
7*4684ddb6SLionel Sambuc// Source Licenses. See LICENSE.TXT for details.
8*4684ddb6SLionel Sambuc//
9*4684ddb6SLionel Sambuc//===----------------------------------------------------------------------===//
10*4684ddb6SLionel Sambuc
11*4684ddb6SLionel Sambuc#ifndef _LIBCPP_ARRAY
12*4684ddb6SLionel Sambuc#define _LIBCPP_ARRAY
13*4684ddb6SLionel Sambuc
14*4684ddb6SLionel Sambuc/*
15*4684ddb6SLionel Sambuc    array synopsis
16*4684ddb6SLionel Sambuc
17*4684ddb6SLionel Sambucnamespace std
18*4684ddb6SLionel Sambuc{
19*4684ddb6SLionel Sambuctemplate <class T, size_t N >
20*4684ddb6SLionel Sambucstruct array
21*4684ddb6SLionel Sambuc{
22*4684ddb6SLionel Sambuc    // types:
23*4684ddb6SLionel Sambuc    typedef T & reference;
24*4684ddb6SLionel Sambuc    typedef const T & const_reference;
25*4684ddb6SLionel Sambuc    typedef implementation defined iterator;
26*4684ddb6SLionel Sambuc    typedef implementation defined const_iterator;
27*4684ddb6SLionel Sambuc    typedef size_t size_type;
28*4684ddb6SLionel Sambuc    typedef ptrdiff_t difference_type;
29*4684ddb6SLionel Sambuc    typedef T value_type;
30*4684ddb6SLionel Sambuc    typedef T* pointer;
31*4684ddb6SLionel Sambuc    typedef const T* const_pointer;
32*4684ddb6SLionel Sambuc    typedef std::reverse_iterator<iterator> reverse_iterator;
33*4684ddb6SLionel Sambuc    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
34*4684ddb6SLionel Sambuc
35*4684ddb6SLionel Sambuc    // No explicit construct/copy/destroy for aggregate type
36*4684ddb6SLionel Sambuc    void fill(const T& u);
37*4684ddb6SLionel Sambuc    void swap(array& a) noexcept(noexcept(swap(declval<T&>(), declval<T&>())));
38*4684ddb6SLionel Sambuc
39*4684ddb6SLionel Sambuc    // iterators:
40*4684ddb6SLionel Sambuc    iterator begin() noexcept;
41*4684ddb6SLionel Sambuc    const_iterator begin() const noexcept;
42*4684ddb6SLionel Sambuc    iterator end() noexcept;
43*4684ddb6SLionel Sambuc    const_iterator end() const noexcept;
44*4684ddb6SLionel Sambuc
45*4684ddb6SLionel Sambuc    reverse_iterator rbegin() noexcept;
46*4684ddb6SLionel Sambuc    const_reverse_iterator rbegin() const noexcept;
47*4684ddb6SLionel Sambuc    reverse_iterator rend() noexcept;
48*4684ddb6SLionel Sambuc    const_reverse_iterator rend() const noexcept;
49*4684ddb6SLionel Sambuc
50*4684ddb6SLionel Sambuc    const_iterator cbegin() const noexcept;
51*4684ddb6SLionel Sambuc    const_iterator cend() const noexcept;
52*4684ddb6SLionel Sambuc    const_reverse_iterator crbegin() const noexcept;
53*4684ddb6SLionel Sambuc    const_reverse_iterator crend() const noexcept;
54*4684ddb6SLionel Sambuc
55*4684ddb6SLionel Sambuc    // capacity:
56*4684ddb6SLionel Sambuc    constexpr size_type size() const noexcept;
57*4684ddb6SLionel Sambuc    constexpr size_type max_size() const noexcept;
58*4684ddb6SLionel Sambuc    constexpr bool empty() const noexcept;
59*4684ddb6SLionel Sambuc
60*4684ddb6SLionel Sambuc    // element access:
61*4684ddb6SLionel Sambuc    reference operator[](size_type n);
62*4684ddb6SLionel Sambuc    const_reference operator[](size_type n) const; // constexpr in C++14
63*4684ddb6SLionel Sambuc    const_reference at(size_type n) const; // constexpr in C++14
64*4684ddb6SLionel Sambuc    reference at(size_type n);
65*4684ddb6SLionel Sambuc
66*4684ddb6SLionel Sambuc    reference front();
67*4684ddb6SLionel Sambuc    const_reference front() const; // constexpr in C++14
68*4684ddb6SLionel Sambuc    reference back();
69*4684ddb6SLionel Sambuc    const_reference back() const; // constexpr in C++14
70*4684ddb6SLionel Sambuc
71*4684ddb6SLionel Sambuc    T* data() noexcept;
72*4684ddb6SLionel Sambuc    const T* data() const noexcept;
73*4684ddb6SLionel Sambuc};
74*4684ddb6SLionel Sambuc
75*4684ddb6SLionel Sambuctemplate <class T, size_t N>
76*4684ddb6SLionel Sambuc  bool operator==(const array<T,N>& x, const array<T,N>& y);
77*4684ddb6SLionel Sambuctemplate <class T, size_t N>
78*4684ddb6SLionel Sambuc  bool operator!=(const array<T,N>& x, const array<T,N>& y);
79*4684ddb6SLionel Sambuctemplate <class T, size_t N>
80*4684ddb6SLionel Sambuc  bool operator<(const array<T,N>& x, const array<T,N>& y);
81*4684ddb6SLionel Sambuctemplate <class T, size_t N>
82*4684ddb6SLionel Sambuc  bool operator>(const array<T,N>& x, const array<T,N>& y);
83*4684ddb6SLionel Sambuctemplate <class T, size_t N>
84*4684ddb6SLionel Sambuc  bool operator<=(const array<T,N>& x, const array<T,N>& y);
85*4684ddb6SLionel Sambuctemplate <class T, size_t N>
86*4684ddb6SLionel Sambuc  bool operator>=(const array<T,N>& x, const array<T,N>& y);
87*4684ddb6SLionel Sambuc
88*4684ddb6SLionel Sambuctemplate <class T, size_t N >
89*4684ddb6SLionel Sambuc  void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y)));
90*4684ddb6SLionel Sambuc
91*4684ddb6SLionel Sambuctemplate <class T> class tuple_size;
92*4684ddb6SLionel Sambuctemplate <int I, class T> class tuple_element;
93*4684ddb6SLionel Sambuctemplate <class T, size_t N> struct tuple_size<array<T, N>>;
94*4684ddb6SLionel Sambuctemplate <int I, class T, size_t N> struct tuple_element<I, array<T, N>>;
95*4684ddb6SLionel Sambuctemplate <int I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
96*4684ddb6SLionel Sambuctemplate <int I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14
97*4684ddb6SLionel Sambuctemplate <int I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14
98*4684ddb6SLionel Sambuc
99*4684ddb6SLionel Sambuc}  // std
100*4684ddb6SLionel Sambuc
101*4684ddb6SLionel Sambuc*/
102*4684ddb6SLionel Sambuc
103*4684ddb6SLionel Sambuc#include <__config>
104*4684ddb6SLionel Sambuc#include <__tuple>
105*4684ddb6SLionel Sambuc#include <type_traits>
106*4684ddb6SLionel Sambuc#include <utility>
107*4684ddb6SLionel Sambuc#include <iterator>
108*4684ddb6SLionel Sambuc#include <algorithm>
109*4684ddb6SLionel Sambuc#include <stdexcept>
110*4684ddb6SLionel Sambuc#if defined(_LIBCPP_NO_EXCEPTIONS)
111*4684ddb6SLionel Sambuc    #include <cassert>
112*4684ddb6SLionel Sambuc#endif
113*4684ddb6SLionel Sambuc
114*4684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
115*4684ddb6SLionel Sambuc#pragma GCC system_header
116*4684ddb6SLionel Sambuc#endif
117*4684ddb6SLionel Sambuc
118*4684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD
119*4684ddb6SLionel Sambuc
120*4684ddb6SLionel Sambuctemplate <class _Tp, size_t _Size>
121*4684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY array
122*4684ddb6SLionel Sambuc{
123*4684ddb6SLionel Sambuc    // types:
124*4684ddb6SLionel Sambuc    typedef array __self;
125*4684ddb6SLionel Sambuc    typedef _Tp                                   value_type;
126*4684ddb6SLionel Sambuc    typedef value_type&                           reference;
127*4684ddb6SLionel Sambuc    typedef const value_type&                     const_reference;
128*4684ddb6SLionel Sambuc    typedef value_type*                           iterator;
129*4684ddb6SLionel Sambuc    typedef const value_type*                     const_iterator;
130*4684ddb6SLionel Sambuc    typedef value_type*                           pointer;
131*4684ddb6SLionel Sambuc    typedef const value_type*                     const_pointer;
132*4684ddb6SLionel Sambuc    typedef size_t                                size_type;
133*4684ddb6SLionel Sambuc    typedef ptrdiff_t                             difference_type;
134*4684ddb6SLionel Sambuc    typedef std::reverse_iterator<iterator>       reverse_iterator;
135*4684ddb6SLionel Sambuc    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
136*4684ddb6SLionel Sambuc
137*4684ddb6SLionel Sambuc    value_type __elems_[_Size > 0 ? _Size : 1];
138*4684ddb6SLionel Sambuc
139*4684ddb6SLionel Sambuc    // No explicit construct/copy/destroy for aggregate type
140*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
141*4684ddb6SLionel Sambuc        {_VSTD::fill_n(__elems_, _Size, __u);}
142*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
143*4684ddb6SLionel Sambuc    void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
144*4684ddb6SLionel Sambuc        {_VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
145*4684ddb6SLionel Sambuc
146*4684ddb6SLionel Sambuc    // iterators:
147*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
148*4684ddb6SLionel Sambuc    iterator begin() _NOEXCEPT {return iterator(__elems_);}
149*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
150*4684ddb6SLionel Sambuc    const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
151*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
152*4684ddb6SLionel Sambuc    iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
153*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
154*4684ddb6SLionel Sambuc    const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);}
155*4684ddb6SLionel Sambuc
156*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
157*4684ddb6SLionel Sambuc    reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
158*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
159*4684ddb6SLionel Sambuc    const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
160*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
161*4684ddb6SLionel Sambuc    reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
162*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
163*4684ddb6SLionel Sambuc    const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
164*4684ddb6SLionel Sambuc
165*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
166*4684ddb6SLionel Sambuc    const_iterator cbegin() const _NOEXCEPT {return begin();}
167*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
168*4684ddb6SLionel Sambuc    const_iterator cend() const _NOEXCEPT {return end();}
169*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
170*4684ddb6SLionel Sambuc    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
171*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
172*4684ddb6SLionel Sambuc    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
173*4684ddb6SLionel Sambuc
174*4684ddb6SLionel Sambuc    // capacity:
175*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
176*4684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return _Size;}
177*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
178*4684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
179*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
180*4684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
181*4684ddb6SLionel Sambuc
182*4684ddb6SLionel Sambuc    // element access:
183*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n)             {return __elems_[__n];}
184*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference operator[](size_type __n) const {return __elems_[__n];}
185*4684ddb6SLionel Sambuc    reference at(size_type __n);
186*4684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const;
187*4684ddb6SLionel Sambuc
188*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY reference front()             {return __elems_[0];}
189*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];}
190*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY reference back()              {return __elems_[_Size > 0 ? _Size-1 : 0];}
191*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const  {return __elems_[_Size > 0 ? _Size-1 : 0];}
192*4684ddb6SLionel Sambuc
193*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
194*4684ddb6SLionel Sambuc    value_type* data() _NOEXCEPT {return __elems_;}
195*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
196*4684ddb6SLionel Sambuc    const value_type* data() const _NOEXCEPT {return __elems_;}
197*4684ddb6SLionel Sambuc};
198*4684ddb6SLionel Sambuc
199*4684ddb6SLionel Sambuctemplate <class _Tp, size_t _Size>
200*4684ddb6SLionel Sambuctypename array<_Tp, _Size>::reference
201*4684ddb6SLionel Sambucarray<_Tp, _Size>::at(size_type __n)
202*4684ddb6SLionel Sambuc{
203*4684ddb6SLionel Sambuc    if (__n >= _Size)
204*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
205*4684ddb6SLionel Sambuc        throw out_of_range("array::at");
206*4684ddb6SLionel Sambuc#else
207*4684ddb6SLionel Sambuc        assert(!"array::at out_of_range");
208*4684ddb6SLionel Sambuc#endif
209*4684ddb6SLionel Sambuc    return __elems_[__n];
210*4684ddb6SLionel Sambuc}
211*4684ddb6SLionel Sambuc
212*4684ddb6SLionel Sambuctemplate <class _Tp, size_t _Size>
213*4684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR_AFTER_CXX11
214*4684ddb6SLionel Sambuctypename array<_Tp, _Size>::const_reference
215*4684ddb6SLionel Sambucarray<_Tp, _Size>::at(size_type __n) const
216*4684ddb6SLionel Sambuc{
217*4684ddb6SLionel Sambuc    if (__n >= _Size)
218*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
219*4684ddb6SLionel Sambuc        throw out_of_range("array::at");
220*4684ddb6SLionel Sambuc#else
221*4684ddb6SLionel Sambuc        assert(!"array::at out_of_range");
222*4684ddb6SLionel Sambuc#endif
223*4684ddb6SLionel Sambuc    return __elems_[__n];
224*4684ddb6SLionel Sambuc}
225*4684ddb6SLionel Sambuc
226*4684ddb6SLionel Sambuctemplate <class _Tp, size_t _Size>
227*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
228*4684ddb6SLionel Sambucbool
229*4684ddb6SLionel Sambucoperator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
230*4684ddb6SLionel Sambuc{
231*4684ddb6SLionel Sambuc    return _VSTD::equal(__x.__elems_, __x.__elems_ + _Size, __y.__elems_);
232*4684ddb6SLionel Sambuc}
233*4684ddb6SLionel Sambuc
234*4684ddb6SLionel Sambuctemplate <class _Tp, size_t _Size>
235*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
236*4684ddb6SLionel Sambucbool
237*4684ddb6SLionel Sambucoperator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
238*4684ddb6SLionel Sambuc{
239*4684ddb6SLionel Sambuc    return !(__x == __y);
240*4684ddb6SLionel Sambuc}
241*4684ddb6SLionel Sambuc
242*4684ddb6SLionel Sambuctemplate <class _Tp, size_t _Size>
243*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
244*4684ddb6SLionel Sambucbool
245*4684ddb6SLionel Sambucoperator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
246*4684ddb6SLionel Sambuc{
247*4684ddb6SLionel Sambuc    return _VSTD::lexicographical_compare(__x.__elems_, __x.__elems_ + _Size, __y.__elems_, __y.__elems_ + _Size);
248*4684ddb6SLionel Sambuc}
249*4684ddb6SLionel Sambuc
250*4684ddb6SLionel Sambuctemplate <class _Tp, size_t _Size>
251*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
252*4684ddb6SLionel Sambucbool
253*4684ddb6SLionel Sambucoperator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
254*4684ddb6SLionel Sambuc{
255*4684ddb6SLionel Sambuc    return __y < __x;
256*4684ddb6SLionel Sambuc}
257*4684ddb6SLionel Sambuc
258*4684ddb6SLionel Sambuctemplate <class _Tp, size_t _Size>
259*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
260*4684ddb6SLionel Sambucbool
261*4684ddb6SLionel Sambucoperator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
262*4684ddb6SLionel Sambuc{
263*4684ddb6SLionel Sambuc    return !(__y < __x);
264*4684ddb6SLionel Sambuc}
265*4684ddb6SLionel Sambuc
266*4684ddb6SLionel Sambuctemplate <class _Tp, size_t _Size>
267*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
268*4684ddb6SLionel Sambucbool
269*4684ddb6SLionel Sambucoperator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
270*4684ddb6SLionel Sambuc{
271*4684ddb6SLionel Sambuc    return !(__x < __y);
272*4684ddb6SLionel Sambuc}
273*4684ddb6SLionel Sambuc
274*4684ddb6SLionel Sambuctemplate <class _Tp, size_t _Size>
275*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
276*4684ddb6SLionel Sambuctypename enable_if
277*4684ddb6SLionel Sambuc<
278*4684ddb6SLionel Sambuc    __is_swappable<_Tp>::value,
279*4684ddb6SLionel Sambuc    void
280*4684ddb6SLionel Sambuc>::type
281*4684ddb6SLionel Sambucswap(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
282*4684ddb6SLionel Sambuc                                  _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
283*4684ddb6SLionel Sambuc{
284*4684ddb6SLionel Sambuc    __x.swap(__y);
285*4684ddb6SLionel Sambuc}
286*4684ddb6SLionel Sambuc
287*4684ddb6SLionel Sambuctemplate <class _Tp, size_t _Size>
288*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY tuple_size<array<_Tp, _Size> >
289*4684ddb6SLionel Sambuc    : public integral_constant<size_t, _Size> {};
290*4684ddb6SLionel Sambuc
291*4684ddb6SLionel Sambuctemplate <size_t _Ip, class _Tp, size_t _Size>
292*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, array<_Tp, _Size> >
293*4684ddb6SLionel Sambuc{
294*4684ddb6SLionel Sambucpublic:
295*4684ddb6SLionel Sambuc    typedef _Tp type;
296*4684ddb6SLionel Sambuc};
297*4684ddb6SLionel Sambuc
298*4684ddb6SLionel Sambuctemplate <size_t _Ip, class _Tp, size_t _Size>
299*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
300*4684ddb6SLionel Sambuc_Tp&
301*4684ddb6SLionel Sambucget(array<_Tp, _Size>& __a) _NOEXCEPT
302*4684ddb6SLionel Sambuc{
303*4684ddb6SLionel Sambuc    static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)");
304*4684ddb6SLionel Sambuc    return __a.__elems_[_Ip];
305*4684ddb6SLionel Sambuc}
306*4684ddb6SLionel Sambuc
307*4684ddb6SLionel Sambuctemplate <size_t _Ip, class _Tp, size_t _Size>
308*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
309*4684ddb6SLionel Sambucconst _Tp&
310*4684ddb6SLionel Sambucget(const array<_Tp, _Size>& __a) _NOEXCEPT
311*4684ddb6SLionel Sambuc{
312*4684ddb6SLionel Sambuc    static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)");
313*4684ddb6SLionel Sambuc    return __a.__elems_[_Ip];
314*4684ddb6SLionel Sambuc}
315*4684ddb6SLionel Sambuc
316*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
317*4684ddb6SLionel Sambuc
318*4684ddb6SLionel Sambuctemplate <size_t _Ip, class _Tp, size_t _Size>
319*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
320*4684ddb6SLionel Sambuc_Tp&&
321*4684ddb6SLionel Sambucget(array<_Tp, _Size>&& __a) _NOEXCEPT
322*4684ddb6SLionel Sambuc{
323*4684ddb6SLionel Sambuc    static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)");
324*4684ddb6SLionel Sambuc    return _VSTD::move(__a.__elems_[_Ip]);
325*4684ddb6SLionel Sambuc}
326*4684ddb6SLionel Sambuc
327*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
328*4684ddb6SLionel Sambuc
329*4684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD
330*4684ddb6SLionel Sambuc
331*4684ddb6SLionel Sambuc#endif  // _LIBCPP_ARRAY
332