57#define _STL_VECTOR_H 1
62#if __cplusplus >= 201103L
65#if __cplusplus > 201703L
71#if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR
73__sanitizer_annotate_contiguous_container(
const void*,
const void*,
74 const void*,
const void*);
77namespace std _GLIBCXX_VISIBILITY(default)
79_GLIBCXX_BEGIN_NAMESPACE_VERSION
80_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
83 template<
typename _Tp,
typename _Alloc>
87 rebind<_Tp>::other _Tp_alloc_type;
88 typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer
91 struct _Vector_impl_data
95 pointer _M_end_of_storage;
97 _Vector_impl_data() _GLIBCXX_NOEXCEPT
98 : _M_start(), _M_finish(), _M_end_of_storage()
101#if __cplusplus >= 201103L
102 _Vector_impl_data(_Vector_impl_data&& __x) noexcept
103 : _M_start(__x._M_start), _M_finish(__x._M_finish),
104 _M_end_of_storage(__x._M_end_of_storage)
105 { __x._M_start = __x._M_finish = __x._M_end_of_storage = pointer(); }
109 _M_copy_data(_Vector_impl_data
const& __x) _GLIBCXX_NOEXCEPT
111 _M_start = __x._M_start;
112 _M_finish = __x._M_finish;
113 _M_end_of_storage = __x._M_end_of_storage;
117 _M_swap_data(_Vector_impl_data& __x) _GLIBCXX_NOEXCEPT
121 _Vector_impl_data __tmp;
122 __tmp._M_copy_data(*
this);
124 __x._M_copy_data(__tmp);
129 :
public _Tp_alloc_type,
public _Vector_impl_data
131 _Vector_impl() _GLIBCXX_NOEXCEPT_IF(
136 _Vector_impl(_Tp_alloc_type
const& __a) _GLIBCXX_NOEXCEPT
137 : _Tp_alloc_type(__a)
140#if __cplusplus >= 201103L
143 _Vector_impl(_Vector_impl&& __x) noexcept
147 _Vector_impl(_Tp_alloc_type&& __a) noexcept
151 _Vector_impl(_Tp_alloc_type&& __a, _Vector_impl&& __rv) noexcept
156#if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR
157 template<
typename = _Tp_alloc_type>
161 ::size_type size_type;
163 static void _S_shrink(_Vector_impl&, size_type) { }
164 static void _S_on_dealloc(_Vector_impl&) { }
166 typedef _Vector_impl& _Reinit;
170 _Grow(_Vector_impl&, size_type) { }
171 void _M_grew(size_type) { }
176 template<
typename _Up>
180 ::size_type size_type;
185 _S_adjust(_Vector_impl& __impl, pointer __prev, pointer __curr)
187 __sanitizer_annotate_contiguous_container(__impl._M_start,
188 __impl._M_end_of_storage, __prev, __curr);
192 _S_grow(_Vector_impl& __impl, size_type __n)
193 { _S_adjust(__impl, __impl._M_finish, __impl._M_finish + __n); }
196 _S_shrink(_Vector_impl& __impl, size_type __n)
197 { _S_adjust(__impl, __impl._M_finish + __n, __impl._M_finish); }
200 _S_on_dealloc(_Vector_impl& __impl)
203 _S_adjust(__impl, __impl._M_finish, __impl._M_end_of_storage);
209 explicit _Reinit(_Vector_impl& __impl) : _M_impl(__impl)
212 _S_on_dealloc(_M_impl);
218 if (_M_impl._M_start)
219 _S_adjust(_M_impl, _M_impl._M_end_of_storage,
223 _Vector_impl& _M_impl;
225#if __cplusplus >= 201103L
226 _Reinit(
const _Reinit&) =
delete;
227 _Reinit& operator=(
const _Reinit&) =
delete;
234 _Grow(_Vector_impl& __impl, size_type __n)
235 : _M_impl(__impl), _M_n(__n)
236 { _S_grow(_M_impl, __n); }
238 ~_Grow() {
if (_M_n) _S_shrink(_M_impl, _M_n); }
240 void _M_grew(size_type __n) { _M_n -= __n; }
242#if __cplusplus >= 201103L
243 _Grow(
const _Grow&) =
delete;
244 _Grow& operator=(
const _Grow&) =
delete;
247 _Vector_impl& _M_impl;
252#define _GLIBCXX_ASAN_ANNOTATE_REINIT \
253 typename _Base::_Vector_impl::template _Asan<>::_Reinit const \
254 __attribute__((__unused__)) __reinit_guard(this->_M_impl)
255#define _GLIBCXX_ASAN_ANNOTATE_GROW(n) \
256 typename _Base::_Vector_impl::template _Asan<>::_Grow \
257 __attribute__((__unused__)) __grow_guard(this->_M_impl, (n))
258#define _GLIBCXX_ASAN_ANNOTATE_GREW(n) __grow_guard._M_grew(n)
259#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n) \
260 _Base::_Vector_impl::template _Asan<>::_S_shrink(this->_M_impl, n)
261#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC \
262 _Base::_Vector_impl::template _Asan<>::_S_on_dealloc(this->_M_impl)
264#define _GLIBCXX_ASAN_ANNOTATE_REINIT
265#define _GLIBCXX_ASAN_ANNOTATE_GROW(n)
266#define _GLIBCXX_ASAN_ANNOTATE_GREW(n)
267#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n)
268#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC
273 typedef _Alloc allocator_type;
276 _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
277 {
return this->_M_impl; }
279 const _Tp_alloc_type&
280 _M_get_Tp_allocator()
const _GLIBCXX_NOEXCEPT
281 {
return this->_M_impl; }
284 get_allocator() const _GLIBCXX_NOEXCEPT
285 {
return allocator_type(_M_get_Tp_allocator()); }
287#if __cplusplus >= 201103L
293 _Vector_base(
const allocator_type& __a) _GLIBCXX_NOEXCEPT
297#if !_GLIBCXX_INLINE_VERSION
298 _Vector_base(
size_t __n)
300 { _M_create_storage(__n); }
303 _Vector_base(
size_t __n,
const allocator_type& __a)
305 { _M_create_storage(__n); }
307#if __cplusplus >= 201103L
308 _Vector_base(_Vector_base&&) =
default;
311# if !_GLIBCXX_INLINE_VERSION
312 _Vector_base(_Tp_alloc_type&& __a) noexcept
315 _Vector_base(_Vector_base&& __x,
const allocator_type& __a)
318 if (__x.get_allocator() == __a)
319 this->_M_impl._M_swap_data(__x._M_impl);
322 size_t __n = __x._M_impl._M_finish - __x._M_impl._M_start;
323 _M_create_storage(__n);
328 _Vector_base(
const allocator_type& __a, _Vector_base&& __x)
329 : _M_impl(_Tp_alloc_type(__a),
std::
move(__x._M_impl))
333 ~_Vector_base() _GLIBCXX_NOEXCEPT
335 _M_deallocate(_M_impl._M_start,
336 _M_impl._M_end_of_storage - _M_impl._M_start);
340 _Vector_impl _M_impl;
343 _M_allocate(
size_t __n)
346 return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer();
350 _M_deallocate(pointer __p,
size_t __n)
354 _Tr::deallocate(_M_impl, __p, __n);
359 _M_create_storage(
size_t __n)
361 this->_M_impl._M_start = this->_M_allocate(__n);
362 this->_M_impl._M_finish = this->_M_impl._M_start;
363 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
388 template<
typename _Tp,
typename _Alloc = std::allocator<_Tp> >
391#ifdef _GLIBCXX_CONCEPT_CHECKS
393 typedef typename _Alloc::value_type _Alloc_value_type;
394# if __cplusplus < 201103L
395 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
397 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
400#if __cplusplus >= 201103L
402 "std::vector must have a non-const, non-volatile value_type");
403# if __cplusplus > 201703L || defined __STRICT_ANSI__
405 "std::vector must have the same value_type as its allocator");
410 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
414 typedef _Tp value_type;
415 typedef typename _Base::pointer pointer;
416 typedef typename _Alloc_traits::const_pointer const_pointer;
417 typedef typename _Alloc_traits::reference reference;
418 typedef typename _Alloc_traits::const_reference const_reference;
419 typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;
420 typedef __gnu_cxx::__normal_iterator<const_pointer, vector>
424 typedef size_t size_type;
425 typedef ptrdiff_t difference_type;
426 typedef _Alloc allocator_type;
429#if __cplusplus >= 201103L
430 static constexpr bool
433 return noexcept(std::__relocate_a(std::declval<pointer>(),
434 std::declval<pointer>(),
435 std::declval<pointer>(),
436 std::declval<_Tp_alloc_type&>()));
439 static constexpr bool
443 static constexpr bool
449 return _S_nothrow_relocate(__is_move_insertable<_Tp_alloc_type>{});
453 _S_do_relocate(pointer __first, pointer __last, pointer __result,
454 _Tp_alloc_type& __alloc,
true_type)
noexcept
456 return std::__relocate_a(__first, __last, __result, __alloc);
460 _S_do_relocate(pointer, pointer, pointer __result,
465 _S_relocate(pointer __first, pointer __last, pointer __result,
466 _Tp_alloc_type& __alloc)
noexcept
468 using __do_it = __bool_constant<_S_use_relocate()>;
469 return _S_do_relocate(__first, __last, __result, __alloc, __do_it{});
474 using _Base::_M_allocate;
475 using _Base::_M_deallocate;
476 using _Base::_M_impl;
477 using _Base::_M_get_Tp_allocator;
486#if __cplusplus >= 201103L
497 vector(
const allocator_type& __a) _GLIBCXX_NOEXCEPT
500#if __cplusplus >= 201103L
510 vector(size_type __n,
const allocator_type& __a = allocator_type())
511 :
_Base(_S_check_init_len(__n, __a), __a)
512 { _M_default_initialize(__n); }
522 vector(size_type __n,
const value_type& __value,
523 const allocator_type& __a = allocator_type())
524 :
_Base(_S_check_init_len(__n, __a), __a)
525 { _M_fill_initialize(__n, __value); }
536 vector(size_type __n,
const value_type& __value = value_type(),
537 const allocator_type& __a = allocator_type())
538 : _Base(_S_check_init_len(__n, __a), __a)
539 { _M_fill_initialize(__n, __value); }
557 this->_M_impl._M_finish =
558 std::__uninitialized_copy_a(__x.
begin(), __x.
end(),
559 this->_M_impl._M_start,
560 _M_get_Tp_allocator());
563#if __cplusplus >= 201103L
578 this->_M_impl._M_finish =
579 std::__uninitialized_copy_a(__x.begin(), __x.end(),
580 this->_M_impl._M_start,
581 _M_get_Tp_allocator());
592 if (__rv.get_allocator() == __m)
593 this->_M_impl._M_swap_data(__rv._M_impl);
594 else if (!__rv.empty())
596 this->_M_create_storage(__rv.size());
597 this->_M_impl._M_finish =
598 std::__uninitialized_move_a(__rv.begin(), __rv.end(),
599 this->_M_impl._M_start,
600 _M_get_Tp_allocator());
609 vector(std::declval<vector&&>(), std::declval<const allocator_type&>(),
610 std::declval<typename _Alloc_traits::is_always_equal>())) )
626 const allocator_type& __a = allocator_type())
629 _M_range_initialize(__l.begin(), __l.end(),
650#if __cplusplus >= 201103L
651 template<
typename _InputIterator,
652 typename = std::_RequireInputIter<_InputIterator>>
653 vector(_InputIterator __first, _InputIterator __last,
654 const allocator_type& __a = allocator_type())
657 _M_range_initialize(__first, __last,
661 template<
typename _InputIterator>
662 vector(_InputIterator __first, _InputIterator __last,
663 const allocator_type& __a = allocator_type())
667 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
668 _M_initialize_dispatch(__first, __last, _Integral());
680 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
681 _M_get_Tp_allocator());
682 _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC;
697#if __cplusplus >= 201103L
711 constexpr bool __move_storage =
712 _Alloc_traits::_S_propagate_on_move_assign()
713 || _Alloc_traits::_S_always_equal();
714 _M_move_assign(
std::move(__x), __bool_constant<__move_storage>());
732 this->_M_assign_aux(__l.begin(), __l.end(),
749 assign(size_type __n,
const value_type& __val)
750 { _M_fill_assign(__n, __val); }
764#if __cplusplus >= 201103L
765 template<
typename _InputIterator,
766 typename = std::_RequireInputIter<_InputIterator>>
768 assign(_InputIterator __first, _InputIterator __last)
769 { _M_assign_dispatch(__first, __last, __false_type()); }
771 template<
typename _InputIterator>
773 assign(_InputIterator __first, _InputIterator __last)
776 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
777 _M_assign_dispatch(__first, __last, _Integral());
781#if __cplusplus >= 201103L
796 this->_M_assign_aux(__l.begin(), __l.end(),
802 using _Base::get_allocator;
812 {
return iterator(this->_M_impl._M_start); }
821 {
return const_iterator(this->_M_impl._M_start); }
830 {
return iterator(this->_M_impl._M_finish); }
838 end() const _GLIBCXX_NOEXCEPT
839 {
return const_iterator(this->_M_impl._M_finish); }
855 const_reverse_iterator
873 const_reverse_iterator
877#if __cplusplus >= 201103L
885 {
return const_iterator(this->_M_impl._M_start); }
894 {
return const_iterator(this->_M_impl._M_finish); }
901 const_reverse_iterator
910 const_reverse_iterator
919 {
return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
924 {
return _S_max_size(_M_get_Tp_allocator()); }
926#if __cplusplus >= 201103L
939 if (__new_size >
size())
940 _M_default_append(__new_size -
size());
941 else if (__new_size <
size())
942 _M_erase_at_end(this->_M_impl._M_start + __new_size);
957 resize(size_type __new_size,
const value_type& __x)
959 if (__new_size >
size())
960 _M_fill_insert(
end(), __new_size -
size(), __x);
961 else if (__new_size <
size())
962 _M_erase_at_end(this->_M_impl._M_start + __new_size);
977 resize(size_type __new_size, value_type __x = value_type())
979 if (__new_size >
size())
980 _M_fill_insert(
end(), __new_size -
size(), __x);
981 else if (__new_size <
size())
982 _M_erase_at_end(this->_M_impl._M_start + __new_size);
986#if __cplusplus >= 201103L
990 { _M_shrink_to_fit(); }
999 {
return size_type(this->_M_impl._M_end_of_storage
1000 - this->_M_impl._M_start); }
1006 _GLIBCXX_NODISCARD
bool
1045 __glibcxx_requires_subscript(__n);
1046 return *(this->_M_impl._M_start + __n);
1063 __glibcxx_requires_subscript(__n);
1064 return *(this->_M_impl._M_start + __n);
1072 if (__n >= this->
size())
1073 __throw_out_of_range_fmt(__N(
"vector::_M_range_check: __n "
1074 "(which is %zu) >= this->size() "
1095 return (*
this)[__n];
1113 return (*
this)[__n];
1123 __glibcxx_requires_nonempty();
1134 __glibcxx_requires_nonempty();
1145 __glibcxx_requires_nonempty();
1146 return *(
end() - 1);
1156 __glibcxx_requires_nonempty();
1157 return *(
end() - 1);
1169 {
return _M_data_ptr(this->_M_impl._M_start); }
1172 data() const _GLIBCXX_NOEXCEPT
1173 {
return _M_data_ptr(this->_M_impl._M_start); }
1189 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
1191 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
1192 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
1194 ++this->_M_impl._M_finish;
1195 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
1198 _M_realloc_insert(
end(), __x);
1201#if __cplusplus >= 201103L
1206 template<
typename... _Args>
1207#if __cplusplus > 201402L
1212 emplace_back(_Args&&... __args);
1227 __glibcxx_requires_nonempty();
1228 --this->_M_impl._M_finish;
1229 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
1230 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
1233#if __cplusplus >= 201103L
1246 template<
typename... _Args>
1248 emplace(const_iterator __position, _Args&&... __args)
1249 {
return _M_emplace_aux(__position, std::forward<_Args>(__args)...); }
1263 insert(const_iterator __position,
const value_type& __x);
1280#if __cplusplus >= 201103L
1293 insert(const_iterator __position, value_type&& __x)
1294 {
return _M_insert_rval(__position,
std::move(__x)); }
1312 auto __offset = __position -
cbegin();
1313 _M_range_insert(
begin() + __offset, __l.begin(), __l.end(),
1315 return begin() + __offset;
1319#if __cplusplus >= 201103L
1335 insert(const_iterator __position, size_type __n,
const value_type& __x)
1337 difference_type __offset = __position -
cbegin();
1338 _M_fill_insert(
begin() + __offset, __n, __x);
1339 return begin() + __offset;
1356 insert(
iterator __position, size_type __n,
const value_type& __x)
1357 { _M_fill_insert(__position, __n, __x); }
1360#if __cplusplus >= 201103L
1376 template<
typename _InputIterator,
1377 typename = std::_RequireInputIter<_InputIterator>>
1379 insert(const_iterator __position, _InputIterator __first,
1380 _InputIterator __last)
1382 difference_type __offset = __position -
cbegin();
1383 _M_insert_dispatch(
begin() + __offset,
1384 __first, __last, __false_type());
1385 return begin() + __offset;
1402 template<
typename _InputIterator>
1405 _InputIterator __last)
1408 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1409 _M_insert_dispatch(__position, __first, __last, _Integral());
1429#if __cplusplus >= 201103L
1431 {
return _M_erase(
begin() + (__position -
cbegin())); }
1434 {
return _M_erase(__position); }
1456#if __cplusplus >= 201103L
1457 erase(const_iterator __first, const_iterator __last)
1459 const auto __beg =
begin();
1460 const auto __cbeg =
cbegin();
1461 return _M_erase(__beg + (__first - __cbeg), __beg + (__last - __cbeg));
1465 {
return _M_erase(__first, __last); }
1482#if __cplusplus >= 201103L
1483 __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value
1484 || _M_get_Tp_allocator() == __x._M_get_Tp_allocator());
1486 this->_M_impl._M_swap_data(__x._M_impl);
1487 _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(),
1488 __x._M_get_Tp_allocator());
1499 { _M_erase_at_end(this->_M_impl._M_start); }
1506 template<
typename _ForwardIterator>
1509 _ForwardIterator __first, _ForwardIterator __last)
1511 pointer __result = this->_M_allocate(__n);
1514 std::__uninitialized_copy_a(__first, __last, __result,
1515 _M_get_Tp_allocator());
1520 _M_deallocate(__result, __n);
1521 __throw_exception_again;
1530#if __cplusplus < 201103L
1533 template<
typename _Integer>
1535 _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
1537 this->_M_impl._M_start = _M_allocate(_S_check_init_len(
1538 static_cast<size_type
>(__n), _M_get_Tp_allocator()));
1539 this->_M_impl._M_end_of_storage =
1540 this->_M_impl._M_start +
static_cast<size_type
>(__n);
1541 _M_fill_initialize(
static_cast<size_type
>(__n), __value);
1545 template<
typename _InputIterator>
1547 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1550 _M_range_initialize(__first, __last,
1556 template<
typename _InputIterator>
1558 _M_range_initialize(_InputIterator __first, _InputIterator __last,
1562 for (; __first != __last; ++__first)
1563#
if __cplusplus >= 201103L
1564 emplace_back(*__first);
1570 __throw_exception_again;
1575 template<
typename _ForwardIterator>
1577 _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
1581 this->_M_impl._M_start
1582 = this->_M_allocate(_S_check_init_len(__n, _M_get_Tp_allocator()));
1583 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
1584 this->_M_impl._M_finish =
1585 std::__uninitialized_copy_a(__first, __last,
1586 this->_M_impl._M_start,
1587 _M_get_Tp_allocator());
1593 _M_fill_initialize(size_type __n,
const value_type& __value)
1595 this->_M_impl._M_finish =
1596 std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value,
1597 _M_get_Tp_allocator());
1600#if __cplusplus >= 201103L
1603 _M_default_initialize(size_type __n)
1605 this->_M_impl._M_finish =
1606 std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,
1607 _M_get_Tp_allocator());
1618 template<
typename _Integer>
1620 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1621 { _M_fill_assign(__n, __val); }
1624 template<
typename _InputIterator>
1626 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1631 template<
typename _InputIterator>
1633 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1637 template<
typename _ForwardIterator>
1639 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1645 _M_fill_assign(size_type __n,
const value_type& __val);
1653 template<
typename _Integer>
1655 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
1657 { _M_fill_insert(__pos, __n, __val); }
1660 template<
typename _InputIterator>
1662 _M_insert_dispatch(iterator __pos, _InputIterator __first,
1663 _InputIterator __last, __false_type)
1665 _M_range_insert(__pos, __first, __last,
1670 template<
typename _InputIterator>
1672 _M_range_insert(iterator __pos, _InputIterator __first,
1676 template<
typename _ForwardIterator>
1678 _M_range_insert(iterator __pos, _ForwardIterator __first,
1684 _M_fill_insert(iterator __pos, size_type __n,
const value_type& __x);
1686#if __cplusplus >= 201103L
1689 _M_default_append(size_type __n);
1695#if __cplusplus < 201103L
1698 _M_insert_aux(iterator __position,
const value_type& __x);
1701 _M_realloc_insert(iterator __position,
const value_type& __x);
1705 struct _Temporary_value
1707 template<
typename... _Args>
1709 _Temporary_value(
vector* __vec, _Args&&... __args) : _M_this(__vec)
1711 _Alloc_traits::construct(_M_this->_M_impl, _M_ptr(),
1712 std::forward<_Args>(__args)...);
1716 { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); }
1719 _M_val() {
return *_M_ptr(); }
1723 _M_ptr() {
return reinterpret_cast<_Tp*
>(&__buf); }
1726 typename aligned_storage<
sizeof(_Tp),
alignof(_Tp)>::type __buf;
1731 template<
typename _Arg>
1733 _M_insert_aux(iterator __position, _Arg&& __arg);
1735 template<
typename... _Args>
1737 _M_realloc_insert(iterator __position, _Args&&... __args);
1741 _M_insert_rval(const_iterator __position, value_type&& __v);
1744 template<
typename... _Args>
1746 _M_emplace_aux(const_iterator __position, _Args&&... __args);
1750 _M_emplace_aux(const_iterator __position, value_type&& __v)
1751 {
return _M_insert_rval(__position,
std::move(__v)); }
1756 _M_check_len(size_type __n,
const char* __s)
const
1759 __throw_length_error(__N(__s));
1767 _S_check_init_len(size_type __n,
const allocator_type& __a)
1769 if (__n > _S_max_size(_Tp_alloc_type(__a)))
1770 __throw_length_error(
1771 __N(
"cannot create std::vector larger than max_size()"));
1776 _S_max_size(
const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
1781 const size_t __diffmax
1782 = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max /
sizeof(_Tp);
1784 return (
std::min)(__diffmax, __allocmax);
1792 _M_erase_at_end(pointer __pos) _GLIBCXX_NOEXCEPT
1794 if (size_type __n = this->_M_impl._M_finish - __pos)
1797 _M_get_Tp_allocator());
1798 this->_M_impl._M_finish = __pos;
1799 _GLIBCXX_ASAN_ANNOTATE_SHRINK(__n);
1804 _M_erase(iterator __position);
1807 _M_erase(iterator __first, iterator __last);
1809#if __cplusplus >= 201103L
1818 this->_M_impl._M_swap_data(__x._M_impl);
1819 __tmp._M_impl._M_swap_data(__x._M_impl);
1820 std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator());
1828 if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator())
1834 this->_M_assign_aux(std::make_move_iterator(__x.begin()),
1835 std::make_move_iterator(__x.end()),
1842 template<
typename _Up>
1844 _M_data_ptr(_Up* __ptr)
const _GLIBCXX_NOEXCEPT
1847#if __cplusplus >= 201103L
1848 template<
typename _Ptr>
1850 _M_data_ptr(_Ptr __ptr)
const
1851 {
return empty() ? nullptr : std::__to_address(__ptr); }
1853 template<
typename _Up>
1855 _M_data_ptr(_Up* __ptr) _GLIBCXX_NOEXCEPT
1858 template<
typename _Ptr>
1860 _M_data_ptr(_Ptr __ptr)
1861 {
return empty() ? (value_type*)0 : __ptr.operator->(); }
1863 template<
typename _Ptr>
1865 _M_data_ptr(_Ptr __ptr)
const
1866 {
return empty() ? (
const value_type*)0 : __ptr.operator->(); }
1870#if __cpp_deduction_guides >= 201606
1871 template<
typename _InputIterator,
typename _ValT
1872 =
typename iterator_traits<_InputIterator>::value_type,
1873 typename _Allocator = allocator<_ValT>,
1874 typename = _RequireInputIter<_InputIterator>,
1875 typename = _RequireAllocator<_Allocator>>
1876 vector(_InputIterator, _InputIterator, _Allocator = _Allocator())
1877 -> vector<_ValT, _Allocator>;
1890 template<
typename _Tp,
typename _Alloc>
1896#if __cpp_lib_three_way_comparison
1908 template<
typename _Tp,
typename _Alloc>
1909 inline __detail::__synth3way_t<_Tp>
1910 operator<=>(
const vector<_Tp, _Alloc>& __x,
const vector<_Tp, _Alloc>& __y)
1912 return std::lexicographical_compare_three_way(__x.begin(), __x.end(),
1913 __y.begin(), __y.end(),
1914 __detail::__synth3way);
1928 template<
typename _Tp,
typename _Alloc>
1931 {
return std::lexicographical_compare(__x.
begin(), __x.
end(),
1935 template<
typename _Tp,
typename _Alloc>
1938 {
return !(__x == __y); }
1941 template<
typename _Tp,
typename _Alloc>
1944 {
return __y < __x; }
1947 template<
typename _Tp,
typename _Alloc>
1950 {
return !(__y < __x); }
1953 template<
typename _Tp,
typename _Alloc>
1956 {
return !(__x < __y); }
1960 template<
typename _Tp,
typename _Alloc>
1963 _GLIBCXX_NOEXCEPT_IF(
noexcept(__x.swap(__y)))
1966_GLIBCXX_END_NAMESPACE_CONTAINER
1968#if __cplusplus >= 201703L
1969 namespace __detail::__variant
1971 template<
typename>
struct _Never_valueless_alt;
1975 template<
typename _Tp,
typename _Alloc>
1976 struct _Never_valueless_alt<_GLIBCXX_STD_C::vector<_Tp, _Alloc>>
1982_GLIBCXX_END_NAMESPACE_VERSION
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
void _Destroy(_ForwardIterator __first, _ForwardIterator __last, _Allocator &__alloc)
is_nothrow_default_constructible
is_nothrow_move_assignable
__detected_or_t< typename is_empty< _Alloc >::type, __equal, _Alloc > is_always_equal
Whether all instances of the allocator type compare equal.
The standard allocator, as per C++03 [20.4.1].
Uniform interface to all pointer-like types.
Forward iterators support a superset of input iterator operations.
Random-access iterators support a superset of bidirectional iterator operations.
See bits/stl_deque.h's _Deque_base for an explanation.
A standard container which offers fixed time access to individual elements in any order.
vector(const vector &__x)
Vector copy constructor.
vector(initializer_list< value_type > __l, const allocator_type &__a=allocator_type())
Builds a vector from an initializer list.
void resize(size_type __new_size)
Resizes the vector to the specified number of elements.
reference at(size_type __n)
Provides access to the data contained in the vector.
vector()=default
Creates a vector with no elements.
iterator insert(const_iterator __position, initializer_list< value_type > __l)
Inserts an initializer_list into the vector.
const_reference front() const noexcept
iterator erase(const_iterator __position)
Remove element at given position.
vector & operator=(initializer_list< value_type > __l)
Vector list assignment operator.
reverse_iterator rbegin() noexcept
pointer _M_allocate_and_copy(size_type __n, _ForwardIterator __first, _ForwardIterator __last)
bool empty() const noexcept
const_reverse_iterator crbegin() const noexcept
iterator insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
Inserts a range into the vector.
reference front() noexcept
iterator insert(const_iterator __position, size_type __n, const value_type &__x)
Inserts a number of copies of given data into the vector.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
vector(size_type __n, const value_type &__value, const allocator_type &__a=allocator_type())
Creates a vector with copies of an exemplar element.
reverse_iterator rend() noexcept
void resize(size_type __new_size, const value_type &__x)
Resizes the vector to the specified number of elements.
vector(size_type __n, const allocator_type &__a=allocator_type())
Creates a vector with default constructed elements.
void push_back(const value_type &__x)
Add data to the end of the vector.
const_reference operator[](size_type __n) const noexcept
Subscript access to the data contained in the vector.
size_type max_size() const noexcept
const_reverse_iterator crend() const noexcept
iterator insert(const_iterator __position, value_type &&__x)
Inserts given rvalue into vector before specified iterator.
void _M_range_check(size_type __n) const
Safety check used only from at().
void reserve(size_type __n)
Attempt to preallocate enough memory for specified number of elements.
vector(_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
Builds a vector from a range.
const_iterator begin() const noexcept
void assign(size_type __n, const value_type &__val)
Assigns a given value to a vector.
void swap(vector &__x) noexcept
Swaps data with another vector.
void pop_back() noexcept
Removes last element.
vector & operator=(const vector &__x)
Vector assignment operator.
const_reverse_iterator rend() const noexcept
const_iterator cbegin() const noexcept
const_reference at(size_type __n) const
Provides access to the data contained in the vector.
const_iterator cend() const noexcept
iterator erase(const_iterator __first, const_iterator __last)
Remove a range of elements.
vector(vector &&) noexcept=default
Vector move constructor.
vector(const allocator_type &__a) noexcept
Creates a vector with no elements.
iterator emplace(const_iterator __position, _Args &&... __args)
Inserts an object in vector before specified iterator.
const_reverse_iterator rbegin() const noexcept
iterator begin() noexcept
vector & operator=(vector &&__x) noexcept(_Alloc_traits::_S_nothrow_move())
Vector move assignment operator.
reference back() noexcept
void assign(_InputIterator __first, _InputIterator __last)
Assigns a range to a vector.
void assign(initializer_list< value_type > __l)
Assigns an initializer list to a vector.
iterator insert(const_iterator __position, const value_type &__x)
Inserts given value into vector before specified iterator.
const_reference back() const noexcept
const_iterator end() const noexcept
vector(vector &&__rv, const allocator_type &__m) noexcept(noexcept(vector(std::declval< vector && >(), std::declval< const allocator_type & >(), std::declval< typename _Alloc_traits::is_always_equal >())))
Move constructor with alternative allocator.
size_type size() const noexcept
size_type capacity() const noexcept
reference operator[](size_type __n) noexcept
Subscript access to the data contained in the vector.
Uniform interface to C++98 and C++11 allocators.
static constexpr size_type max_size(const _Tp_alloc_type &__a) noexcept
The maximum supported allocation size.