29 #ifndef _GLIBCXX_ARRAY
30 #define _GLIBCXX_ARRAY 1
32 #pragma GCC system_header
34 #if __cplusplus < 201103L
43 namespace std _GLIBCXX_VISIBILITY(default)
45 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
47 template<
typename _Tp, std::
size_t _Nm>
50 typedef _Tp _Type[_Nm];
53 _S_ref(
const _Type& __t, std::size_t __n) noexcept
54 {
return const_cast<_Tp&
>(__t[__n]); }
57 _S_ptr(
const _Type& __t) noexcept
58 {
return const_cast<_Tp*
>(__t); }
61 template<
typename _Tp>
62 struct __array_traits<_Tp, 0>
67 _S_ref(
const _Type&, std::size_t) noexcept
68 {
return *
static_cast<_Tp*
>(
nullptr); }
71 _S_ptr(
const _Type&) noexcept
89 template<
typename _Tp, std::
size_t _Nm>
92 typedef _Tp value_type;
93 typedef value_type* pointer;
94 typedef const value_type* const_pointer;
95 typedef value_type& reference;
96 typedef const value_type& const_reference;
97 typedef value_type* iterator;
98 typedef const value_type* const_iterator;
99 typedef std::size_t size_type;
100 typedef std::ptrdiff_t difference_type;
105 typedef _GLIBCXX_STD_C::__array_traits<_Tp, _Nm> _AT_Type;
106 typename _AT_Type::_Type _M_elems;
112 fill(
const value_type& __u)
117 noexcept(__is_nothrow_swappable<_Tp>::value)
123 {
return iterator(data()); }
126 begin()
const noexcept
127 {
return const_iterator(data()); }
131 {
return iterator(data() + _Nm); }
135 {
return const_iterator(data() + _Nm); }
142 rbegin()
const noexcept
150 rend()
const noexcept
154 cbegin()
const noexcept
155 {
return const_iterator(data()); }
158 cend()
const noexcept
159 {
return const_iterator(data() + _Nm); }
162 crbegin()
const noexcept
166 crend()
const noexcept
171 size()
const noexcept {
return _Nm; }
174 max_size()
const noexcept {
return _Nm; }
177 empty()
const noexcept {
return size() == 0; }
181 operator[](size_type __n) noexcept
182 {
return _AT_Type::_S_ref(_M_elems, __n); }
184 constexpr const_reference
185 operator[](size_type __n)
const noexcept
186 {
return _AT_Type::_S_ref(_M_elems, __n); }
192 std::__throw_out_of_range_fmt(__N(
"array::at: __n (which is %zu) "
193 ">= _Nm (which is %zu)"),
195 return _AT_Type::_S_ref(_M_elems, __n);
198 constexpr const_reference
199 at(size_type __n)
const
203 return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
204 : (std::__throw_out_of_range_fmt(__N(
"array::at: __n (which is %zu) "
205 ">= _Nm (which is %zu)"),
207 _AT_Type::_S_ref(_M_elems, 0));
214 constexpr const_reference
215 front()
const noexcept
216 {
return _AT_Type::_S_ref(_M_elems, 0); }
220 {
return _Nm ? *(end() - 1) : *end(); }
222 constexpr const_reference
223 back()
const noexcept
225 return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
226 : _AT_Type::_S_ref(_M_elems, 0);
231 {
return _AT_Type::_S_ptr(_M_elems); }
234 data()
const noexcept
235 {
return _AT_Type::_S_ptr(_M_elems); }
239 template<
typename _Tp, std::
size_t _Nm>
242 {
return std::equal(__one.begin(), __one.end(), __two.begin()); }
244 template<
typename _Tp, std::
size_t _Nm>
246 operator!=(
const array<_Tp, _Nm>& __one,
const array<_Tp, _Nm>& __two)
247 {
return !(__one == __two); }
249 template<
typename _Tp, std::
size_t _Nm>
251 operator<(const array<_Tp, _Nm>& __a,
const array<_Tp, _Nm>& __b)
254 __b.begin(), __b.end());
257 template<
typename _Tp, std::
size_t _Nm>
259 operator>(
const array<_Tp, _Nm>& __one,
const array<_Tp, _Nm>& __two)
260 {
return __two < __one; }
262 template<
typename _Tp, std::
size_t _Nm>
264 operator<=(const array<_Tp, _Nm>& __one,
const array<_Tp, _Nm>& __two)
265 {
return !(__one > __two); }
267 template<
typename _Tp, std::
size_t _Nm>
269 operator>=(
const array<_Tp, _Nm>& __one,
const array<_Tp, _Nm>& __two)
270 {
return !(__one < __two); }
273 template<
typename _Tp, std::
size_t _Nm>
275 swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
276 noexcept(noexcept(__one.swap(__two)))
277 { __one.swap(__two); }
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 _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
285 _S_ref(
__arr._M_elems, _Int);
288 template<std::
size_t _Int,
typename _Tp, std::
size_t _Nm>
290 get(array<_Tp, _Nm>&&
__arr) noexcept
292 static_assert(_Int < _Nm,
"index is out of bounds");
293 return std::move(_GLIBCXX_STD_C::get<_Int>(
__arr));
296 template<std::
size_t _Int,
typename _Tp, std::
size_t _Nm>
298 get(
const array<_Tp, _Nm>&
__arr) noexcept
300 static_assert(_Int < _Nm,
"index is out of bounds");
301 return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
302 _S_ref(
__arr._M_elems, _Int);
305 _GLIBCXX_END_NAMESPACE_CONTAINER
308 namespace std _GLIBCXX_VISIBILITY(default)
310 _GLIBCXX_BEGIN_NAMESPACE_VERSION
315 template<
typename _Tp>
319 template<
typename _Tp, std::
size_t _Nm>
324 template<std::
size_t _Int,
typename _Tp>
328 template<std::
size_t _Int,
typename _Tp, std::
size_t _Nm>
331 static_assert(_Int < _Nm,
"index is out of bounds");
335 template<
typename _Tp, std::
size_t _Nm>
336 struct __is_tuple_like_impl<_GLIBCXX_STD_C::
array<_Tp, _Nm>> :
true_type
339 _GLIBCXX_END_NAMESPACE_VERSION
342 #ifdef _GLIBCXX_DEBUG
346 #ifdef _GLIBCXX_PROFILE
347 # include <profile/array>
352 #endif // _GLIBCXX_ARRAY
void swap(basic_filebuf< _CharT, _Traits > &__x, basic_filebuf< _CharT, _Traits > &__y)
Swap specialization for filebufs.
A standard container for storing a fixed size sequence of elements.
bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _Compare __comp)
Performs dictionary comparison on ranges.
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.
_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.