blob: 79f7e0d62c56579d078a8195dd87b518b6a58c6e [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:161// -*- C++ -*-
2//===---------------------------- array -----------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:014// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:165//
Howard Hinnantb64f8b02010-11-16 22:09:026// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:168//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_ARRAY
12#define _LIBCPP_ARRAY
13
14/*
15 array synopsis
16
17namespace std
18{
Howard Hinnant324bb032010-08-22 00:02:4319template <class T, size_t N >
Howard Hinnantbc8d3f92010-05-11 19:42:1620struct array
Howard Hinnant324bb032010-08-22 00:02:4321{
22 // types:
23 typedef T & reference;
24 typedef const T & const_reference;
25 typedef implementation defined iterator;
26 typedef implementation defined const_iterator;
27 typedef size_t size_type;
28 typedef ptrdiff_t difference_type;
29 typedef T value_type;
Howard Hinnantbc8d3f92010-05-11 19:42:1630 typedef T* pointer;
31 typedef const T* const_pointer;
Howard Hinnant324bb032010-08-22 00:02:4332 typedef std::reverse_iterator<iterator> reverse_iterator;
33 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
Howard Hinnantbc8d3f92010-05-11 19:42:1634
Howard Hinnant324bb032010-08-22 00:02:4335 // No explicit construct/copy/destroy for aggregate type
36 void fill(const T& u);
Eric Fiselier8f1e73d2016-04-21 23:38:5937 void swap(array& a) noexcept(is_nothrow_swappable_v<T>);
Howard Hinnantbc8d3f92010-05-11 19:42:1638
Howard Hinnant324bb032010-08-22 00:02:4339 // iterators:
Howard Hinnantf0562af2011-05-31 21:06:3340 iterator begin() noexcept;
41 const_iterator begin() const noexcept;
42 iterator end() noexcept;
43 const_iterator end() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1644
Howard Hinnantf0562af2011-05-31 21:06:3345 reverse_iterator rbegin() noexcept;
46 const_reverse_iterator rbegin() const noexcept;
47 reverse_iterator rend() noexcept;
48 const_reverse_iterator rend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1649
Howard Hinnantf0562af2011-05-31 21:06:3350 const_iterator cbegin() const noexcept;
51 const_iterator cend() const noexcept;
52 const_reverse_iterator crbegin() const noexcept;
53 const_reverse_iterator crend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1654
Howard Hinnant324bb032010-08-22 00:02:4355 // capacity:
Howard Hinnantf0562af2011-05-31 21:06:3356 constexpr size_type size() const noexcept;
57 constexpr size_type max_size() const noexcept;
Howard Hinnant08bce172012-07-20 19:20:4958 constexpr bool empty() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1659
Howard Hinnant324bb032010-08-22 00:02:4360 // element access:
61 reference operator[](size_type n);
Marshall Clow8fc4f5a2013-07-17 18:25:3662 const_reference operator[](size_type n) const; // constexpr in C++14
63 const_reference at(size_type n) const; // constexpr in C++14
Howard Hinnant324bb032010-08-22 00:02:4364 reference at(size_type n);
Howard Hinnantbc8d3f92010-05-11 19:42:1665
Howard Hinnant324bb032010-08-22 00:02:4366 reference front();
Marshall Clow8fc4f5a2013-07-17 18:25:3667 const_reference front() const; // constexpr in C++14
Howard Hinnant324bb032010-08-22 00:02:4368 reference back();
Marshall Clow8fc4f5a2013-07-17 18:25:3669 const_reference back() const; // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1670
Howard Hinnantf0562af2011-05-31 21:06:3371 T* data() noexcept;
72 const T* data() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1673};
74
Howard Hinnant324bb032010-08-22 00:02:4375template <class T, size_t N>
76 bool operator==(const array<T,N>& x, const array<T,N>& y);
77template <class T, size_t N>
78 bool operator!=(const array<T,N>& x, const array<T,N>& y);
79template <class T, size_t N>
80 bool operator<(const array<T,N>& x, const array<T,N>& y);
81template <class T, size_t N>
82 bool operator>(const array<T,N>& x, const array<T,N>& y);
83template <class T, size_t N>
84 bool operator<=(const array<T,N>& x, const array<T,N>& y);
85template <class T, size_t N>
86 bool operator>=(const array<T,N>& x, const array<T,N>& y);
Howard Hinnantbc8d3f92010-05-11 19:42:1687
Howard Hinnant324bb032010-08-22 00:02:4388template <class T, size_t N >
Howard Hinnantf0562af2011-05-31 21:06:3389 void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y)));
Howard Hinnantbc8d3f92010-05-11 19:42:1690
Howard Hinnant324bb032010-08-22 00:02:4391template <class T> class tuple_size;
Marshall Clowd8717282015-11-19 19:41:0492template <size_t I, class T> class tuple_element;
Howard Hinnantbc8d3f92010-05-11 19:42:1693template <class T, size_t N> struct tuple_size<array<T, N>>;
Marshall Clowd8717282015-11-19 19:41:0494template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>;
95template <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
96template <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14
97template <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14
Eric Fiselier199bee02015-12-18 00:36:5598template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1699
100} // std
101
102*/
103
104#include <__config>
105#include <__tuple>
106#include <type_traits>
107#include <utility>
108#include <iterator>
109#include <algorithm>
110#include <stdexcept>
Howard Hinnantbc8d3f92010-05-11 19:42:16111
Howard Hinnant08e17472011-10-17 20:05:10112#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16113#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10114#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16115
Eric Fiselier018a3d52017-05-31 22:07:49116
117
Howard Hinnantbc8d3f92010-05-11 19:42:16118_LIBCPP_BEGIN_NAMESPACE_STD
119
Howard Hinnant324bb032010-08-22 00:02:43120template <class _Tp, size_t _Size>
Eric Fiselierc3589a82017-01-04 23:56:00121struct _LIBCPP_TEMPLATE_VIS array
Howard Hinnantbc8d3f92010-05-11 19:42:16122{
123 // types:
124 typedef array __self;
Howard Hinnant324bb032010-08-22 00:02:43125 typedef _Tp value_type;
126 typedef value_type& reference;
127 typedef const value_type& const_reference;
Howard Hinnantbc8d3f92010-05-11 19:42:16128 typedef value_type* iterator;
129 typedef const value_type* const_iterator;
130 typedef value_type* pointer;
131 typedef const value_type* const_pointer;
Howard Hinnant324bb032010-08-22 00:02:43132 typedef size_t size_type;
133 typedef ptrdiff_t difference_type;
134 typedef std::reverse_iterator<iterator> reverse_iterator;
135 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
Howard Hinnantbc8d3f92010-05-11 19:42:16136
137 value_type __elems_[_Size > 0 ? _Size : 1];
138
Howard Hinnant324bb032010-08-22 00:02:43139 // No explicit construct/copy/destroy for aggregate type
Howard Hinnant333f50d2010-09-21 20:16:37140 _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
Howard Hinnant0949eed2011-06-30 21:18:19141 {_VSTD::fill_n(__elems_, _Size, __u);}
Howard Hinnantf0562af2011-05-31 21:06:33142 _LIBCPP_INLINE_VISIBILITY
Eric Fiselier8f1e73d2016-04-21 23:38:59143 void swap(array& __a) _NOEXCEPT_(_Size == 0 || __is_nothrow_swappable<_Tp>::value)
144 { __swap_dispatch((std::integral_constant<bool, _Size == 0>()), __a); }
145
146 _LIBCPP_INLINE_VISIBILITY
147 void __swap_dispatch(std::true_type, array&) {}
148
149 _LIBCPP_INLINE_VISIBILITY
150 void __swap_dispatch(std::false_type, array& __a)
151 { _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16152
Howard Hinnant324bb032010-08-22 00:02:43153 // iterators:
Marshall Clowe22af6b2017-01-04 17:58:17154 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33155 iterator begin() _NOEXCEPT {return iterator(__elems_);}
Marshall Clowe22af6b2017-01-04 17:58:17156 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33157 const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
Marshall Clowe22af6b2017-01-04 17:58:17158 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33159 iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
Marshall Clowe22af6b2017-01-04 17:58:17160 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33161 const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);}
Howard Hinnantbc8d3f92010-05-11 19:42:16162
Marshall Clowe22af6b2017-01-04 17:58:17163 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33164 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
Marshall Clowe22af6b2017-01-04 17:58:17165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33166 const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
Marshall Clowe22af6b2017-01-04 17:58:17167 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33168 reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
Marshall Clowe22af6b2017-01-04 17:58:17169 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33170 const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
Howard Hinnantbc8d3f92010-05-11 19:42:16171
Marshall Clowe22af6b2017-01-04 17:58:17172 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33173 const_iterator cbegin() const _NOEXCEPT {return begin();}
Marshall Clowe22af6b2017-01-04 17:58:17174 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33175 const_iterator cend() const _NOEXCEPT {return end();}
Marshall Clowe22af6b2017-01-04 17:58:17176 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33177 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
Marshall Clowe22af6b2017-01-04 17:58:17178 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33179 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
Howard Hinnantbc8d3f92010-05-11 19:42:16180
Howard Hinnant324bb032010-08-22 00:02:43181 // capacity:
Howard Hinnantf0562af2011-05-31 21:06:33182 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant08bce172012-07-20 19:20:49183 _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return _Size;}
Howard Hinnantf0562af2011-05-31 21:06:33184 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant08bce172012-07-20 19:20:49185 _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
Howard Hinnantf0562af2011-05-31 21:06:33186 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant08bce172012-07-20 19:20:49187 _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
Howard Hinnantbc8d3f92010-05-11 19:42:16188
Howard Hinnant324bb032010-08-22 00:02:43189 // element access:
Marshall Clowd25c9972017-01-16 03:02:10190 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
191 reference operator[](size_type __n) {return __elems_[__n];}
192 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
193 const_reference operator[](size_type __n) const {return __elems_[__n];}
194
195 _LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n);
Marshall Clow8fc4f5a2013-07-17 18:25:36196 _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const;
Howard Hinnantbc8d3f92010-05-11 19:42:16197
Marshall Clowd25c9972017-01-16 03:02:10198 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() {return __elems_[0];}
Marshall Clow8fc4f5a2013-07-17 18:25:36199 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];}
Marshall Clowd25c9972017-01-16 03:02:10200 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];}
Marshall Clow8fc4f5a2013-07-17 18:25:36201 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];}
Howard Hinnantbc8d3f92010-05-11 19:42:16202
Marshall Clowe22af6b2017-01-04 17:58:17203 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33204 value_type* data() _NOEXCEPT {return __elems_;}
Marshall Clowe22af6b2017-01-04 17:58:17205 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantf0562af2011-05-31 21:06:33206 const value_type* data() const _NOEXCEPT {return __elems_;}
Howard Hinnantbc8d3f92010-05-11 19:42:16207};
208
Howard Hinnant324bb032010-08-22 00:02:43209template <class _Tp, size_t _Size>
Marshall Clowd25c9972017-01-16 03:02:10210_LIBCPP_CONSTEXPR_AFTER_CXX14
Howard Hinnantbc8d3f92010-05-11 19:42:16211typename array<_Tp, _Size>::reference
212array<_Tp, _Size>::at(size_type __n)
213{
214 if (__n >= _Size)
Marshall Clow14c09a22016-08-25 15:09:01215 __throw_out_of_range("array::at");
216
Howard Hinnantbc8d3f92010-05-11 19:42:16217 return __elems_[__n];
218}
219
Howard Hinnant324bb032010-08-22 00:02:43220template <class _Tp, size_t _Size>
Marshall Clow8fc4f5a2013-07-17 18:25:36221_LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16222typename array<_Tp, _Size>::const_reference
223array<_Tp, _Size>::at(size_type __n) const
224{
225 if (__n >= _Size)
Marshall Clow14c09a22016-08-25 15:09:01226 __throw_out_of_range("array::at");
Howard Hinnantbc8d3f92010-05-11 19:42:16227 return __elems_[__n];
228}
229
Howard Hinnant324bb032010-08-22 00:02:43230template <class _Tp, size_t _Size>
Howard Hinnant1e564242013-10-04 22:09:00231inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16232bool
233operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
234{
Howard Hinnant0949eed2011-06-30 21:18:19235 return _VSTD::equal(__x.__elems_, __x.__elems_ + _Size, __y.__elems_);
Howard Hinnantbc8d3f92010-05-11 19:42:16236}
237
Howard Hinnant324bb032010-08-22 00:02:43238template <class _Tp, size_t _Size>
Howard Hinnant1e564242013-10-04 22:09:00239inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16240bool
241operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
242{
243 return !(__x == __y);
244}
245
Howard Hinnant324bb032010-08-22 00:02:43246template <class _Tp, size_t _Size>
Howard Hinnant1e564242013-10-04 22:09:00247inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16248bool
249operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
250{
Howard Hinnant0949eed2011-06-30 21:18:19251 return _VSTD::lexicographical_compare(__x.__elems_, __x.__elems_ + _Size, __y.__elems_, __y.__elems_ + _Size);
Howard Hinnantbc8d3f92010-05-11 19:42:16252}
253
Howard Hinnant324bb032010-08-22 00:02:43254template <class _Tp, size_t _Size>
Howard Hinnant1e564242013-10-04 22:09:00255inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16256bool
257operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
258{
259 return __y < __x;
260}
261
Howard Hinnant324bb032010-08-22 00:02:43262template <class _Tp, size_t _Size>
Howard Hinnant1e564242013-10-04 22:09:00263inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16264bool
265operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
266{
267 return !(__y < __x);
268}
269
Howard Hinnant324bb032010-08-22 00:02:43270template <class _Tp, size_t _Size>
Howard Hinnant1e564242013-10-04 22:09:00271inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16272bool
273operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
274{
275 return !(__x < __y);
276}
277
Howard Hinnant324bb032010-08-22 00:02:43278template <class _Tp, size_t _Size>
Howard Hinnant1e564242013-10-04 22:09:00279inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantaabf2872011-06-01 19:59:32280typename enable_if
281<
Eric Fiselier8f1e73d2016-04-21 23:38:59282 _Size == 0 ||
Howard Hinnantaabf2872011-06-01 19:59:32283 __is_swappable<_Tp>::value,
284 void
285>::type
Marshall Clow8d48d9b2016-03-07 21:57:10286swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
Eric Fiselier8f1e73d2016-04-21 23:38:59287 _NOEXCEPT_(noexcept(__x.swap(__y)))
Howard Hinnantbc8d3f92010-05-11 19:42:16288{
289 __x.swap(__y);
290}
291
292template <class _Tp, size_t _Size>
Eric Fiselierc3589a82017-01-04 23:56:00293class _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> >
Howard Hinnant333f50d2010-09-21 20:16:37294 : public integral_constant<size_t, _Size> {};
Howard Hinnantbc8d3f92010-05-11 19:42:16295
Howard Hinnantbc8d3f92010-05-11 19:42:16296template <size_t _Ip, class _Tp, size_t _Size>
Eric Fiselierc3589a82017-01-04 23:56:00297class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
Howard Hinnantbc8d3f92010-05-11 19:42:16298{
299public:
300 typedef _Tp type;
301};
302
303template <size_t _Ip, class _Tp, size_t _Size>
Howard Hinnant1e564242013-10-04 22:09:00304inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16305_Tp&
Howard Hinnantf0562af2011-05-31 21:06:33306get(array<_Tp, _Size>& __a) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16307{
Marshall Clowa46482e2012-12-18 16:46:30308 static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)");
Marshall Clow8fc4f5a2013-07-17 18:25:36309 return __a.__elems_[_Ip];
Howard Hinnantbc8d3f92010-05-11 19:42:16310}
311
312template <size_t _Ip, class _Tp, size_t _Size>
Howard Hinnant1e564242013-10-04 22:09:00313inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16314const _Tp&
Howard Hinnantf0562af2011-05-31 21:06:33315get(const array<_Tp, _Size>& __a) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16316{
Marshall Clowa46482e2012-12-18 16:46:30317 static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)");
Marshall Clow8fc4f5a2013-07-17 18:25:36318 return __a.__elems_[_Ip];
Howard Hinnantbc8d3f92010-05-11 19:42:16319}
320
Eric Fiselier6c26be62017-04-16 02:50:40321#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantcd2254b2010-11-17 19:52:17322
323template <size_t _Ip, class _Tp, size_t _Size>
Howard Hinnant1e564242013-10-04 22:09:00324inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantcd2254b2010-11-17 19:52:17325_Tp&&
Howard Hinnantf0562af2011-05-31 21:06:33326get(array<_Tp, _Size>&& __a) _NOEXCEPT
Howard Hinnantcd2254b2010-11-17 19:52:17327{
Marshall Clowa46482e2012-12-18 16:46:30328 static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)");
Marshall Clow8fc4f5a2013-07-17 18:25:36329 return _VSTD::move(__a.__elems_[_Ip]);
Howard Hinnantcd2254b2010-11-17 19:52:17330}
331
Eric Fiselier199bee02015-12-18 00:36:55332template <size_t _Ip, class _Tp, size_t _Size>
333inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
334const _Tp&&
335get(const array<_Tp, _Size>&& __a) _NOEXCEPT
336{
337 static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)");
338 return _VSTD::move(__a.__elems_[_Ip]);
339}
340
Eric Fiselier6c26be62017-04-16 02:50:40341#endif // !_LIBCPP_CXX03_LANG
Howard Hinnantcd2254b2010-11-17 19:52:17342
Howard Hinnantbc8d3f92010-05-11 19:42:16343_LIBCPP_END_NAMESPACE_STD
344
345#endif // _LIBCPP_ARRAY