90 rebind<_Tp>::other _Tp_alloc_type;
91 typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer
94 struct _Vector_impl_data
98 pointer _M_end_of_storage;
101 _Vector_impl_data() _GLIBCXX_NOEXCEPT
102 : _M_start(), _M_finish(), _M_end_of_storage()
105#if __cplusplus >= 201103L
107 _Vector_impl_data(_Vector_impl_data&& __x) noexcept
108 : _M_start(__x._M_start), _M_finish(__x._M_finish),
109 _M_end_of_storage(__x._M_end_of_storage)
110 { __x._M_start = __x._M_finish = __x._M_end_of_storage = pointer(); }
115 _M_copy_data(_Vector_impl_data
const& __x) _GLIBCXX_NOEXCEPT
117 _M_start = __x._M_start;
118 _M_finish = __x._M_finish;
119 _M_end_of_storage = __x._M_end_of_storage;
124 _M_swap_data(_Vector_impl_data& __x) _GLIBCXX_NOEXCEPT
128 _Vector_impl_data __tmp;
129 __tmp._M_copy_data(*
this);
131 __x._M_copy_data(__tmp);
136 :
public _Tp_alloc_type,
public _Vector_impl_data
139 _Vector_impl() _GLIBCXX_NOEXCEPT_IF(
141#if __cpp_lib_concepts
142 requires is_default_constructible_v<_Tp_alloc_type>
148 _Vector_impl(_Tp_alloc_type
const& __a) _GLIBCXX_NOEXCEPT
149 : _Tp_alloc_type(__a)
152#if __cplusplus >= 201103L
156 _Vector_impl(_Vector_impl&& __x) noexcept
161 _Vector_impl(_Tp_alloc_type&& __a) noexcept
166 _Vector_impl(_Tp_alloc_type&& __a, _Vector_impl&& __rv) noexcept
171#if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR
172 template<
typename = _Tp_alloc_type>
178 static _GLIBCXX20_CONSTEXPR
void
180 static _GLIBCXX20_CONSTEXPR
void
181 _S_on_dealloc(_Vector_impl&) { }
183 typedef _Vector_impl& _Reinit;
187 _GLIBCXX20_CONSTEXPR _Grow(_Vector_impl&,
size_type) { }
188 _GLIBCXX20_CONSTEXPR
void _M_grew(
size_type) { }
193 template<
typename _Up>
201 static _GLIBCXX20_CONSTEXPR
void
202 _S_adjust(_Vector_impl& __impl, pointer __prev, pointer __curr)
204#if __cpp_lib_is_constant_evaluated
205 if (std::is_constant_evaluated())
208 __sanitizer_annotate_contiguous_container(__impl._M_start,
209 __impl._M_end_of_storage, __prev, __curr);
212 static _GLIBCXX20_CONSTEXPR
void
213 _S_grow(_Vector_impl& __impl,
size_type __n)
214 { _S_adjust(__impl, __impl._M_finish, __impl._M_finish + __n); }
216 static _GLIBCXX20_CONSTEXPR
void
217 _S_shrink(_Vector_impl& __impl,
size_type __n)
218 { _S_adjust(__impl, __impl._M_finish + __n, __impl._M_finish); }
220 static _GLIBCXX20_CONSTEXPR
void
221 _S_on_dealloc(_Vector_impl& __impl)
224 _S_adjust(__impl, __impl._M_finish, __impl._M_end_of_storage);
230 explicit _GLIBCXX20_CONSTEXPR
231 _Reinit(_Vector_impl& __impl) : _M_impl(__impl)
234 _S_on_dealloc(_M_impl);
241 if (_M_impl._M_start)
242 _S_adjust(_M_impl, _M_impl._M_end_of_storage,
246 _Vector_impl& _M_impl;
248#if __cplusplus >= 201103L
249 _Reinit(
const _Reinit&) =
delete;
250 _Reinit& operator=(
const _Reinit&) =
delete;
258 _Grow(_Vector_impl& __impl,
size_type __n)
259 : _M_impl(__impl), _M_n(__n)
260 { _S_grow(_M_impl, __n); }
263 ~_Grow() {
if (_M_n) _S_shrink(_M_impl, _M_n); }
266 void _M_grew(
size_type __n) { _M_n -= __n; }
268#if __cplusplus >= 201103L
269 _Grow(
const _Grow&) =
delete;
270 _Grow& operator=(
const _Grow&) =
delete;
273 _Vector_impl& _M_impl;
278#define _GLIBCXX_ASAN_ANNOTATE_REINIT \
279 typename _Base::_Vector_impl::template _Asan<>::_Reinit const \
280 __attribute__((__unused__)) __reinit_guard(this->_M_impl)
281#define _GLIBCXX_ASAN_ANNOTATE_GROW(n) \
282 typename _Base::_Vector_impl::template _Asan<>::_Grow \
283 __attribute__((__unused__)) __grow_guard(this->_M_impl, (n))
284#define _GLIBCXX_ASAN_ANNOTATE_GREW(n) __grow_guard._M_grew(n)
285#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n) \
286 _Base::_Vector_impl::template _Asan<>::_S_shrink(this->_M_impl, n)
287#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC \
288 _Base::_Vector_impl::template _Asan<>::_S_on_dealloc(this->_M_impl)
290#define _GLIBCXX_ASAN_ANNOTATE_REINIT
291#define _GLIBCXX_ASAN_ANNOTATE_GROW(n)
292#define _GLIBCXX_ASAN_ANNOTATE_GREW(n)
293#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n)
294#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC
299 typedef _Alloc allocator_type;
303 _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
304 {
return this->_M_impl; }
307 const _Tp_alloc_type&
308 _M_get_Tp_allocator()
const _GLIBCXX_NOEXCEPT
309 {
return this->_M_impl; }
314 {
return allocator_type(_M_get_Tp_allocator()); }
316#if __cplusplus >= 201103L
323 _Vector_base(
const allocator_type& __a) _GLIBCXX_NOEXCEPT
327#if !_GLIBCXX_INLINE_VERSION
329 _Vector_base(
size_t __n)
331 { _M_create_storage(__n); }
335 _Vector_base(
size_t __n,
const allocator_type& __a)
337 { _M_create_storage(__n); }
339#if __cplusplus >= 201103L
340 _Vector_base(_Vector_base&&) =
default;
343# if !_GLIBCXX_INLINE_VERSION
345 _Vector_base(_Tp_alloc_type&& __a) noexcept
349 _Vector_base(_Vector_base&& __x,
const allocator_type& __a)
352 if (__x.get_allocator() == __a)
353 this->_M_impl._M_swap_data(__x._M_impl);
356 size_t __n = __x._M_impl._M_finish - __x._M_impl._M_start;
357 _M_create_storage(__n);
363 _Vector_base(
const allocator_type& __a, _Vector_base&& __x)
364 : _M_impl(_Tp_alloc_type(__a), std::
move(__x._M_impl))
369 ~_Vector_base() _GLIBCXX_NOEXCEPT
371 _M_deallocate(_M_impl._M_start,
372 _M_impl._M_end_of_storage - _M_impl._M_start);
376 _Vector_impl _M_impl;
380 _M_allocate(
size_t __n)
382 typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr;
383 return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer();
388 _M_deallocate(pointer __p,
size_t __n)
390 typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr;
392 _Tr::deallocate(_M_impl, __p, __n);
399 _M_create_storage(
size_t __n)
401 this->_M_impl._M_start = this->_M_allocate(__n);
402 this->_M_impl._M_finish = this->_M_impl._M_start;
403 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
431 class vector :
protected _Vector_base<_Tp, _Alloc>
433#ifdef _GLIBCXX_CONCEPT_CHECKS
435 typedef typename _Alloc::value_type _Alloc_value_type;
436# if __cplusplus < 201103L
437 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
439 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
442#if __cplusplus >= 201103L
444 "std::vector must have a non-const, non-volatile value_type");
445# if __cplusplus > 201703L || defined __STRICT_ANSI__
447 "std::vector must have the same value_type as its allocator");
451 typedef _Vector_base<_Tp, _Alloc> _Base;
452 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
456 typedef _Tp value_type;
457 typedef typename _Base::pointer pointer;
458 typedef typename _Alloc_traits::const_pointer const_pointer;
459 typedef typename _Alloc_traits::reference reference;
460 typedef typename _Alloc_traits::const_reference const_reference;
461 typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;
462 typedef __gnu_cxx::__normal_iterator<const_pointer, vector>
466 typedef size_t size_type;
467 typedef ptrdiff_t difference_type;
468 typedef _Alloc allocator_type;
471#if __cplusplus >= 201103L
472 static constexpr bool
481 static constexpr bool
485 static constexpr bool
491 return _S_nothrow_relocate(__is_move_insertable<_Tp_alloc_type>{});
495 _S_do_relocate(pointer __first, pointer __last, pointer __result,
496 _Tp_alloc_type& __alloc,
true_type)
noexcept
498 return std::__relocate_a(__first, __last, __result, __alloc);
502 _S_do_relocate(pointer, pointer, pointer __result,
506 static _GLIBCXX20_CONSTEXPR pointer
507 _S_relocate(pointer __first, pointer __last, pointer __result,
508 _Tp_alloc_type& __alloc)
noexcept
510#if __cpp_if_constexpr
512 return std::__relocate_a(__first, __last, __result, __alloc);
514 using __do_it = __bool_constant<_S_use_relocate()>;
515 return _S_do_relocate(__first, __last, __result, __alloc, __do_it{});
521 using _Base::_M_allocate;
522 using _Base::_M_deallocate;
523 using _Base::_M_impl;
524 using _Base::_M_get_Tp_allocator;
533#if __cplusplus >= 201103L
545 vector(
const allocator_type& __a) _GLIBCXX_NOEXCEPT
548#if __cplusplus >= 201103L
559 vector(size_type __n,
const allocator_type& __a = allocator_type())
560 : _Base(_S_check_init_len(__n, __a), __a)
561 { _M_default_initialize(__n); }
572 vector(size_type __n,
const value_type& __value,
573 const allocator_type& __a = allocator_type())
574 : _Base(_S_check_init_len(__n, __a), __a)
575 { _M_fill_initialize(__n, __value); }
587 const allocator_type& __a = allocator_type())
588 : _Base(_S_check_init_len(__n, __a), __a)
589 { _M_fill_initialize(__n, __value); }
606 _Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator()))
608 this->_M_impl._M_finish =
609 std::__uninitialized_copy_a(__x.
begin(), __x.
end(),
610 this->_M_impl._M_start,
611 _M_get_Tp_allocator());
614#if __cplusplus >= 201103L
627 vector(const
vector& __x, const __type_identity_t<allocator_type>& __a)
628 : _Base(__x.
size(), __a)
630 this->_M_impl._M_finish =
631 std::__uninitialized_copy_a(__x.begin(), __x.end(),
632 this->_M_impl._M_start,
633 _M_get_Tp_allocator());
643 vector(vector&& __rv,
const allocator_type& __m, false_type)
646 if (__rv.get_allocator() == __m)
647 this->_M_impl._M_swap_data(__rv._M_impl);
648 else if (!__rv.empty())
650 this->_M_create_storage(__rv.size());
651 this->_M_impl._M_finish =
652 std::__uninitialized_move_a(__rv.begin(), __rv.end(),
653 this->_M_impl._M_start,
654 _M_get_Tp_allocator());
666 :
vector(
std::
move(__rv), __m, typename _Alloc_traits::is_always_equal{})
682 const allocator_type& __a = allocator_type())
685 _M_range_initialize_n(__l.begin(), __l.end(), __l.size());
705#if __cplusplus >= 201103L
706 template<
typename _InputIterator,
707 typename = std::_RequireInputIter<_InputIterator>>
709 vector(_InputIterator __first, _InputIterator __last,
710 const allocator_type& __a = allocator_type())
713#if __glibcxx_concepts
714 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>
715 || forward_iterator<_InputIterator>)
718 =
static_cast<size_type
>(ranges::distance(__first, __last));
719 _M_range_initialize_n(__first, __last, __n);
724 _M_range_initialize(__first, __last,
728 template<
typename _InputIterator>
729 vector(_InputIterator __first, _InputIterator __last,
730 const allocator_type& __a = allocator_type())
734 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
735 _M_initialize_dispatch(__first, __last, _Integral());
748 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
749 _M_get_Tp_allocator());
750 _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC;
766#if __cplusplus >= 201103L
781 constexpr bool __move_storage =
782 _Alloc_traits::_S_propagate_on_move_assign()
783 || _Alloc_traits::_S_always_equal();
784 _M_move_assign(
std::move(__x), __bool_constant<__move_storage>());
803 this->_M_assign_aux(__l.begin(), __l.end(),
821 assign(size_type __n,
const value_type& __val)
822 { _M_fill_assign(__n, __val); }
836#if __cplusplus >= 201103L
837 template<
typename _InputIterator,
838 typename = std::_RequireInputIter<_InputIterator>>
841 assign(_InputIterator __first, _InputIterator __last)
844 template<
typename _InputIterator>
846 assign(_InputIterator __first, _InputIterator __last)
849 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
850 _M_assign_dispatch(__first, __last, _Integral());
854#if __cplusplus >= 201103L
870 this->_M_assign_aux(__l.begin(), __l.end(),
876 using _Base::get_allocator;
884 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
887 {
return iterator(this->_M_impl._M_start); }
894 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
897 {
return const_iterator(this->_M_impl._M_start); }
904 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
907 {
return iterator(this->_M_impl._M_finish); }
914 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
916 end() const _GLIBCXX_NOEXCEPT
917 {
return const_iterator(this->_M_impl._M_finish); }
924 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
927 {
return reverse_iterator(
end()); }
934 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
935 const_reverse_iterator
937 {
return const_reverse_iterator(
end()); }
944 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
947 {
return reverse_iterator(
begin()); }
954 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
955 const_reverse_iterator
957 {
return const_reverse_iterator(
begin()); }
959#if __cplusplus >= 201103L
965 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
968 {
return const_iterator(this->_M_impl._M_start); }
975 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
978 {
return const_iterator(this->_M_impl._M_finish); }
985 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
986 const_reverse_iterator
988 {
return const_reverse_iterator(
end()); }
995 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
996 const_reverse_iterator
998 {
return const_reverse_iterator(
begin()); }
1003 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1006 {
return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
1009 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1012 {
return _S_max_size(_M_get_Tp_allocator()); }
1014#if __cplusplus >= 201103L
1024 _GLIBCXX20_CONSTEXPR
1028 if (__new_size >
size())
1029 _M_default_append(__new_size -
size());
1030 else if (__new_size <
size())
1031 _M_erase_at_end(this->_M_impl._M_start + __new_size);
1045 _GLIBCXX20_CONSTEXPR
1047 resize(size_type __new_size,
const value_type& __x)
1049 if (__new_size >
size())
1050 _M_fill_append(__new_size -
size(), __x);
1051 else if (__new_size <
size())
1052 _M_erase_at_end(this->_M_impl._M_start + __new_size);
1066 _GLIBCXX20_CONSTEXPR
1070 if (__new_size >
size())
1071 _M_fill_append(__new_size -
size(), __x);
1072 else if (__new_size <
size())
1073 _M_erase_at_end(this->_M_impl._M_start + __new_size);
1077#if __cplusplus >= 201103L
1079 _GLIBCXX20_CONSTEXPR
1082 { _M_shrink_to_fit(); }
1089 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1093 return size_type(this->_M_impl._M_end_of_storage
1094 - this->_M_impl._M_start);
1101 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1123 _GLIBCXX20_CONSTEXPR
1139 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1143 __glibcxx_requires_subscript(__n);
1144 return *(this->_M_impl._M_start + __n);
1158 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1162 __glibcxx_requires_subscript(__n);
1163 return *(this->_M_impl._M_start + __n);
1168 _GLIBCXX20_CONSTEXPR
1172 if (__n >= this->
size())
1173 __throw_out_of_range_fmt(__N(
"vector::_M_range_check: __n "
1174 "(which is %zu) >= this->size() "
1191 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1196 return (*
this)[__n];
1210 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1215 return (*
this)[__n];
1222 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1226 __glibcxx_requires_nonempty();
1234 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1238 __glibcxx_requires_nonempty();
1246 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1250 __glibcxx_requires_nonempty();
1251 return *(
end() - 1);
1258 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1262 __glibcxx_requires_nonempty();
1263 return *(
end() - 1);
1273 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1276 {
return _M_data_ptr(this->_M_impl._M_start); }
1278 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1280 data() const _GLIBCXX_NOEXCEPT
1281 {
return _M_data_ptr(this->_M_impl._M_start); }
1294 _GLIBCXX20_CONSTEXPR
1298 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
1300 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
1301 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
1303 ++this->_M_impl._M_finish;
1304 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
1307 _M_realloc_append(__x);
1310#if __cplusplus >= 201103L
1311 _GLIBCXX20_CONSTEXPR
1316 template<
typename... _Args>
1317#if __cplusplus > 201402L
1318 _GLIBCXX20_CONSTEXPR
1323 emplace_back(_Args&&... __args);
1335 _GLIBCXX20_CONSTEXPR
1339 __glibcxx_requires_nonempty();
1340 --this->_M_impl._M_finish;
1341 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
1342 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
1345#if __cplusplus >= 201103L
1358 template<
typename... _Args>
1359 _GLIBCXX20_CONSTEXPR
1361 emplace(const_iterator __position, _Args&&... __args)
1375 _GLIBCXX20_CONSTEXPR
1377 insert(const_iterator __position,
const value_type& __x);
1391 insert(iterator __position,
const value_type& __x);
1394#if __cplusplus >= 201103L
1406 _GLIBCXX20_CONSTEXPR
1408 insert(const_iterator __position, value_type&& __x)
1409 {
return _M_insert_rval(__position,
std::move(__x)); }
1424 _GLIBCXX20_CONSTEXPR
1428 auto __offset = __position -
cbegin();
1429 _M_range_insert(
begin() + __offset, __l.begin(), __l.end(),
1431 return begin() + __offset;
1435#if __cplusplus >= 201103L
1450 _GLIBCXX20_CONSTEXPR
1452 insert(const_iterator __position, size_type __n,
const value_type& __x)
1454 difference_type __offset = __position -
cbegin();
1455 _M_fill_insert(
begin() + __offset, __n, __x);
1456 return begin() + __offset;
1474 { _M_fill_insert(__position, __n, __x); }
1477#if __cplusplus >= 201103L
1493 template<
typename _InputIterator,
1494 typename = std::_RequireInputIter<_InputIterator>>
1495 _GLIBCXX20_CONSTEXPR
1497 insert(const_iterator __position, _InputIterator __first,
1498 _InputIterator __last)
1500 difference_type __offset = __position -
cbegin();
1501 _M_range_insert(
begin() + __offset, __first, __last,
1503 return begin() + __offset;
1520 template<
typename _InputIterator>
1523 _InputIterator __last)
1526 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1527 _M_insert_dispatch(__position, __first, __last, _Integral());
1546 _GLIBCXX20_CONSTEXPR
1548#if __cplusplus >= 201103L
1550 {
return _M_erase(
begin() + (__position -
cbegin())); }
1553 {
return _M_erase(__position); }
1574 _GLIBCXX20_CONSTEXPR
1576#if __cplusplus >= 201103L
1577 erase(const_iterator __first, const_iterator __last)
1579 const auto __beg =
begin();
1580 const auto __cbeg =
cbegin();
1581 return _M_erase(__beg + (__first - __cbeg), __beg + (__last - __cbeg));
1585 {
return _M_erase(__first, __last); }
1599 _GLIBCXX20_CONSTEXPR
1603#if __cplusplus >= 201103L
1604 __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value
1605 || _M_get_Tp_allocator() == __x._M_get_Tp_allocator());
1607 this->_M_impl._M_swap_data(__x._M_impl);
1608 _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(),
1609 __x._M_get_Tp_allocator());
1618 _GLIBCXX20_CONSTEXPR
1621 { _M_erase_at_end(this->_M_impl._M_start); }
1628 template<
typename _ForwardIterator>
1629 _GLIBCXX20_CONSTEXPR
1632 _ForwardIterator __first, _ForwardIterator __last)
1634 pointer __result = this->_M_allocate(__n);
1637 std::__uninitialized_copy_a(__first, __last, __result,
1638 _M_get_Tp_allocator());
1643 _M_deallocate(__result, __n);
1644 __throw_exception_again;
1653#if __cplusplus < 201103L
1656 template<
typename _Integer>
1658 _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
1660 this->_M_impl._M_start = _M_allocate(_S_check_init_len(
1661 static_cast<size_type>(__n), _M_get_Tp_allocator()));
1662 this->_M_impl._M_end_of_storage =
1663 this->_M_impl._M_start +
static_cast<size_type>(__n);
1664 _M_fill_initialize(
static_cast<size_type>(__n), __value);
1668 template<
typename _InputIterator>
1670 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1673 _M_range_initialize(__first, __last,
1679 template<
typename _InputIterator>
1680 _GLIBCXX20_CONSTEXPR
1682 _M_range_initialize(_InputIterator __first, _InputIterator __last,
1683 std::input_iterator_tag)
1686 for (; __first != __last; ++__first)
1687#
if __cplusplus >= 201103L
1688 emplace_back(*__first);
1694 __throw_exception_again;
1699 template<
typename _ForwardIterator>
1700 _GLIBCXX20_CONSTEXPR
1702 _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
1703 std::forward_iterator_tag)
1705 _M_range_initialize_n(__first, __last,
1709 template<
typename _Iterator>
1710 _GLIBCXX20_CONSTEXPR
1712 _M_range_initialize_n(_Iterator __first, _Iterator __last,
1715 pointer __start = this->_M_impl._M_start =
1716 this->_M_allocate(_S_check_init_len(__n, _M_get_Tp_allocator()));
1717 this->_M_impl._M_end_of_storage = __start + __n;
1718 this->_M_impl._M_finish
1719 = std::__uninitialized_copy_a(_GLIBCXX_MOVE(__first), __last,
1720 __start, _M_get_Tp_allocator());
1725 _GLIBCXX20_CONSTEXPR
1727 _M_fill_initialize(size_type __n,
const value_type& __value)
1729 this->_M_impl._M_finish =
1730 std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value,
1731 _M_get_Tp_allocator());
1734#if __cplusplus >= 201103L
1736 _GLIBCXX20_CONSTEXPR
1738 _M_default_initialize(size_type __n)
1740 this->_M_impl._M_finish =
1741 std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,
1742 _M_get_Tp_allocator());
1753 template<
typename _Integer>
1754 _GLIBCXX20_CONSTEXPR
1756 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1757 { _M_fill_assign(__n, __val); }
1760 template<
typename _InputIterator>
1761 _GLIBCXX20_CONSTEXPR
1763 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1768 template<
typename _InputIterator>
1769 _GLIBCXX20_CONSTEXPR
1771 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1772 std::input_iterator_tag);
1775 template<
typename _ForwardIterator>
1776 _GLIBCXX20_CONSTEXPR
1778 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1779 std::forward_iterator_tag);
1783 _GLIBCXX20_CONSTEXPR
1785 _M_fill_assign(size_type __n,
const value_type& __val);
1793 template<
typename _Integer>
1794 _GLIBCXX20_CONSTEXPR
1796 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
1798 { _M_fill_insert(__pos, __n, __val); }
1801 template<
typename _InputIterator>
1802 _GLIBCXX20_CONSTEXPR
1804 _M_insert_dispatch(iterator __pos, _InputIterator __first,
1805 _InputIterator __last, __false_type)
1807 _M_range_insert(__pos, __first, __last,
1812 template<
typename _InputIterator>
1813 _GLIBCXX20_CONSTEXPR
1815 _M_range_insert(iterator __pos, _InputIterator __first,
1816 _InputIterator __last, std::input_iterator_tag);
1819 template<
typename _ForwardIterator>
1820 _GLIBCXX20_CONSTEXPR
1822 _M_range_insert(iterator __pos, _ForwardIterator __first,
1823 _ForwardIterator __last, std::forward_iterator_tag);
1827 _GLIBCXX20_CONSTEXPR
1829 _M_fill_insert(iterator __pos, size_type __n,
const value_type& __x);
1832 _GLIBCXX20_CONSTEXPR
1834 _M_fill_append(size_type __n,
const value_type& __x);
1836#if __cplusplus >= 201103L
1838 _GLIBCXX20_CONSTEXPR
1840 _M_default_append(size_type __n);
1842 _GLIBCXX20_CONSTEXPR
1847#if __cplusplus < 201103L
1850 _M_insert_aux(iterator __position,
const value_type& __x);
1853 _M_realloc_insert(iterator __position,
const value_type& __x);
1856 _M_realloc_append(
const value_type& __x);
1860 struct _Temporary_value
1862 template<
typename... _Args>
1863 _GLIBCXX20_CONSTEXPR
explicit
1864 _Temporary_value(
vector* __vec, _Args&&... __args) : _M_this(__vec)
1866 _Alloc_traits::construct(_M_this->_M_impl, _M_ptr(),
1870 _GLIBCXX20_CONSTEXPR
1872 { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); }
1874 _GLIBCXX20_CONSTEXPR value_type&
1875 _M_val() noexcept {
return _M_storage._M_val; }
1878 _GLIBCXX20_CONSTEXPR _Tp*
1883 constexpr _Storage() : _M_byte() { }
1884 _GLIBCXX20_CONSTEXPR ~_Storage() { }
1885 _Storage& operator=(
const _Storage&) =
delete;
1886 unsigned char _M_byte;
1891 _Storage _M_storage;
1896 template<
typename _Arg>
1897 _GLIBCXX20_CONSTEXPR
1899 _M_insert_aux(iterator __position, _Arg&& __arg);
1901 template<
typename... _Args>
1902 _GLIBCXX20_CONSTEXPR
1904 _M_realloc_insert(iterator __position, _Args&&... __args);
1906 template<
typename... _Args>
1907 _GLIBCXX20_CONSTEXPR
1909 _M_realloc_append(_Args&&... __args);
1912 _GLIBCXX20_CONSTEXPR
1914 _M_insert_rval(const_iterator __position, value_type&& __v);
1917 template<
typename... _Args>
1918 _GLIBCXX20_CONSTEXPR
1920 _M_emplace_aux(const_iterator __position, _Args&&... __args);
1923 _GLIBCXX20_CONSTEXPR
1925 _M_emplace_aux(const_iterator __position, value_type&& __v)
1926 {
return _M_insert_rval(__position,
std::move(__v)); }
1930 _GLIBCXX20_CONSTEXPR
1932 _M_check_len(size_type __n,
const char* __s)
const
1935 __throw_length_error(__N(__s));
1942 static _GLIBCXX20_CONSTEXPR size_type
1943 _S_check_init_len(size_type __n,
const allocator_type& __a)
1945 if (__n > _S_max_size(_Tp_alloc_type(__a)))
1946 __throw_length_error(
1947 __N(
"cannot create std::vector larger than max_size()"));
1951 static _GLIBCXX20_CONSTEXPR size_type
1952 _S_max_size(
const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
1957 const size_t __diffmax
1958 = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max /
sizeof(_Tp);
1960 return (
std::min)(__diffmax, __allocmax);
1967 _GLIBCXX20_CONSTEXPR
1969 _M_erase_at_end(pointer __pos) _GLIBCXX_NOEXCEPT
1971 if (size_type __n = this->_M_impl._M_finish - __pos)
1974 _M_get_Tp_allocator());
1975 this->_M_impl._M_finish = __pos;
1976 _GLIBCXX_ASAN_ANNOTATE_SHRINK(__n);
1980 _GLIBCXX20_CONSTEXPR
1982 _M_erase(iterator __position);
1984 _GLIBCXX20_CONSTEXPR
1986 _M_erase(iterator __first, iterator __last);
1988#if __cplusplus >= 201103L
1993 _GLIBCXX20_CONSTEXPR
1998 this->_M_impl._M_swap_data(__x._M_impl);
1999 __tmp._M_impl._M_swap_data(__x._M_impl);
2000 std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator());
2005 _GLIBCXX20_CONSTEXPR
2009 if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator())
2015 this->_M_assign_aux(std::make_move_iterator(__x.begin()),
2016 std::make_move_iterator(__x.end()),
2017 std::random_access_iterator_tag());
2023 template<
typename _Up>
2024 _GLIBCXX20_CONSTEXPR
2026 _M_data_ptr(_Up* __ptr)
const _GLIBCXX_NOEXCEPT
2029#if __cplusplus >= 201103L
2030 template<
typename _Ptr>
2031 _GLIBCXX20_CONSTEXPR
2032 typename std::pointer_traits<_Ptr>::element_type*
2033 _M_data_ptr(_Ptr __ptr)
const
2034 {
return empty() ? nullptr : std::__to_address(__ptr); }
2036 template<
typename _Up>
2038 _M_data_ptr(_Up* __ptr) _GLIBCXX_NOEXCEPT
2041 template<
typename _Ptr>
2043 _M_data_ptr(_Ptr __ptr)
2044 {
return empty() ? (value_type*)0 : __ptr.operator->(); }
2046 template<
typename _Ptr>
2048 _M_data_ptr(_Ptr __ptr)
const
2049 {
return empty() ? (
const value_type*)0 : __ptr.operator->(); }