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