57 #define _STL_VECTOR_H 1
62 #if __cplusplus >= 201103L
68 #if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR
70 __sanitizer_annotate_contiguous_container(
const void*,
const void*,
71 const void*,
const void*);
74 namespace std _GLIBCXX_VISIBILITY(default)
76 _GLIBCXX_BEGIN_NAMESPACE_VERSION
77 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
80 template<
typename _Tp,
typename _Alloc>
84 rebind<_Tp>::other _Tp_alloc_type;
85 typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer
88 struct _Vector_impl_data
92 pointer _M_end_of_storage;
94 _Vector_impl_data() _GLIBCXX_NOEXCEPT
95 : _M_start(), _M_finish(), _M_end_of_storage()
98 #if __cplusplus >= 201103L
99 _Vector_impl_data(_Vector_impl_data&& __x) noexcept
100 : _M_start(__x._M_start), _M_finish(__x._M_finish),
101 _M_end_of_storage(__x._M_end_of_storage)
102 { __x._M_start = __x._M_finish = __x._M_end_of_storage = pointer(); }
106 _M_copy_data(_Vector_impl_data
const& __x) _GLIBCXX_NOEXCEPT
108 _M_start = __x._M_start;
109 _M_finish = __x._M_finish;
110 _M_end_of_storage = __x._M_end_of_storage;
114 _M_swap_data(_Vector_impl_data& __x) _GLIBCXX_NOEXCEPT
118 _Vector_impl_data __tmp;
119 __tmp._M_copy_data(*
this);
121 __x._M_copy_data(__tmp);
126 :
public _Tp_alloc_type,
public _Vector_impl_data
128 _Vector_impl() _GLIBCXX_NOEXCEPT_IF(
133 _Vector_impl(_Tp_alloc_type
const& __a) _GLIBCXX_NOEXCEPT
134 : _Tp_alloc_type(__a)
137 #if __cplusplus >= 201103L
140 _Vector_impl(_Vector_impl&& __x) noexcept
144 _Vector_impl(_Tp_alloc_type&& __a) noexcept
148 _Vector_impl(_Tp_alloc_type&& __a, _Vector_impl&& __rv) noexcept
153 #if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR
154 template<
typename = _Tp_alloc_type>
158 ::size_type size_type;
160 static void _S_shrink(_Vector_impl&, size_type) { }
161 static void _S_on_dealloc(_Vector_impl&) { }
163 typedef _Vector_impl& _Reinit;
167 _Grow(_Vector_impl&, size_type) { }
168 void _M_grew(size_type) { }
173 template<
typename _Up>
177 ::size_type size_type;
182 _S_adjust(_Vector_impl& __impl, pointer __prev, pointer __curr)
184 __sanitizer_annotate_contiguous_container(__impl._M_start,
185 __impl._M_end_of_storage, __prev, __curr);
189 _S_grow(_Vector_impl& __impl, size_type __n)
190 { _S_adjust(__impl, __impl._M_finish, __impl._M_finish + __n); }
193 _S_shrink(_Vector_impl& __impl, size_type __n)
194 { _S_adjust(__impl, __impl._M_finish + __n, __impl._M_finish); }
197 _S_on_dealloc(_Vector_impl& __impl)
200 _S_adjust(__impl, __impl._M_finish, __impl._M_end_of_storage);
206 explicit _Reinit(_Vector_impl& __impl) : _M_impl(__impl)
209 _S_on_dealloc(_M_impl);
215 if (_M_impl._M_start)
216 _S_adjust(_M_impl, _M_impl._M_end_of_storage,
220 _Vector_impl& _M_impl;
222 #if __cplusplus >= 201103L
223 _Reinit(
const _Reinit&) =
delete;
224 _Reinit& operator=(
const _Reinit&) =
delete;
231 _Grow(_Vector_impl& __impl, size_type __n)
232 : _M_impl(__impl), _M_n(__n)
233 { _S_grow(_M_impl, __n); }
235 ~_Grow() {
if (_M_n) _S_shrink(_M_impl, _M_n); }
237 void _M_grew(size_type __n) { _M_n -= __n; }
239 #if __cplusplus >= 201103L
240 _Grow(
const _Grow&) =
delete;
241 _Grow& operator=(
const _Grow&) =
delete;
244 _Vector_impl& _M_impl;
249 #define _GLIBCXX_ASAN_ANNOTATE_REINIT \
250 typename _Base::_Vector_impl::template _Asan<>::_Reinit const \
251 __attribute__((__unused__)) __reinit_guard(this->_M_impl)
252 #define _GLIBCXX_ASAN_ANNOTATE_GROW(n) \
253 typename _Base::_Vector_impl::template _Asan<>::_Grow \
254 __attribute__((__unused__)) __grow_guard(this->_M_impl, (n))
255 #define _GLIBCXX_ASAN_ANNOTATE_GREW(n) __grow_guard._M_grew(n)
256 #define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n) \
257 _Base::_Vector_impl::template _Asan<>::_S_shrink(this->_M_impl, n)
258 #define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC \
259 _Base::_Vector_impl::template _Asan<>::_S_on_dealloc(this->_M_impl)
260 #else // ! (_GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR)
261 #define _GLIBCXX_ASAN_ANNOTATE_REINIT
262 #define _GLIBCXX_ASAN_ANNOTATE_GROW(n)
263 #define _GLIBCXX_ASAN_ANNOTATE_GREW(n)
264 #define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n)
265 #define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC
266 #endif // _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR
270 typedef _Alloc allocator_type;
273 _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
274 {
return this->_M_impl; }
276 const _Tp_alloc_type&
277 _M_get_Tp_allocator()
const _GLIBCXX_NOEXCEPT
278 {
return this->_M_impl; }
281 get_allocator() const _GLIBCXX_NOEXCEPT
282 {
return allocator_type(_M_get_Tp_allocator()); }
284 #if __cplusplus >= 201103L
290 _Vector_base(
const allocator_type& __a) _GLIBCXX_NOEXCEPT
294 #if !_GLIBCXX_INLINE_VERSION
295 _Vector_base(
size_t __n)
297 { _M_create_storage(__n); }
300 _Vector_base(
size_t __n,
const allocator_type& __a)
302 { _M_create_storage(__n); }
304 #if __cplusplus >= 201103L
305 _Vector_base(_Vector_base&&) =
default;
308 # if !_GLIBCXX_INLINE_VERSION
309 _Vector_base(_Tp_alloc_type&& __a) noexcept
312 _Vector_base(_Vector_base&& __x,
const allocator_type& __a)
315 if (__x.get_allocator() == __a)
316 this->_M_impl._M_swap_data(__x._M_impl);
319 size_t __n = __x._M_impl._M_finish - __x._M_impl._M_start;
320 _M_create_storage(__n);
325 _Vector_base(
const allocator_type& __a, _Vector_base&& __x)
326 : _M_impl(_Tp_alloc_type(__a),
std::
move(__x._M_impl))
330 ~_Vector_base() _GLIBCXX_NOEXCEPT
332 _M_deallocate(_M_impl._M_start,
333 _M_impl._M_end_of_storage - _M_impl._M_start);
337 _Vector_impl _M_impl;
340 _M_allocate(
size_t __n)
343 return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer();
347 _M_deallocate(pointer __p,
size_t __n)
351 _Tr::deallocate(_M_impl, __p, __n);
356 _M_create_storage(
size_t __n)
358 this->_M_impl._M_start = this->_M_allocate(__n);
359 this->_M_impl._M_finish = this->_M_impl._M_start;
360 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
385 template<
typename _Tp,
typename _Alloc = std::allocator<_Tp> >
388 #ifdef _GLIBCXX_CONCEPT_CHECKS
390 typedef typename _Alloc::value_type _Alloc_value_type;
391 # if __cplusplus < 201103L
392 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
394 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
397 #if __cplusplus >= 201103L
398 static_assert(
is_same<
typename remove_cv<_Tp>::type, _Tp>::value,
399 "std::vector must have a non-const, non-volatile value_type");
400 # if __cplusplus > 201703L || defined __STRICT_ANSI__
402 "std::vector must have the same value_type as its allocator");
407 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
411 typedef _Tp value_type;
412 typedef typename _Base::pointer pointer;
413 typedef typename _Alloc_traits::const_pointer const_pointer;
414 typedef typename _Alloc_traits::reference reference;
415 typedef typename _Alloc_traits::const_reference const_reference;
416 typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;
417 typedef __gnu_cxx::__normal_iterator<const_pointer, vector>
421 typedef size_t size_type;
422 typedef ptrdiff_t difference_type;
423 typedef _Alloc allocator_type;
426 #if __cplusplus >= 201103L
427 static constexpr
bool
430 return noexcept(std::__relocate_a(std::declval<pointer>(),
431 std::declval<pointer>(),
432 std::declval<pointer>(),
433 std::declval<_Tp_alloc_type&>()));
436 static constexpr
bool
440 static constexpr
bool
446 return _S_nothrow_relocate(__is_move_insertable<_Tp_alloc_type>{});
450 _S_do_relocate(pointer __first, pointer __last, pointer __result,
451 _Tp_alloc_type& __alloc,
true_type) noexcept
453 return std::__relocate_a(__first, __last, __result, __alloc);
457 _S_do_relocate(pointer, pointer, pointer __result,
462 _S_relocate(pointer __first, pointer __last, pointer __result,
463 _Tp_alloc_type& __alloc) noexcept
466 return _S_do_relocate(__first, __last, __result, __alloc, __do_it{});
471 using _Base::_M_allocate;
472 using _Base::_M_deallocate;
473 using _Base::_M_impl;
474 using _Base::_M_get_Tp_allocator;
483 #if __cplusplus >= 201103L
494 vector(
const allocator_type& __a) _GLIBCXX_NOEXCEPT
497 #if __cplusplus >= 201103L
507 vector(size_type __n,
const allocator_type& __a = allocator_type())
508 :
_Base(_S_check_init_len(__n, __a), __a)
509 { _M_default_initialize(__n); }
519 vector(size_type __n,
const value_type& __value,
520 const allocator_type& __a = allocator_type())
521 :
_Base(_S_check_init_len(__n, __a), __a)
522 { _M_fill_initialize(__n, __value); }
533 vector(size_type __n,
const value_type& __value = value_type(),
534 const allocator_type& __a = allocator_type())
535 : _Base(_S_check_init_len(__n, __a), __a)
536 { _M_fill_initialize(__n, __value); }
554 this->_M_impl._M_finish =
555 std::__uninitialized_copy_a(__x.
begin(), __x.
end(),
556 this->_M_impl._M_start,
557 _M_get_Tp_allocator());
560 #if __cplusplus >= 201103L
575 this->_M_impl._M_finish =
576 std::__uninitialized_copy_a(__x.begin(), __x.end(),
577 this->_M_impl._M_start,
578 _M_get_Tp_allocator());
589 if (__rv.get_allocator() == __m)
590 this->_M_impl._M_swap_data(__rv._M_impl);
591 else if (!__rv.empty())
593 this->_M_create_storage(__rv.size());
594 this->_M_impl._M_finish =
595 std::__uninitialized_move_a(__rv.begin(), __rv.end(),
596 this->_M_impl._M_start,
597 _M_get_Tp_allocator());
606 vector(std::declval<vector&&>(), std::declval<const allocator_type&>(),
607 std::declval<typename _Alloc_traits::is_always_equal>())) )
623 const allocator_type& __a = allocator_type())
626 _M_range_initialize(__l.begin(), __l.end(),
647 #if __cplusplus >= 201103L
648 template<
typename _InputIterator,
649 typename = std::_RequireInputIter<_InputIterator>>
650 vector(_InputIterator __first, _InputIterator __last,
651 const allocator_type& __a = allocator_type())
654 _M_range_initialize(__first, __last,
658 template<
typename _InputIterator>
659 vector(_InputIterator __first, _InputIterator __last,
660 const allocator_type& __a = allocator_type())
664 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
665 _M_initialize_dispatch(__first, __last, _Integral());
677 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
678 _M_get_Tp_allocator());
679 _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC;
694 #if __cplusplus >= 201103L
708 constexpr
bool __move_storage =
709 _Alloc_traits::_S_propagate_on_move_assign()
710 || _Alloc_traits::_S_always_equal();
729 this->_M_assign_aux(__l.begin(), __l.end(),
746 assign(size_type __n,
const value_type& __val)
747 { _M_fill_assign(__n, __val); }
761 #if __cplusplus >= 201103L
762 template<
typename _InputIterator,
763 typename = std::_RequireInputIter<_InputIterator>>
765 assign(_InputIterator __first, _InputIterator __last)
766 { _M_assign_dispatch(__first, __last, __false_type()); }
768 template<
typename _InputIterator>
770 assign(_InputIterator __first, _InputIterator __last)
773 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
774 _M_assign_dispatch(__first, __last, _Integral());
778 #if __cplusplus >= 201103L
793 this->_M_assign_aux(__l.begin(), __l.end(),
799 using _Base::get_allocator;
809 {
return iterator(this->_M_impl._M_start); }
818 {
return const_iterator(this->_M_impl._M_start); }
827 {
return iterator(this->_M_impl._M_finish); }
835 end() const _GLIBCXX_NOEXCEPT
836 {
return const_iterator(this->_M_impl._M_finish); }
852 const_reverse_iterator
870 const_reverse_iterator
874 #if __cplusplus >= 201103L
882 {
return const_iterator(this->_M_impl._M_start); }
891 {
return const_iterator(this->_M_impl._M_finish); }
898 const_reverse_iterator
907 const_reverse_iterator
916 {
return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
921 {
return _S_max_size(_M_get_Tp_allocator()); }
923 #if __cplusplus >= 201103L
936 if (__new_size >
size())
937 _M_default_append(__new_size -
size());
938 else if (__new_size <
size())
939 _M_erase_at_end(this->_M_impl._M_start + __new_size);
954 resize(size_type __new_size,
const value_type& __x)
956 if (__new_size >
size())
957 _M_fill_insert(
end(), __new_size -
size(), __x);
958 else if (__new_size <
size())
959 _M_erase_at_end(this->_M_impl._M_start + __new_size);
974 resize(size_type __new_size, value_type __x = value_type())
976 if (__new_size >
size())
977 _M_fill_insert(
end(), __new_size -
size(), __x);
978 else if (__new_size <
size())
979 _M_erase_at_end(this->_M_impl._M_start + __new_size);
983 #if __cplusplus >= 201103L
987 { _M_shrink_to_fit(); }
996 {
return size_type(this->_M_impl._M_end_of_storage
997 - this->_M_impl._M_start); }
1003 _GLIBCXX_NODISCARD
bool
1042 __glibcxx_requires_subscript(__n);
1043 return *(this->_M_impl._M_start + __n);
1060 __glibcxx_requires_subscript(__n);
1061 return *(this->_M_impl._M_start + __n);
1069 if (__n >= this->
size())
1070 __throw_out_of_range_fmt(__N(
"vector::_M_range_check: __n "
1071 "(which is %zu) >= this->size() "
1092 return (*
this)[__n];
1110 return (*
this)[__n];
1120 __glibcxx_requires_nonempty();
1131 __glibcxx_requires_nonempty();
1142 __glibcxx_requires_nonempty();
1143 return *(
end() - 1);
1153 __glibcxx_requires_nonempty();
1154 return *(
end() - 1);
1166 {
return _M_data_ptr(this->_M_impl._M_start); }
1169 data() const _GLIBCXX_NOEXCEPT
1170 {
return _M_data_ptr(this->_M_impl._M_start); }
1186 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
1188 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
1189 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
1191 ++this->_M_impl._M_finish;
1192 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
1195 _M_realloc_insert(
end(), __x);
1198 #if __cplusplus >= 201103L
1203 template<
typename... _Args>
1204 #if __cplusplus > 201402L
1209 emplace_back(_Args&&... __args);
1224 __glibcxx_requires_nonempty();
1225 --this->_M_impl._M_finish;
1226 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
1227 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
1230 #if __cplusplus >= 201103L
1243 template<
typename... _Args>
1245 emplace(const_iterator __position, _Args&&... __args)
1246 {
return _M_emplace_aux(__position, std::forward<_Args>(__args)...); }
1260 insert(const_iterator __position,
const value_type& __x);
1277 #if __cplusplus >= 201103L
1290 insert(const_iterator __position, value_type&& __x)
1291 {
return _M_insert_rval(__position,
std::move(__x)); }
1309 auto __offset = __position -
cbegin();
1310 _M_range_insert(
begin() + __offset, __l.begin(), __l.end(),
1312 return begin() + __offset;
1316 #if __cplusplus >= 201103L
1332 insert(const_iterator __position, size_type __n,
const value_type& __x)
1334 difference_type __offset = __position -
cbegin();
1335 _M_fill_insert(
begin() + __offset, __n, __x);
1336 return begin() + __offset;
1353 insert(
iterator __position, size_type __n,
const value_type& __x)
1354 { _M_fill_insert(__position, __n, __x); }
1357 #if __cplusplus >= 201103L
1373 template<
typename _InputIterator,
1374 typename = std::_RequireInputIter<_InputIterator>>
1376 insert(const_iterator __position, _InputIterator __first,
1377 _InputIterator __last)
1379 difference_type __offset = __position -
cbegin();
1380 _M_insert_dispatch(
begin() + __offset,
1381 __first, __last, __false_type());
1382 return begin() + __offset;
1399 template<
typename _InputIterator>
1402 _InputIterator __last)
1405 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1406 _M_insert_dispatch(__position, __first, __last, _Integral());
1426 #if __cplusplus >= 201103L
1428 {
return _M_erase(
begin() + (__position -
cbegin())); }
1431 {
return _M_erase(__position); }
1453 #if __cplusplus >= 201103L
1454 erase(const_iterator __first, const_iterator __last)
1456 const auto __beg =
begin();
1457 const auto __cbeg =
cbegin();
1458 return _M_erase(__beg + (__first - __cbeg), __beg + (__last - __cbeg));
1462 {
return _M_erase(__first, __last); }
1479 #if __cplusplus >= 201103L
1480 __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value
1481 || _M_get_Tp_allocator() == __x._M_get_Tp_allocator());
1483 this->_M_impl._M_swap_data(__x._M_impl);
1484 _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(),
1485 __x._M_get_Tp_allocator());
1496 { _M_erase_at_end(this->_M_impl._M_start); }
1503 template<
typename _ForwardIterator>
1506 _ForwardIterator __first, _ForwardIterator __last)
1508 pointer __result = this->_M_allocate(__n);
1511 std::__uninitialized_copy_a(__first, __last, __result,
1512 _M_get_Tp_allocator());
1517 _M_deallocate(__result, __n);
1518 __throw_exception_again;
1527 #if __cplusplus < 201103L
1530 template<
typename _Integer>
1532 _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
1534 this->_M_impl._M_start = _M_allocate(_S_check_init_len(
1535 static_cast<size_type
>(__n), _M_get_Tp_allocator()));
1536 this->_M_impl._M_end_of_storage =
1537 this->_M_impl._M_start +
static_cast<size_type
>(__n);
1538 _M_fill_initialize(
static_cast<size_type
>(__n), __value);
1542 template<
typename _InputIterator>
1544 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1547 _M_range_initialize(__first, __last,
1553 template<
typename _InputIterator>
1555 _M_range_initialize(_InputIterator __first, _InputIterator __last,
1559 for (; __first != __last; ++__first)
1560 #
if __cplusplus >= 201103L
1561 emplace_back(*__first);
1567 __throw_exception_again;
1572 template<
typename _ForwardIterator>
1574 _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
1578 this->_M_impl._M_start
1579 = this->_M_allocate(_S_check_init_len(__n, _M_get_Tp_allocator()));
1580 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
1581 this->_M_impl._M_finish =
1582 std::__uninitialized_copy_a(__first, __last,
1583 this->_M_impl._M_start,
1584 _M_get_Tp_allocator());
1590 _M_fill_initialize(size_type __n,
const value_type& __value)
1592 this->_M_impl._M_finish =
1593 std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value,
1594 _M_get_Tp_allocator());
1597 #if __cplusplus >= 201103L
1600 _M_default_initialize(size_type __n)
1602 this->_M_impl._M_finish =
1603 std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,
1604 _M_get_Tp_allocator());
1615 template<
typename _Integer>
1617 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1618 { _M_fill_assign(__n, __val); }
1621 template<
typename _InputIterator>
1623 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1628 template<
typename _InputIterator>
1630 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1634 template<
typename _ForwardIterator>
1636 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1642 _M_fill_assign(size_type __n,
const value_type& __val);
1650 template<
typename _Integer>
1652 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
1654 { _M_fill_insert(__pos, __n, __val); }
1657 template<
typename _InputIterator>
1659 _M_insert_dispatch(iterator __pos, _InputIterator __first,
1660 _InputIterator __last, __false_type)
1662 _M_range_insert(__pos, __first, __last,
1667 template<
typename _InputIterator>
1669 _M_range_insert(iterator __pos, _InputIterator __first,
1673 template<
typename _ForwardIterator>
1675 _M_range_insert(iterator __pos, _ForwardIterator __first,
1681 _M_fill_insert(iterator __pos, size_type __n,
const value_type& __x);
1683 #if __cplusplus >= 201103L
1686 _M_default_append(size_type __n);
1692 #if __cplusplus < 201103L
1695 _M_insert_aux(iterator __position,
const value_type& __x);
1698 _M_realloc_insert(iterator __position,
const value_type& __x);
1702 struct _Temporary_value
1704 template<
typename... _Args>
1706 _Temporary_value(
vector* __vec, _Args&&... __args) : _M_this(__vec)
1708 _Alloc_traits::construct(_M_this->_M_impl, _M_ptr(),
1709 std::forward<_Args>(__args)...);
1713 { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); }
1716 _M_val() {
return *_M_ptr(); }
1720 _M_ptr() {
return reinterpret_cast<_Tp*
>(&__buf); }
1723 typename aligned_storage<
sizeof(_Tp),
alignof(_Tp)>::type __buf;
1728 template<
typename _Arg>
1730 _M_insert_aux(iterator __position, _Arg&& __arg);
1732 template<
typename... _Args>
1734 _M_realloc_insert(iterator __position, _Args&&... __args);
1738 _M_insert_rval(const_iterator __position, value_type&& __v);
1741 template<
typename... _Args>
1743 _M_emplace_aux(const_iterator __position, _Args&&... __args);
1747 _M_emplace_aux(const_iterator __position, value_type&& __v)
1748 {
return _M_insert_rval(__position,
std::move(__v)); }
1753 _M_check_len(size_type __n,
const char* __s)
const
1756 __throw_length_error(__N(__s));
1764 _S_check_init_len(size_type __n,
const allocator_type& __a)
1766 if (__n > _S_max_size(_Tp_alloc_type(__a)))
1767 __throw_length_error(
1768 __N(
"cannot create std::vector larger than max_size()"));
1773 _S_max_size(
const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
1778 const size_t __diffmax
1779 = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max /
sizeof(_Tp);
1781 return (
std::min)(__diffmax, __allocmax);
1789 _M_erase_at_end(pointer __pos) _GLIBCXX_NOEXCEPT
1791 if (size_type __n = this->_M_impl._M_finish - __pos)
1794 _M_get_Tp_allocator());
1795 this->_M_impl._M_finish = __pos;
1796 _GLIBCXX_ASAN_ANNOTATE_SHRINK(__n);
1801 _M_erase(iterator __position);
1804 _M_erase(iterator __first, iterator __last);
1806 #if __cplusplus >= 201103L
1815 this->_M_impl._M_swap_data(__x._M_impl);
1816 __tmp._M_impl._M_swap_data(__x._M_impl);
1817 std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator());
1825 if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator())
1831 this->_M_assign_aux(std::make_move_iterator(__x.begin()),
1832 std::make_move_iterator(__x.end()),
1839 template<
typename _Up>
1841 _M_data_ptr(_Up* __ptr)
const _GLIBCXX_NOEXCEPT
1844 #if __cplusplus >= 201103L
1845 template<
typename _Ptr>
1847 _M_data_ptr(_Ptr __ptr)
const
1848 {
return empty() ? nullptr : std::__to_address(__ptr); }
1850 template<
typename _Up>
1852 _M_data_ptr(_Up* __ptr) _GLIBCXX_NOEXCEPT
1855 template<
typename _Ptr>
1857 _M_data_ptr(_Ptr __ptr)
1858 {
return empty() ? (value_type*)0 : __ptr.operator->(); }
1860 template<
typename _Ptr>
1862 _M_data_ptr(_Ptr __ptr)
const
1863 {
return empty() ? (
const value_type*)0 : __ptr.operator->(); }
1867 #if __cpp_deduction_guides >= 201606
1868 template<
typename _InputIterator,
typename _ValT
1869 =
typename iterator_traits<_InputIterator>::value_type,
1870 typename _Allocator = allocator<_ValT>,
1871 typename = _RequireInputIter<_InputIterator>,
1872 typename = _RequireAllocator<_Allocator>>
1873 vector(_InputIterator, _InputIterator, _Allocator = _Allocator())
1874 -> vector<_ValT, _Allocator>;
1887 template<
typename _Tp,
typename _Alloc>
1904 template<
typename _Tp,
typename _Alloc>
1911 template<
typename _Tp,
typename _Alloc>
1914 {
return !(__x == __y); }
1917 template<
typename _Tp,
typename _Alloc>
1920 {
return __y < __x; }
1923 template<
typename _Tp,
typename _Alloc>
1926 {
return !(__y < __x); }
1929 template<
typename _Tp,
typename _Alloc>
1932 {
return !(__x < __y); }
1935 template<
typename _Tp,
typename _Alloc>
1938 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
1941 _GLIBCXX_END_NAMESPACE_CONTAINER
1943 #if __cplusplus >= 201703L
1944 namespace __detail::__variant
1946 template<
typename>
struct _Never_valueless_alt;
1950 template<
typename _Tp,
typename _Alloc>
1951 struct _Never_valueless_alt<_GLIBCXX_STD_C::vector<_Tp, _Alloc>>
1957 _GLIBCXX_END_NAMESPACE_VERSION