29 #ifndef _GLIBCXX_DEBUG_ARRAY
30 #define _GLIBCXX_DEBUG_ARRAY 1
32 #pragma GCC system_header
39 namespace std _GLIBCXX_VISIBILITY(default)
43 template<
typename _Tp, std::
size_t _Nm>
46 typedef _Tp value_type;
47 typedef value_type* pointer;
48 typedef const value_type* const_pointer;
49 typedef value_type& reference;
50 typedef const value_type& const_reference;
51 typedef value_type* iterator;
52 typedef const value_type* const_iterator;
53 typedef std::size_t size_type;
54 typedef std::ptrdiff_t difference_type;
59 typedef _GLIBCXX_STD_C::__array_traits<_Tp, _Nm> _AT_Type;
60 typename _AT_Type::_Type _M_elems;
62 template<std::
size_t _Size>
63 struct _Array_check_subscript
65 std::size_t size() {
return _Size; }
67 _Array_check_subscript(std::size_t __index)
68 { __glibcxx_check_subscript(__index); }
71 template<std::
size_t _Size>
72 struct _Array_check_nonempty
74 bool empty() {
return _Size == 0; }
76 _Array_check_nonempty()
77 { __glibcxx_check_nonempty(); }
84 fill(
const value_type& __u)
89 noexcept(__is_nothrow_swappable<_Tp>::value)
95 {
return iterator(data()); }
98 begin() const noexcept
99 {
return const_iterator(data()); }
103 {
return iterator(data() + _Nm); }
107 {
return const_iterator(data() + _Nm); }
111 {
return reverse_iterator(
end()); }
113 const_reverse_iterator
115 {
return const_reverse_iterator(
end()); }
119 {
return reverse_iterator(
begin()); }
121 const_reverse_iterator
122 rend() const noexcept
123 {
return const_reverse_iterator(
begin()); }
127 {
return const_iterator(data()); }
130 cend() const noexcept
131 {
return const_iterator(data() + _Nm); }
133 const_reverse_iterator
135 {
return const_reverse_iterator(
end()); }
137 const_reverse_iterator
138 crend() const noexcept
139 {
return const_reverse_iterator(
begin()); }
143 size() const noexcept {
return _Nm; }
146 max_size() const noexcept {
return _Nm; }
149 empty() const noexcept {
return size() == 0; }
153 operator[](size_type __n) noexcept
155 __glibcxx_check_subscript(__n);
156 return _AT_Type::_S_ref(_M_elems, __n);
159 constexpr const_reference
160 operator[](size_type __n)
const noexcept
162 return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
163 : (_GLIBCXX_THROW_OR_ABORT(_Array_check_subscript<_Nm>(__n)),
164 _AT_Type::_S_ref(_M_elems, 0));
171 std::__throw_out_of_range_fmt(__N(
"array::at: __n "
172 "(which is %zu) >= _Nm "
175 return _AT_Type::_S_ref(_M_elems, __n);
178 constexpr const_reference
179 at(size_type __n)
const
183 return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
184 : (std::__throw_out_of_range_fmt(__N(
"array::at: __n (which is %zu) "
185 ">= _Nm (which is %zu)"),
187 _AT_Type::_S_ref(_M_elems, 0));
193 __glibcxx_check_nonempty();
197 constexpr const_reference
198 front() const noexcept
200 return _Nm ? _AT_Type::_S_ref(_M_elems, 0)
201 : (_GLIBCXX_THROW_OR_ABORT(_Array_check_nonempty<_Nm>()),
202 _AT_Type::_S_ref(_M_elems, 0));
208 __glibcxx_check_nonempty();
209 return _Nm ? *(
end() - 1) : *
end();
212 constexpr const_reference
213 back() const noexcept
215 return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
216 : (_GLIBCXX_THROW_OR_ABORT(_Array_check_nonempty<_Nm>()),
217 _AT_Type::_S_ref(_M_elems, 0));
222 {
return _AT_Type::_S_ptr(_M_elems); }
225 data() const noexcept
226 {
return _AT_Type::_S_ptr(_M_elems); }
230 template<
typename _Tp, std::
size_t _Nm>
232 operator==(
const array<_Tp, _Nm>& __one,
const array<_Tp, _Nm>& __two)
233 {
return std::equal(__one.begin(), __one.end(), __two.begin()); }
235 template<
typename _Tp, std::
size_t _Nm>
237 operator!=(
const array<_Tp, _Nm>& __one,
const array<_Tp, _Nm>& __two)
238 {
return !(__one == __two); }
240 template<
typename _Tp, std::
size_t _Nm>
242 operator<(const array<_Tp, _Nm>& __a,
const array<_Tp, _Nm>& __b)
245 __b.begin(), __b.end());
248 template<
typename _Tp, std::
size_t _Nm>
250 operator>(
const array<_Tp, _Nm>& __one,
const array<_Tp, _Nm>& __two)
251 {
return __two < __one; }
253 template<
typename _Tp, std::
size_t _Nm>
255 operator<=(const array<_Tp, _Nm>& __one,
const array<_Tp, _Nm>& __two)
256 {
return !(__one > __two); }
258 template<
typename _Tp, std::
size_t _Nm>
260 operator>=(
const array<_Tp, _Nm>& __one,
const array<_Tp, _Nm>& __two)
261 {
return !(__one < __two); }
264 template<
typename _Tp, std::
size_t _Nm>
266 swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
267 noexcept(noexcept(__one.swap(__two)))
268 { __one.swap(__two); }
270 template<std::
size_t _Int,
typename _Tp, std::
size_t _Nm>
272 get(array<_Tp, _Nm>&
__arr) noexcept
274 static_assert(_Int < _Nm,
"index is out of bounds");
275 return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
276 _S_ref(
__arr._M_elems, _Int);
279 template<std::
size_t _Int,
typename _Tp, std::
size_t _Nm>
281 get(array<_Tp, _Nm>&&
__arr) noexcept
283 static_assert(_Int < _Nm,
"index is out of bounds");
284 return std::move(__debug::get<_Int>(
__arr));
287 template<std::
size_t _Int,
typename _Tp, std::
size_t _Nm>
289 get(
const array<_Tp, _Nm>&
__arr) noexcept
291 static_assert(_Int < _Nm,
"index is out of bounds");
292 return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
293 _S_ref(
__arr._M_elems, _Int);
297 _GLIBCXX_BEGIN_NAMESPACE_VERSION
301 template<
typename _Tp, std::
size_t _Nm>
306 template<std::
size_t _Int,
typename _Tp, std::
size_t _Nm>
309 static_assert(_Int < _Nm,
"index is out of bounds");
313 template<
typename _Tp, std::
size_t _Nm>
314 struct __is_tuple_like_impl<std::__debug::array<_Tp, _Nm>> :
true_type
317 _GLIBCXX_END_NAMESPACE_VERSION
320 #endif // _GLIBCXX_DEBUG_ARRAY
auto rend(_Container &__cont) -> decltype(__cont.rend())
Return a reverse iterator pointing one past the first element of the container.
auto crend(const _Container &__cont) -> decltype(std::rend(__cont))
Return a reverse iterator pointing one past the first element of the const container.
void swap(basic_filebuf< _CharT, _Traits > &__x, basic_filebuf< _CharT, _Traits > &__y)
Swap specialization for filebufs.
bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _Compare __comp)
Performs dictionary comparison on ranges.
constexpr auto cbegin(const _Container &__cont) noexcept(noexcept(std::begin(__cont))) -> decltype(std::begin(__cont))
Return an iterator pointing to the first element of the const container.
constexpr const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
bool equal(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred)
Tests a range for element-wise equality.
_ForwardIterator2 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
Swap the elements of two sequences.
constexpr const _Tp * end(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to one past the last element of the initializer_list. ...
constexpr auto cend(const _Container &__cont) noexcept(noexcept(std::end(__cont))) -> decltype(std::end(__cont))
Return an iterator pointing to one past the last element of the const container.
auto crbegin(const _Container &__cont) -> decltype(std::rbegin(__cont))
Return a reverse iterator pointing to the last element of the const container.
auto rbegin(_Container &__cont) -> decltype(__cont.rbegin())
Return a reverse iterator pointing to the last element of the container.
_GLIBCXX14_CONSTEXPR _Tp *return __arr
Return an iterator pointing to the first element of the array.
_OI fill_n(_OI __first, _Size __n, const _Tp &__value)
Fills the range [first,first+n) with copies of value.