88 rebind<_Tp>::other _Tp_alloc_type;
89 typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer
92 struct _Vector_impl_data
96 pointer _M_end_of_storage;
99 _Vector_impl_data() _GLIBCXX_NOEXCEPT
100 : _M_start(), _M_finish(), _M_end_of_storage()
103#if __cplusplus >= 201103L
105 _Vector_impl_data(_Vector_impl_data&& __x) noexcept
106 : _M_start(__x._M_start), _M_finish(__x._M_finish),
107 _M_end_of_storage(__x._M_end_of_storage)
108 { __x._M_start = __x._M_finish = __x._M_end_of_storage = pointer(); }
113 _M_copy_data(_Vector_impl_data
const& __x) _GLIBCXX_NOEXCEPT
115 _M_start = __x._M_start;
116 _M_finish = __x._M_finish;
117 _M_end_of_storage = __x._M_end_of_storage;
122 _M_swap_data(_Vector_impl_data& __x) _GLIBCXX_NOEXCEPT
126 _Vector_impl_data __tmp;
127 __tmp._M_copy_data(*
this);
129 __x._M_copy_data(__tmp);
134 :
public _Tp_alloc_type,
public _Vector_impl_data
137 _Vector_impl() _GLIBCXX_NOEXCEPT_IF(
139#if __cpp_lib_concepts
140 requires is_default_constructible_v<_Tp_alloc_type>
146 _Vector_impl(_Tp_alloc_type
const& __a) _GLIBCXX_NOEXCEPT
147 : _Tp_alloc_type(__a)
150#if __cplusplus >= 201103L
154 _Vector_impl(_Vector_impl&& __x) noexcept
159 _Vector_impl(_Tp_alloc_type&& __a) noexcept
164 _Vector_impl(_Tp_alloc_type&& __a, _Vector_impl&& __rv) noexcept
169#if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR
170 template<
typename = _Tp_alloc_type>
176 static _GLIBCXX20_CONSTEXPR
void
178 static _GLIBCXX20_CONSTEXPR
void
179 _S_on_dealloc(_Vector_impl&) { }
181 typedef _Vector_impl& _Reinit;
185 _GLIBCXX20_CONSTEXPR _Grow(_Vector_impl&,
size_type) { }
186 _GLIBCXX20_CONSTEXPR
void _M_grew(
size_type) { }
191 template<
typename _Up>
199 static _GLIBCXX20_CONSTEXPR
void
200 _S_adjust(_Vector_impl& __impl, pointer __prev, pointer __curr)
202#if __cpp_lib_is_constant_evaluated
206 __sanitizer_annotate_contiguous_container(__impl._M_start,
207 __impl._M_end_of_storage, __prev, __curr);
210 static _GLIBCXX20_CONSTEXPR
void
211 _S_grow(_Vector_impl& __impl,
size_type __n)
212 { _S_adjust(__impl, __impl._M_finish, __impl._M_finish + __n); }
214 static _GLIBCXX20_CONSTEXPR
void
215 _S_shrink(_Vector_impl& __impl,
size_type __n)
216 { _S_adjust(__impl, __impl._M_finish + __n, __impl._M_finish); }
218 static _GLIBCXX20_CONSTEXPR
void
219 _S_on_dealloc(_Vector_impl& __impl)
222 _S_adjust(__impl, __impl._M_finish, __impl._M_end_of_storage);
228 explicit _GLIBCXX20_CONSTEXPR
229 _Reinit(_Vector_impl& __impl) : _M_impl(__impl)
232 _S_on_dealloc(_M_impl);
239 if (_M_impl._M_start)
240 _S_adjust(_M_impl, _M_impl._M_end_of_storage,
244 _Vector_impl& _M_impl;
246#if __cplusplus >= 201103L
247 _Reinit(
const _Reinit&) =
delete;
248 _Reinit& operator=(
const _Reinit&) =
delete;
256 _Grow(_Vector_impl& __impl,
size_type __n)
257 : _M_impl(__impl), _M_n(__n)
258 { _S_grow(_M_impl, __n); }
261 ~_Grow() {
if (_M_n) _S_shrink(_M_impl, _M_n); }
264 void _M_grew(
size_type __n) { _M_n -= __n; }
266#if __cplusplus >= 201103L
267 _Grow(
const _Grow&) =
delete;
268 _Grow& operator=(
const _Grow&) =
delete;
271 _Vector_impl& _M_impl;
276#define _GLIBCXX_ASAN_ANNOTATE_REINIT \
277 typename _Base::_Vector_impl::template _Asan<>::_Reinit const \
278 __attribute__((__unused__)) __reinit_guard(this->_M_impl)
279#define _GLIBCXX_ASAN_ANNOTATE_GROW(n) \
280 typename _Base::_Vector_impl::template _Asan<>::_Grow \
281 __attribute__((__unused__)) __grow_guard(this->_M_impl, (n))
282#define _GLIBCXX_ASAN_ANNOTATE_GREW(n) __grow_guard._M_grew(n)
283#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n) \
284 _Base::_Vector_impl::template _Asan<>::_S_shrink(this->_M_impl, n)
285#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC \
286 _Base::_Vector_impl::template _Asan<>::_S_on_dealloc(this->_M_impl)
288#define _GLIBCXX_ASAN_ANNOTATE_REINIT
289#define _GLIBCXX_ASAN_ANNOTATE_GROW(n)
290#define _GLIBCXX_ASAN_ANNOTATE_GREW(n)
291#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n)
292#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC
297 typedef _Alloc allocator_type;
301 _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
302 {
return this->_M_impl; }
305 const _Tp_alloc_type&
306 _M_get_Tp_allocator()
const _GLIBCXX_NOEXCEPT
307 {
return this->_M_impl; }
312 {
return allocator_type(_M_get_Tp_allocator()); }
314#if __cplusplus >= 201103L
321 _Vector_base(
const allocator_type& __a) _GLIBCXX_NOEXCEPT
325#if !_GLIBCXX_INLINE_VERSION
327 _Vector_base(
size_t __n)
329 { _M_create_storage(__n); }
333 _Vector_base(
size_t __n,
const allocator_type& __a)
335 { _M_create_storage(__n); }
337#if __cplusplus >= 201103L
338 _Vector_base(_Vector_base&&) =
default;
341# if !_GLIBCXX_INLINE_VERSION
343 _Vector_base(_Tp_alloc_type&& __a) noexcept
347 _Vector_base(_Vector_base&& __x,
const allocator_type& __a)
350 if (__x.get_allocator() == __a)
351 this->_M_impl._M_swap_data(__x._M_impl);
354 size_t __n = __x._M_impl._M_finish - __x._M_impl._M_start;
355 _M_create_storage(__n);
361 _Vector_base(
const allocator_type& __a, _Vector_base&& __x)
362 : _M_impl(_Tp_alloc_type(__a), std::
move(__x._M_impl))
367 ~_Vector_base() _GLIBCXX_NOEXCEPT
369 _M_deallocate(_M_impl._M_start,
370 _M_impl._M_end_of_storage - _M_impl._M_start);
374 _Vector_impl _M_impl;
378 _M_allocate(
size_t __n)
380 typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr;
381 return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer();
386 _M_deallocate(pointer __p,
size_t __n)
388 typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr;
390 _Tr::deallocate(_M_impl, __p, __n);
396 _M_create_storage(
size_t __n)
398 this->_M_impl._M_start = this->_M_allocate(__n);
399 this->_M_impl._M_finish = this->_M_impl._M_start;
400 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
428 class vector :
protected _Vector_base<_Tp, _Alloc>
430#ifdef _GLIBCXX_CONCEPT_CHECKS
432 typedef typename _Alloc::value_type _Alloc_value_type;
433# if __cplusplus < 201103L
434 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
436 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
439#if __cplusplus >= 201103L
441 "std::vector must have a non-const, non-volatile value_type");
442# if __cplusplus > 201703L || defined __STRICT_ANSI__
443 static_assert(is_same<typename _Alloc::value_type, _Tp>::value,
444 "std::vector must have the same value_type as its allocator");
448 typedef _Vector_base<_Tp, _Alloc> _Base;
449 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
453 typedef _Tp value_type;
454 typedef typename _Base::pointer pointer;
455 typedef typename _Alloc_traits::const_pointer const_pointer;
456 typedef typename _Alloc_traits::reference reference;
457 typedef typename _Alloc_traits::const_reference const_reference;
458 typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;
459 typedef __gnu_cxx::__normal_iterator<const_pointer, vector>
463 typedef size_t size_type;
464 typedef ptrdiff_t difference_type;
465 typedef _Alloc allocator_type;
468#if __cplusplus >= 201103L
469 static constexpr bool
478 static constexpr bool
482 static constexpr bool
488 return _S_nothrow_relocate(__is_move_insertable<_Tp_alloc_type>{});
492 _S_do_relocate(pointer __first, pointer __last, pointer __result,
493 _Tp_alloc_type& __alloc,
true_type)
noexcept
495 return std::__relocate_a(__first, __last, __result, __alloc);
499 _S_do_relocate(pointer, pointer, pointer __result,
503 static _GLIBCXX20_CONSTEXPR pointer
504 _S_relocate(pointer __first, pointer __last, pointer __result,
505 _Tp_alloc_type& __alloc)
noexcept
507#if __cpp_if_constexpr
509 return std::__relocate_a(__first, __last, __result, __alloc);
511 using __do_it = __bool_constant<_S_use_relocate()>;
512 return _S_do_relocate(__first, __last, __result, __alloc, __do_it{});
518 using _Base::_M_allocate;
519 using _Base::_M_deallocate;
520 using _Base::_M_impl;
521 using _Base::_M_get_Tp_allocator;
530#if __cplusplus >= 201103L
542 vector(
const allocator_type& __a) _GLIBCXX_NOEXCEPT
545#if __cplusplus >= 201103L
556 vector(size_type __n,
const allocator_type& __a = allocator_type())
557 : _Base(_S_check_init_len(__n, __a), __a)
558 { _M_default_initialize(__n); }
569 vector(size_type __n,
const value_type& __value,
570 const allocator_type& __a = allocator_type())
571 : _Base(_S_check_init_len(__n, __a), __a)
572 { _M_fill_initialize(__n, __value); }
584 const allocator_type& __a = allocator_type())
585 : _Base(_S_check_init_len(__n, __a), __a)
586 { _M_fill_initialize(__n, __value); }
603 _Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator()))
605 this->_M_impl._M_finish =
606 std::__uninitialized_copy_a(__x.
begin(), __x.
end(),
607 this->_M_impl._M_start,
608 _M_get_Tp_allocator());
611#if __cplusplus >= 201103L
624 vector(const
vector& __x, const __type_identity_t<allocator_type>& __a)
625 : _Base(__x.
size(), __a)
627 this->_M_impl._M_finish =
628 std::__uninitialized_copy_a(__x.begin(), __x.end(),
629 this->_M_impl._M_start,
630 _M_get_Tp_allocator());
640 vector(vector&& __rv,
const allocator_type& __m, false_type)
643 if (__rv.get_allocator() == __m)
644 this->_M_impl._M_swap_data(__rv._M_impl);
645 else if (!__rv.empty())
647 this->_M_create_storage(__rv.size());
648 this->_M_impl._M_finish =
649 std::__uninitialized_move_a(__rv.begin(), __rv.end(),
650 this->_M_impl._M_start,
651 _M_get_Tp_allocator());
663 :
vector(
std::
move(__rv), __m, typename _Alloc_traits::is_always_equal{})
679 const allocator_type& __a = allocator_type())
682 _M_range_initialize(__l.begin(), __l.end(),
703#if __cplusplus >= 201103L
704 template<
typename _InputIterator,
705 typename = std::_RequireInputIter<_InputIterator>>
707 vector(_InputIterator __first, _InputIterator __last,
708 const allocator_type& __a = allocator_type())
711 _M_range_initialize(__first, __last,
715 template<
typename _InputIterator>
716 vector(_InputIterator __first, _InputIterator __last,
717 const allocator_type& __a = allocator_type())
721 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
722 _M_initialize_dispatch(__first, __last, _Integral());
735 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
736 _M_get_Tp_allocator());
737 _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC;
753#if __cplusplus >= 201103L
768 constexpr bool __move_storage =
769 _Alloc_traits::_S_propagate_on_move_assign()
770 || _Alloc_traits::_S_always_equal();
771 _M_move_assign(
std::move(__x), __bool_constant<__move_storage>());
790 this->_M_assign_aux(__l.begin(), __l.end(),
808 assign(size_type __n,
const value_type& __val)
809 { _M_fill_assign(__n, __val); }
823#if __cplusplus >= 201103L
824 template<
typename _InputIterator,
825 typename = std::_RequireInputIter<_InputIterator>>
828 assign(_InputIterator __first, _InputIterator __last)
829 { _M_assign_dispatch(__first, __last, __false_type()); }
831 template<
typename _InputIterator>
833 assign(_InputIterator __first, _InputIterator __last)
836 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
837 _M_assign_dispatch(__first, __last, _Integral());
841#if __cplusplus >= 201103L
857 this->_M_assign_aux(__l.begin(), __l.end(),
863 using _Base::get_allocator;
871 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
874 {
return iterator(this->_M_impl._M_start); }
881 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
884 {
return const_iterator(this->_M_impl._M_start); }
891 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
894 {
return iterator(this->_M_impl._M_finish); }
901 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
903 end() const _GLIBCXX_NOEXCEPT
904 {
return const_iterator(this->_M_impl._M_finish); }
911 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
914 {
return reverse_iterator(
end()); }
921 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
922 const_reverse_iterator
924 {
return const_reverse_iterator(
end()); }
931 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
934 {
return reverse_iterator(
begin()); }
941 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
942 const_reverse_iterator
944 {
return const_reverse_iterator(
begin()); }
946#if __cplusplus >= 201103L
952 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
955 {
return const_iterator(this->_M_impl._M_start); }
962 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
965 {
return const_iterator(this->_M_impl._M_finish); }
972 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
973 const_reverse_iterator
975 {
return const_reverse_iterator(
end()); }
982 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
983 const_reverse_iterator
985 {
return const_reverse_iterator(
begin()); }
990 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
993 {
return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
996 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
999 {
return _S_max_size(_M_get_Tp_allocator()); }
1001#if __cplusplus >= 201103L
1011 _GLIBCXX20_CONSTEXPR
1015 if (__new_size >
size())
1016 _M_default_append(__new_size -
size());
1017 else if (__new_size <
size())
1018 _M_erase_at_end(this->_M_impl._M_start + __new_size);
1032 _GLIBCXX20_CONSTEXPR
1034 resize(size_type __new_size,
const value_type& __x)
1036 if (__new_size >
size())
1037 _M_fill_insert(
end(), __new_size -
size(), __x);
1038 else if (__new_size <
size())
1039 _M_erase_at_end(this->_M_impl._M_start + __new_size);
1053 _GLIBCXX20_CONSTEXPR
1057 if (__new_size >
size())
1058 _M_fill_insert(
end(), __new_size -
size(), __x);
1059 else if (__new_size <
size())
1060 _M_erase_at_end(this->_M_impl._M_start + __new_size);
1064#if __cplusplus >= 201103L
1066 _GLIBCXX20_CONSTEXPR
1069 { _M_shrink_to_fit(); }
1076 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1079 {
return size_type(this->_M_impl._M_end_of_storage
1080 - this->_M_impl._M_start); }
1086 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1108 _GLIBCXX20_CONSTEXPR
1124 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1128 __glibcxx_requires_subscript(__n);
1129 return *(this->_M_impl._M_start + __n);
1143 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1147 __glibcxx_requires_subscript(__n);
1148 return *(this->_M_impl._M_start + __n);
1153 _GLIBCXX20_CONSTEXPR
1157 if (__n >= this->
size())
1158 __throw_out_of_range_fmt(__N(
"vector::_M_range_check: __n "
1159 "(which is %zu) >= this->size() "
1176 _GLIBCXX20_CONSTEXPR
1181 return (*
this)[__n];
1195 _GLIBCXX20_CONSTEXPR
1200 return (*
this)[__n];
1207 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1211 __glibcxx_requires_nonempty();
1219 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1223 __glibcxx_requires_nonempty();
1231 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1235 __glibcxx_requires_nonempty();
1236 return *(
end() - 1);
1243 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1247 __glibcxx_requires_nonempty();
1248 return *(
end() - 1);
1258 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1261 {
return _M_data_ptr(this->_M_impl._M_start); }
1263 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1265 data() const _GLIBCXX_NOEXCEPT
1266 {
return _M_data_ptr(this->_M_impl._M_start); }
1279 _GLIBCXX20_CONSTEXPR
1283 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
1285 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
1286 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
1288 ++this->_M_impl._M_finish;
1289 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
1292 _M_realloc_insert(
end(), __x);
1295#if __cplusplus >= 201103L
1296 _GLIBCXX20_CONSTEXPR
1301 template<
typename... _Args>
1302#if __cplusplus > 201402L
1303 _GLIBCXX20_CONSTEXPR
1308 emplace_back(_Args&&... __args);
1320 _GLIBCXX20_CONSTEXPR
1324 __glibcxx_requires_nonempty();
1325 --this->_M_impl._M_finish;
1326 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
1327 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
1330#if __cplusplus >= 201103L
1343 template<
typename... _Args>
1344 _GLIBCXX20_CONSTEXPR
1346 emplace(const_iterator __position, _Args&&... __args)
1360 _GLIBCXX20_CONSTEXPR
1362 insert(const_iterator __position,
const value_type& __x);
1376 insert(iterator __position,
const value_type& __x);
1379#if __cplusplus >= 201103L
1391 _GLIBCXX20_CONSTEXPR
1393 insert(const_iterator __position, value_type&& __x)
1394 {
return _M_insert_rval(__position,
std::move(__x)); }
1409 _GLIBCXX20_CONSTEXPR
1413 auto __offset = __position -
cbegin();
1414 _M_range_insert(
begin() + __offset, __l.begin(), __l.end(),
1416 return begin() + __offset;
1420#if __cplusplus >= 201103L
1435 _GLIBCXX20_CONSTEXPR
1437 insert(const_iterator __position, size_type __n,
const value_type& __x)
1439 difference_type __offset = __position -
cbegin();
1440 _M_fill_insert(
begin() + __offset, __n, __x);
1441 return begin() + __offset;
1459 { _M_fill_insert(__position, __n, __x); }
1462#if __cplusplus >= 201103L
1478 template<
typename _InputIterator,
1479 typename = std::_RequireInputIter<_InputIterator>>
1480 _GLIBCXX20_CONSTEXPR
1482 insert(const_iterator __position, _InputIterator __first,
1483 _InputIterator __last)
1485 difference_type __offset = __position -
cbegin();
1486 _M_insert_dispatch(
begin() + __offset,
1487 __first, __last, __false_type());
1488 return begin() + __offset;
1505 template<
typename _InputIterator>
1508 _InputIterator __last)
1511 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1512 _M_insert_dispatch(__position, __first, __last, _Integral());
1531 _GLIBCXX20_CONSTEXPR
1533#if __cplusplus >= 201103L
1535 {
return _M_erase(
begin() + (__position -
cbegin())); }
1538 {
return _M_erase(__position); }
1559 _GLIBCXX20_CONSTEXPR
1561#if __cplusplus >= 201103L
1562 erase(const_iterator __first, const_iterator __last)
1564 const auto __beg =
begin();
1565 const auto __cbeg =
cbegin();
1566 return _M_erase(__beg + (__first - __cbeg), __beg + (__last - __cbeg));
1570 {
return _M_erase(__first, __last); }
1584 _GLIBCXX20_CONSTEXPR
1588#if __cplusplus >= 201103L
1589 __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value
1590 || _M_get_Tp_allocator() == __x._M_get_Tp_allocator());
1592 this->_M_impl._M_swap_data(__x._M_impl);
1593 _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(),
1594 __x._M_get_Tp_allocator());
1603 _GLIBCXX20_CONSTEXPR
1606 { _M_erase_at_end(this->_M_impl._M_start); }
1613 template<
typename _ForwardIterator>
1614 _GLIBCXX20_CONSTEXPR
1617 _ForwardIterator __first, _ForwardIterator __last)
1619 pointer __result = this->_M_allocate(__n);
1622 std::__uninitialized_copy_a(__first, __last, __result,
1623 _M_get_Tp_allocator());
1628 _M_deallocate(__result, __n);
1629 __throw_exception_again;
1638#if __cplusplus < 201103L
1641 template<
typename _Integer>
1643 _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
1645 this->_M_impl._M_start = _M_allocate(_S_check_init_len(
1646 static_cast<size_type>(__n), _M_get_Tp_allocator()));
1647 this->_M_impl._M_end_of_storage =
1648 this->_M_impl._M_start +
static_cast<size_type>(__n);
1649 _M_fill_initialize(
static_cast<size_type>(__n), __value);
1653 template<
typename _InputIterator>
1655 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1658 _M_range_initialize(__first, __last,
1664 template<
typename _InputIterator>
1665 _GLIBCXX20_CONSTEXPR
1667 _M_range_initialize(_InputIterator __first, _InputIterator __last,
1668 std::input_iterator_tag)
1671 for (; __first != __last; ++__first)
1672#
if __cplusplus >= 201103L
1673 emplace_back(*__first);
1679 __throw_exception_again;
1684 template<
typename _ForwardIterator>
1685 _GLIBCXX20_CONSTEXPR
1687 _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
1688 std::forward_iterator_tag)
1691 this->_M_impl._M_start
1692 = this->_M_allocate(_S_check_init_len(__n, _M_get_Tp_allocator()));
1693 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
1694 this->_M_impl._M_finish =
1695 std::__uninitialized_copy_a(__first, __last,
1696 this->_M_impl._M_start,
1697 _M_get_Tp_allocator());
1702 _GLIBCXX20_CONSTEXPR
1704 _M_fill_initialize(size_type __n,
const value_type& __value)
1706 this->_M_impl._M_finish =
1707 std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value,
1708 _M_get_Tp_allocator());
1711#if __cplusplus >= 201103L
1713 _GLIBCXX20_CONSTEXPR
1715 _M_default_initialize(size_type __n)
1717 this->_M_impl._M_finish =
1718 std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,
1719 _M_get_Tp_allocator());
1730 template<
typename _Integer>
1731 _GLIBCXX20_CONSTEXPR
1733 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1734 { _M_fill_assign(__n, __val); }
1737 template<
typename _InputIterator>
1738 _GLIBCXX20_CONSTEXPR
1740 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1745 template<
typename _InputIterator>
1746 _GLIBCXX20_CONSTEXPR
1748 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1749 std::input_iterator_tag);
1752 template<
typename _ForwardIterator>
1753 _GLIBCXX20_CONSTEXPR
1755 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1756 std::forward_iterator_tag);
1760 _GLIBCXX20_CONSTEXPR
1762 _M_fill_assign(size_type __n,
const value_type& __val);
1770 template<
typename _Integer>
1771 _GLIBCXX20_CONSTEXPR
1773 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
1775 { _M_fill_insert(__pos, __n, __val); }
1778 template<
typename _InputIterator>
1779 _GLIBCXX20_CONSTEXPR
1781 _M_insert_dispatch(iterator __pos, _InputIterator __first,
1782 _InputIterator __last, __false_type)
1784 _M_range_insert(__pos, __first, __last,
1789 template<
typename _InputIterator>
1790 _GLIBCXX20_CONSTEXPR
1792 _M_range_insert(iterator __pos, _InputIterator __first,
1793 _InputIterator __last, std::input_iterator_tag);
1796 template<
typename _ForwardIterator>
1797 _GLIBCXX20_CONSTEXPR
1799 _M_range_insert(iterator __pos, _ForwardIterator __first,
1800 _ForwardIterator __last, std::forward_iterator_tag);
1804 _GLIBCXX20_CONSTEXPR
1806 _M_fill_insert(iterator __pos, size_type __n,
const value_type& __x);
1808#if __cplusplus >= 201103L
1810 _GLIBCXX20_CONSTEXPR
1812 _M_default_append(size_type __n);
1814 _GLIBCXX20_CONSTEXPR
1819#if __cplusplus < 201103L
1822 _M_insert_aux(iterator __position,
const value_type& __x);
1825 _M_realloc_insert(iterator __position,
const value_type& __x);
1829 struct _Temporary_value
1831 template<
typename... _Args>
1832 _GLIBCXX20_CONSTEXPR
explicit
1833 _Temporary_value(
vector* __vec, _Args&&... __args) : _M_this(__vec)
1835 _Alloc_traits::construct(_M_this->_M_impl, _M_ptr(),
1839 _GLIBCXX20_CONSTEXPR
1841 { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); }
1843 _GLIBCXX20_CONSTEXPR value_type&
1844 _M_val() noexcept {
return _M_storage._M_val; }
1847 _GLIBCXX20_CONSTEXPR _Tp*
1852 constexpr _Storage() : _M_byte() { }
1853 _GLIBCXX20_CONSTEXPR ~_Storage() { }
1854 _Storage& operator=(
const _Storage&) =
delete;
1855 unsigned char _M_byte;
1860 _Storage _M_storage;
1865 template<
typename _Arg>
1866 _GLIBCXX20_CONSTEXPR
1868 _M_insert_aux(iterator __position, _Arg&& __arg);
1870 template<
typename... _Args>
1871 _GLIBCXX20_CONSTEXPR
1873 _M_realloc_insert(iterator __position, _Args&&... __args);
1876 _GLIBCXX20_CONSTEXPR
1878 _M_insert_rval(const_iterator __position, value_type&& __v);
1881 template<
typename... _Args>
1882 _GLIBCXX20_CONSTEXPR
1884 _M_emplace_aux(const_iterator __position, _Args&&... __args);
1887 _GLIBCXX20_CONSTEXPR
1889 _M_emplace_aux(const_iterator __position, value_type&& __v)
1890 {
return _M_insert_rval(__position,
std::move(__v)); }
1894 _GLIBCXX20_CONSTEXPR
1896 _M_check_len(size_type __n,
const char* __s)
const
1899 __throw_length_error(__N(__s));
1906 static _GLIBCXX20_CONSTEXPR size_type
1907 _S_check_init_len(size_type __n,
const allocator_type& __a)
1909 if (__n > _S_max_size(_Tp_alloc_type(__a)))
1910 __throw_length_error(
1911 __N(
"cannot create std::vector larger than max_size()"));
1915 static _GLIBCXX20_CONSTEXPR size_type
1916 _S_max_size(
const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
1921 const size_t __diffmax
1922 = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max /
sizeof(_Tp);
1924 return (
std::min)(__diffmax, __allocmax);
1931 _GLIBCXX20_CONSTEXPR
1933 _M_erase_at_end(pointer __pos) _GLIBCXX_NOEXCEPT
1935 if (size_type __n = this->_M_impl._M_finish - __pos)
1938 _M_get_Tp_allocator());
1939 this->_M_impl._M_finish = __pos;
1940 _GLIBCXX_ASAN_ANNOTATE_SHRINK(__n);
1944 _GLIBCXX20_CONSTEXPR
1946 _M_erase(iterator __position);
1948 _GLIBCXX20_CONSTEXPR
1950 _M_erase(iterator __first, iterator __last);
1952#if __cplusplus >= 201103L
1957 _GLIBCXX20_CONSTEXPR
1962 this->_M_impl._M_swap_data(__x._M_impl);
1963 __tmp._M_impl._M_swap_data(__x._M_impl);
1964 std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator());
1969 _GLIBCXX20_CONSTEXPR
1973 if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator())
1979 this->_M_assign_aux(std::make_move_iterator(__x.begin()),
1980 std::make_move_iterator(__x.end()),
1981 std::random_access_iterator_tag());
1987 template<
typename _Up>
1988 _GLIBCXX20_CONSTEXPR
1990 _M_data_ptr(_Up* __ptr)
const _GLIBCXX_NOEXCEPT
1993#if __cplusplus >= 201103L
1994 template<
typename _Ptr>
1995 _GLIBCXX20_CONSTEXPR
1996 typename std::pointer_traits<_Ptr>::element_type*
1997 _M_data_ptr(_Ptr __ptr)
const
1998 {
return empty() ? nullptr : std::__to_address(__ptr); }
2000 template<
typename _Up>
2002 _M_data_ptr(_Up* __ptr) _GLIBCXX_NOEXCEPT
2005 template<
typename _Ptr>
2007 _M_data_ptr(_Ptr __ptr)
2008 {
return empty() ? (value_type*)0 : __ptr.operator->(); }
2010 template<
typename _Ptr>
2012 _M_data_ptr(_Ptr __ptr)
const
2013 {
return empty() ? (
const value_type*)0 : __ptr.operator->(); }