59namespace std _GLIBCXX_VISIBILITY(default)
61_GLIBCXX_BEGIN_NAMESPACE_VERSION
62_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
64 template<
typename _Tp,
typename _Alloc>
71 __throw_length_error(__N(
"vector::reserve"));
74 const size_type __old_size =
size();
76#if __cplusplus >= 201103L
77 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
79 __tmp = this->_M_allocate(__n);
80 _S_relocate(this->_M_impl._M_start, this->_M_impl._M_finish,
81 __tmp, _M_get_Tp_allocator());
87 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_start),
88 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_finish));
89 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
90 _M_get_Tp_allocator());
92 _GLIBCXX_ASAN_ANNOTATE_REINIT;
93 _M_deallocate(this->_M_impl._M_start,
94 this->_M_impl._M_end_of_storage
95 - this->_M_impl._M_start);
96 this->_M_impl._M_start = __tmp;
97 this->_M_impl._M_finish = __tmp + __old_size;
98 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
102#if __cplusplus >= 201103L
103 template<
typename _Tp,
typename _Alloc>
104 template<
typename... _Args>
105#if __cplusplus > 201402L
107 typename vector<_Tp, _Alloc>::reference
114 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
116 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
117 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
119 ++this->_M_impl._M_finish;
120 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
124#if __cplusplus > 201402L
130 template<
typename _Tp,
typename _Alloc>
132 typename vector<_Tp, _Alloc>::iterator
134#if __cplusplus >= 201103L
135 insert(const_iterator __position,
const value_type& __x)
137 insert(iterator __position,
const value_type& __x)
140 const size_type __n = __position -
begin();
141 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
143 __glibcxx_assert(__position != const_iterator());
144 if (!(__position != const_iterator()))
145 __builtin_unreachable();
147 if (__position ==
end())
149 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
150 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
152 ++this->_M_impl._M_finish;
153 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
157#if __cplusplus >= 201103L
158 const auto __pos =
begin() + (__position -
cbegin());
161 _Temporary_value __x_copy(
this, __x);
162 _M_insert_aux(__pos,
std::move(__x_copy._M_val()));
164 _M_insert_aux(__position, __x);
169#if __cplusplus >= 201103L
170 _M_realloc_insert(
begin() + (__position -
cbegin()), __x);
172 _M_realloc_insert(__position, __x);
175 return iterator(this->_M_impl._M_start + __n);
178 template<
typename _Tp,
typename _Alloc>
180 typename vector<_Tp, _Alloc>::iterator
184 if (__position + 1 !=
end())
185 _GLIBCXX_MOVE3(__position + 1,
end(), __position);
186 --this->_M_impl._M_finish;
187 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
188 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
192 template<
typename _Tp,
typename _Alloc>
194 typename vector<_Tp, _Alloc>::iterator
195 vector<_Tp, _Alloc>::
196 _M_erase(iterator __first, iterator __last)
198 if (__first != __last)
201 _GLIBCXX_MOVE3(__last,
end(), __first);
202 _M_erase_at_end(__first.base() + (
end() - __last));
207 template<
typename _Tp,
typename _Alloc>
215 _GLIBCXX_ASAN_ANNOTATE_REINIT;
216#if __cplusplus >= 201103L
217 if (_Alloc_traits::_S_propagate_on_copy_assign())
219 if (!_Alloc_traits::_S_always_equal()
220 && _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
224 _M_deallocate(this->_M_impl._M_start,
225 this->_M_impl._M_end_of_storage
226 - this->_M_impl._M_start);
227 this->_M_impl._M_start =
nullptr;
228 this->_M_impl._M_finish =
nullptr;
229 this->_M_impl._M_end_of_storage =
nullptr;
231 std::__alloc_on_copy(_M_get_Tp_allocator(),
232 __x._M_get_Tp_allocator());
235 const size_type __xlen = __x.
size();
240 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
241 _M_get_Tp_allocator());
242 _M_deallocate(this->_M_impl._M_start,
243 this->_M_impl._M_end_of_storage
244 - this->_M_impl._M_start);
245 this->_M_impl._M_start = __tmp;
246 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen;
248 else if (
size() >= __xlen)
251 end(), _M_get_Tp_allocator());
255 std::copy(__x._M_impl._M_start, __x._M_impl._M_start +
size(),
256 this->_M_impl._M_start);
257 std::__uninitialized_copy_a(__x._M_impl._M_start +
size(),
258 __x._M_impl._M_finish,
259 this->_M_impl._M_finish,
260 _M_get_Tp_allocator());
262 this->_M_impl._M_finish = this->_M_impl._M_start + __xlen;
267 template<
typename _Tp,
typename _Alloc>
274 if (__n > capacity())
277 __builtin_unreachable();
278 vector __tmp(__n, __val, _M_get_Tp_allocator());
279 __tmp._M_impl._M_swap_data(this->_M_impl);
284 const size_type __add = __n - __sz;
285 _GLIBCXX_ASAN_ANNOTATE_GROW(__add);
286 this->_M_impl._M_finish =
287 std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
288 __add, __val, _M_get_Tp_allocator());
289 _GLIBCXX_ASAN_ANNOTATE_GREW(__add);
292 _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val));
295 template<
typename _Tp,
typename _Alloc>
296 template<
typename _InputIterator>
301 std::input_iterator_tag)
303 pointer __cur(this->_M_impl._M_start);
304 for (; __first != __last && __cur != this->_M_impl._M_finish;
305 ++__cur, (void)++__first)
307 if (__first == __last)
308 _M_erase_at_end(__cur);
310 _M_range_insert(
end(), __first, __last,
314 template<
typename _Tp,
typename _Alloc>
315 template<
typename _ForwardIterator>
319 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
320 std::forward_iterator_tag)
325 if (__len > capacity())
328 __builtin_unreachable();
330 _S_check_init_len(__len, _M_get_Tp_allocator());
331 pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
332 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
333 _M_get_Tp_allocator());
334 _GLIBCXX_ASAN_ANNOTATE_REINIT;
335 _M_deallocate(this->_M_impl._M_start,
336 this->_M_impl._M_end_of_storage
337 - this->_M_impl._M_start);
338 this->_M_impl._M_start = __tmp;
339 this->_M_impl._M_finish = this->_M_impl._M_start + __len;
340 this->_M_impl._M_end_of_storage = this->_M_impl._M_finish;
342 else if (__sz >= __len)
343 _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start));
346 _ForwardIterator __mid = __first;
348 std::copy(__first, __mid, this->_M_impl._M_start);
349 const size_type __attribute__((__unused__)) __n = __len - __sz;
350 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
351 this->_M_impl._M_finish =
352 std::__uninitialized_copy_a(__mid, __last,
353 this->_M_impl._M_finish,
354 _M_get_Tp_allocator());
355 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
359#if __cplusplus >= 201103L
360 template<
typename _Tp,
typename _Alloc>
366 const auto __n = __position -
cbegin();
367 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
368 if (__position ==
cend())
370 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
371 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
373 ++this->_M_impl._M_finish;
374 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
381 return iterator(this->_M_impl._M_start + __n);
384 template<
typename _Tp,
typename _Alloc>
385 template<
typename... _Args>
392 const auto __n = __position -
cbegin();
393 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
394 if (__position ==
cend())
396 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
397 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
399 ++this->_M_impl._M_finish;
400 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
413 return iterator(this->_M_impl._M_start + __n);
416 template<
typename _Tp,
typename _Alloc>
417 template<
typename _Arg>
423 template<
typename _Tp,
typename _Alloc>
429 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
430 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
431 _GLIBCXX_MOVE(*(this->_M_impl._M_finish - 1)));
432 ++this->_M_impl._M_finish;
433 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
434#if __cplusplus < 201103L
437 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
438 this->_M_impl._M_finish - 2,
439 this->_M_impl._M_finish - 1);
440#if __cplusplus < 201103L
441 *__position = __x_copy;
447#if __cplusplus >= 201103L
448 template<
typename _Tp,
typename _Alloc>
449 template<
typename... _Args>
455 template<
typename _Tp,
typename _Alloc>
461 const size_type __len = _M_check_len(1u,
"vector::_M_realloc_insert");
463 __builtin_unreachable ();
464 pointer __old_start = this->_M_impl._M_start;
465 pointer __old_finish = this->_M_impl._M_finish;
467 pointer __new_start(this->_M_allocate(__len));
468 pointer __new_finish(__new_start);
475 _Tp_alloc_type& _M_alloc;
478 _Guard(pointer __s, size_type __l, _Tp_alloc_type& __a)
479 : _M_storage(__s), _M_len(__l), _M_alloc(__a)
491 _Guard(
const _Guard&);
495 _Guard __guard(__new_start, __len, _M_impl);
504#if __cplusplus >= 201103L
505 _Alloc_traits::construct(this->_M_impl,
506 std::__to_address(__new_start + __elems_before),
509 _Alloc_traits::construct(this->_M_impl,
510 __new_start + __elems_before,
514#if __cplusplus >= 201103L
515 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
518 __new_finish = _S_relocate(__old_start, __position.base(),
519 __new_start, _M_get_Tp_allocator());
521 __new_finish = _S_relocate(__position.base(), __old_finish,
522 __new_finish, _M_get_Tp_allocator());
530 pointer _M_first, _M_last;
531 _Tp_alloc_type& _M_alloc;
534 _Guard_elts(pointer __elt, _Tp_alloc_type& __a)
535 : _M_first(__elt), _M_last(__elt + 1), _M_alloc(__a)
543 _Guard_elts(
const _Guard_elts&);
547 _Guard_elts __guard_elts(__new_start + __elems_before, _M_impl);
549 __new_finish = std::__uninitialized_move_if_noexcept_a(
550 __old_start, __position.base(),
551 __new_start, _M_get_Tp_allocator());
555 __guard_elts._M_first = __new_start;
557 __new_finish = std::__uninitialized_move_if_noexcept_a(
558 __position.base(), __old_finish,
559 __new_finish, _M_get_Tp_allocator());
562 __guard_elts._M_first = __old_start;
563 __guard_elts._M_last = __old_finish;
565 __guard._M_storage = __old_start;
566 __guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
571 this->_M_impl._M_start = __new_start;
572 this->_M_impl._M_finish = __new_finish;
573 this->_M_impl._M_end_of_storage = __new_start + __len;
576#if __cplusplus >= 201103L
577 template<
typename _Tp,
typename _Alloc>
578 template<
typename... _Args>
584 template<
typename _Tp,
typename _Alloc>
590 const size_type __len = _M_check_len(1u,
"vector::_M_realloc_append");
592 __builtin_unreachable ();
593 pointer __old_start = this->_M_impl._M_start;
594 pointer __old_finish = this->_M_impl._M_finish;
596 pointer __new_start(this->_M_allocate(__len));
597 pointer __new_finish(__new_start);
604 _Tp_alloc_type& _M_alloc;
607 _Guard(pointer __s, size_type __l, _Tp_alloc_type& __a)
608 : _M_storage(__s), _M_len(__l), _M_alloc(__a)
620 _Guard(
const _Guard&);
624 _Guard __guard(__new_start, __len, _M_impl);
633#if __cplusplus >= 201103L
634 _Alloc_traits::construct(this->_M_impl,
635 std::__to_address(__new_start + __elems),
638 _Alloc_traits::construct(this->_M_impl,
639 __new_start + __elems,
643#if __cplusplus >= 201103L
644 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
647 __new_finish = _S_relocate(__old_start, __old_finish,
648 __new_start, _M_get_Tp_allocator());
657 pointer _M_first, _M_last;
658 _Tp_alloc_type& _M_alloc;
661 _Guard_elts(pointer __elt, _Tp_alloc_type& __a)
662 : _M_first(__elt), _M_last(__elt + 1), _M_alloc(__a)
670 _Guard_elts(
const _Guard_elts&);
674 _Guard_elts __guard_elts(__new_start + __elems, _M_impl);
676 __new_finish = std::__uninitialized_move_if_noexcept_a(
677 __old_start, __old_finish,
678 __new_start, _M_get_Tp_allocator());
683 __guard_elts._M_first = __old_start;
684 __guard_elts._M_last = __old_finish;
686 __guard._M_storage = __old_start;
687 __guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
692 this->_M_impl._M_start = __new_start;
693 this->_M_impl._M_finish = __new_finish;
694 this->_M_impl._M_end_of_storage = __new_start + __len;
697 template<
typename _Tp,
typename _Alloc>
705 if (__position.base() == this->_M_impl._M_finish)
706 _M_fill_append(__n, __x);
707 else if (
size_type(this->_M_impl._M_end_of_storage
708 - this->_M_impl._M_finish) >= __n)
710#if __cplusplus < 201103L
713 _Temporary_value __tmp(
this, __x);
717 pointer __old_finish(this->_M_impl._M_finish);
718 if (__elems_after > __n)
720 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
721 std::__uninitialized_move_a(__old_finish - __n,
724 _M_get_Tp_allocator());
725 this->_M_impl._M_finish += __n;
726 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
727 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
728 __old_finish - __n, __old_finish);
729 std::fill(__position.base(), __position.base() + __n,
734 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
735 this->_M_impl._M_finish =
736 std::__uninitialized_fill_n_a(__old_finish,
739 _M_get_Tp_allocator());
740 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
741 std::__uninitialized_move_a(__position.base(), __old_finish,
742 this->_M_impl._M_finish,
743 _M_get_Tp_allocator());
744 this->_M_impl._M_finish += __elems_after;
745 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
746 std::fill(__position.base(), __old_finish, __x_copy);
753 pointer __old_start = this->_M_impl._M_start;
754 pointer __old_finish = this->_M_impl._M_finish;
755 const pointer __pos = __position.base();
758 _M_check_len(__n,
"vector::_M_fill_insert");
759 const size_type __elems_before = __pos - __old_start;
760 pointer __new_start(this->_M_allocate(__len));
761 pointer __new_finish(__new_start);
765 std::__uninitialized_fill_n_a(__new_start + __elems_before,
767 _M_get_Tp_allocator());
768 __new_finish = pointer();
771 = std::__uninitialized_move_if_noexcept_a
772 (__old_start, __pos, __new_start, _M_get_Tp_allocator());
777 = std::__uninitialized_move_if_noexcept_a
778 (__pos, __old_finish, __new_finish, _M_get_Tp_allocator());
784 __new_start + __elems_before + __n,
785 _M_get_Tp_allocator());
788 _M_get_Tp_allocator());
789 _M_deallocate(__new_start, __len);
790 __throw_exception_again;
792 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
793 _GLIBCXX_ASAN_ANNOTATE_REINIT;
794 _M_deallocate(__old_start,
795 this->_M_impl._M_end_of_storage - __old_start);
796 this->_M_impl._M_start = __new_start;
797 this->_M_impl._M_finish = __new_finish;
798 this->_M_impl._M_end_of_storage = __new_start + __len;
803 template<
typename _Tp,
typename _Alloc>
809 if (
size_type(this->_M_impl._M_end_of_storage
810 - this->_M_impl._M_finish) >= __n)
812 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
813 this->_M_impl._M_finish =
814 std::__uninitialized_fill_n_a(this->_M_impl._M_finish, __n, __x,
815 _M_get_Tp_allocator());
816 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
822 pointer __old_start = this->_M_impl._M_start;
823 pointer __old_finish = this->_M_impl._M_finish;
824 const size_type __old_size = __old_finish - __old_start;
827 _M_check_len(__n,
"vector::_M_fill_append");
828 pointer __new_start(this->_M_allocate(__len));
829 pointer __new_finish(__new_start + __old_size);
833 __new_finish = std::__uninitialized_fill_n_a(
834 __new_finish, __n, __x,
835 _M_get_Tp_allocator());
836 std::__uninitialized_move_if_noexcept_a(
837 __old_start, __old_finish, __new_start,
838 _M_get_Tp_allocator());
843 _M_get_Tp_allocator());
844 _M_deallocate(__new_start, __len);
845 __throw_exception_again;
847 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
848 _GLIBCXX_ASAN_ANNOTATE_REINIT;
849 _M_deallocate(__old_start,
850 this->_M_impl._M_end_of_storage - __old_start);
851 this->_M_impl._M_start = __new_start;
852 this->_M_impl._M_finish = __new_finish;
853 this->_M_impl._M_end_of_storage = __new_start + __len;
857#if __cplusplus >= 201103L
858 template<
typename _Tp,
typename _Alloc>
868 - this->_M_impl._M_finish);
870 if (__size > max_size() || __navail > max_size() - __size)
871 __builtin_unreachable();
875 if (!this->_M_impl._M_finish)
876 __builtin_unreachable();
878 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
879 this->_M_impl._M_finish =
880 std::__uninitialized_default_n_a(this->_M_impl._M_finish,
881 __n, _M_get_Tp_allocator());
882 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
888 pointer __old_start = this->_M_impl._M_start;
889 pointer __old_finish = this->_M_impl._M_finish;
892 _M_check_len(__n,
"vector::_M_default_append");
893 pointer __new_start(this->_M_allocate(__len));
900 _Tp_alloc_type& _M_alloc;
903 _Guard(pointer __s, size_type __l, _Tp_alloc_type& __a)
904 : _M_storage(__s), _M_len(__l), _M_alloc(__a)
916 _Guard(
const _Guard&);
920 _Guard __guard(__new_start, __len, _M_impl);
922 std::__uninitialized_default_n_a(__new_start + __size, __n,
923 _M_get_Tp_allocator());
925 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
927 _S_relocate(__old_start, __old_finish,
928 __new_start, _M_get_Tp_allocator());
935 pointer _M_first, _M_last;
936 _Tp_alloc_type& _M_alloc;
939 _Guard_elts(pointer __first, size_type __n,
941 : _M_first(__first), _M_last(__first + __n), _M_alloc(__a)
949 _Guard_elts(
const _Guard_elts&);
951 _Guard_elts __guard_elts(__new_start + __size, __n, _M_impl);
953 std::__uninitialized_move_if_noexcept_a(
954 __old_start, __old_finish, __new_start,
955 _M_get_Tp_allocator());
957 __guard_elts._M_first = __old_start;
958 __guard_elts._M_last = __old_finish;
960 _GLIBCXX_ASAN_ANNOTATE_REINIT;
961 __guard._M_storage = __old_start;
962 __guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
967 this->_M_impl._M_start = __new_start;
968 this->_M_impl._M_finish = __new_start + __size + __n;
969 this->_M_impl._M_end_of_storage = __new_start + __len;
974 template<
typename _Tp,
typename _Alloc>
980 if (capacity() ==
size())
982 _GLIBCXX_ASAN_ANNOTATE_REINIT;
983 return std::__shrink_to_fit_aux<vector>::_S_do_it(*
this);
987 template<
typename _Tp,
typename _Alloc>
988 template<
typename _InputIterator>
993 _InputIterator __last, std::input_iterator_tag)
997 for (; __first != __last; ++__first)
998 insert(
end(), *__first);
1000 else if (__first != __last)
1002 vector __tmp(__first, __last, _M_get_Tp_allocator());
1004 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()),
1005 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end()));
1009 template<
typename _Tp,
typename _Alloc>
1010 template<
typename _ForwardIterator>
1011 _GLIBCXX20_CONSTEXPR
1015 _ForwardIterator __last, std::forward_iterator_tag)
1017 if (__first != __last)
1020 if (
size_type(this->_M_impl._M_end_of_storage
1021 - this->_M_impl._M_finish) >= __n)
1024 pointer __old_finish(this->_M_impl._M_finish);
1025 if (__elems_after > __n)
1027 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
1028 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
1029 this->_M_impl._M_finish,
1030 this->_M_impl._M_finish,
1031 _M_get_Tp_allocator());
1032 this->_M_impl._M_finish += __n;
1033 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
1034 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
1035 __old_finish - __n, __old_finish);
1036 std::copy(__first, __last, __position);
1040 _ForwardIterator __mid = __first;
1042 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
1043 std::__uninitialized_copy_a(__mid, __last,
1044 this->_M_impl._M_finish,
1045 _M_get_Tp_allocator());
1046 this->_M_impl._M_finish += __n - __elems_after;
1047 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
1048 std::__uninitialized_move_a(__position.base(),
1050 this->_M_impl._M_finish,
1051 _M_get_Tp_allocator());
1052 this->_M_impl._M_finish += __elems_after;
1053 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
1054 std::copy(__first, __mid, __position);
1062 pointer __old_start = this->_M_impl._M_start;
1063 pointer __old_finish = this->_M_impl._M_finish;
1064 if ((__old_finish - __old_start) < 0)
1065 __builtin_unreachable();
1068 _M_check_len(__n,
"vector::_M_range_insert");
1069#if __cplusplus < 201103L
1070 if (__len < (__n + (__old_finish - __old_start)))
1071 __builtin_unreachable();
1074 pointer __new_start(this->_M_allocate(__len));
1075 pointer __new_finish(__new_start);
1079 = std::__uninitialized_move_if_noexcept_a
1080 (__old_start, __position.base(),
1081 __new_start, _M_get_Tp_allocator());
1083 = std::__uninitialized_copy_a(__first, __last,
1085 _M_get_Tp_allocator());
1087 = std::__uninitialized_move_if_noexcept_a
1088 (__position.base(), __old_finish,
1089 __new_finish, _M_get_Tp_allocator());
1094 _M_get_Tp_allocator());
1095 _M_deallocate(__new_start, __len);
1096 __throw_exception_again;
1099 _M_get_Tp_allocator());
1100 _GLIBCXX_ASAN_ANNOTATE_REINIT;
1101 _M_deallocate(__old_start,
1102 this->_M_impl._M_end_of_storage - __old_start);
1103 this->_M_impl._M_start = __new_start;
1104 this->_M_impl._M_finish = __new_finish;
1105 this->_M_impl._M_end_of_storage = __new_start + __len;
1112 template<
typename _Alloc>
1113 _GLIBCXX20_CONSTEXPR
1120 __builtin_unreachable();
1121 _Bit_pointer __q = this->_M_allocate(__n);
1123 iterator __finish(_M_copy_aligned(__begin, __end, __start));
1124 this->_M_deallocate();
1125 this->_M_impl._M_start = __start;
1126 this->_M_impl._M_finish = __finish;
1127 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
1130 template<
typename _Alloc>
1131 _GLIBCXX20_CONSTEXPR
1138 if (capacity() -
size() >= __n)
1140 std::copy_backward(__position,
end(),
1147 const size_type __len =
1148 _M_check_len(__n,
"vector<bool>::_M_fill_insert");
1149 iterator __begin =
begin(), __end =
end();
1150 _Bit_pointer __q = this->_M_allocate(__len);
1152 iterator __i = _M_copy_aligned(__begin, __position, __start);
1153 std::fill(__i, __i + difference_type(__n), __x);
1154 iterator __finish = std::copy(__position, __end,
1155 __i + difference_type(__n));
1156 this->_M_deallocate();
1157 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
1158 this->_M_impl._M_start = __start;
1159 this->_M_impl._M_finish = __finish;
1163 template<
typename _Alloc>
1164 template<
typename _ForwardIterator>
1165 _GLIBCXX20_CONSTEXPR
1169 _ForwardIterator __last, std::forward_iterator_tag)
1171 if (__first != __last)
1174 if (capacity() -
size() >= __n)
1176 std::copy_backward(__position,
end(),
1177 this->_M_impl._M_finish
1179 std::copy(__first, __last, __position);
1185 _M_check_len(__n,
"vector<bool>::_M_insert_range");
1187 _Bit_pointer __q = this->_M_allocate(__len);
1189 iterator __i = _M_copy_aligned(__begin, __position, __start);
1190 __i = std::copy(__first, __last, __i);
1191 iterator __finish = std::copy(__position, __end, __i);
1192 this->_M_deallocate();
1193 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
1194 this->_M_impl._M_start = __start;
1195 this->_M_impl._M_finish = __finish;
1200 template<
typename _Alloc>
1201 _GLIBCXX20_CONSTEXPR
1206 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
1208 std::copy_backward(__position, this->_M_impl._M_finish,
1209 this->_M_impl._M_finish + 1);
1211 ++this->_M_impl._M_finish;
1216 _M_check_len(
size_type(1),
"vector<bool>::_M_insert_aux");
1217 _Bit_pointer __q = this->_M_allocate(__len);
1219 iterator __i = _M_copy_aligned(
begin(), __position, __start);
1221 iterator __finish = std::copy(__position,
end(), __i);
1222 this->_M_deallocate();
1223 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
1224 this->_M_impl._M_start = __start;
1225 this->_M_impl._M_finish = __finish;
1229 template<
typename _Alloc>
1230 _GLIBCXX20_CONSTEXPR
1231 typename vector<bool, _Alloc>::iterator
1235 if (__position + 1 !=
end())
1236 std::copy(__position + 1,
end(), __position);
1237 --this->_M_impl._M_finish;
1241 template<
typename _Alloc>
1242 _GLIBCXX20_CONSTEXPR
1243 typename vector<bool, _Alloc>::iterator
1247 if (__first != __last)
1248 _M_erase_at_end(std::copy(__last,
end(), __first));
1252#if __cplusplus >= 201103L
1253 template<
typename _Alloc>
1254 _GLIBCXX20_CONSTEXPR
1259 if (capacity() -
size() <
int(_S_word_bit))
1267 this->_M_deallocate();
1268 this->_M_impl._M_reset();
1277_GLIBCXX_END_NAMESPACE_CONTAINER
1278_GLIBCXX_END_NAMESPACE_VERSION
1281#if __cplusplus >= 201103L
1283namespace std _GLIBCXX_VISIBILITY(default)
1285_GLIBCXX_BEGIN_NAMESPACE_VERSION
1287 template<
typename _Alloc>
1290 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b)
const noexcept
1293 const size_t __words = __b.size() / _S_word_bit;
1296 const size_t __clength = __words *
sizeof(_Bit_type);
1297 __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
1300 const size_t __extrabits = __b.size() % _S_word_bit;
1303 _Bit_type __hiword = *__b._M_impl._M_finish._M_p;
1304 __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits);
1306 const size_t __clength
1307 = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__;
1309 __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
1311 __hash = std::_Hash_impl::hash(&__hiword, __clength);
1317_GLIBCXX_END_NAMESPACE_VERSION
1322#undef _GLIBCXX_ASAN_ANNOTATE_REINIT
1323#undef _GLIBCXX_ASAN_ANNOTATE_GROW
1324#undef _GLIBCXX_ASAN_ANNOTATE_GREW
1325#undef _GLIBCXX_ASAN_ANNOTATE_SHRINK
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
_Tp * end(valarray< _Tp > &__va) noexcept
Return an iterator pointing to one past the last element of the valarray.
_Tp * begin(valarray< _Tp > &__va) noexcept
Return an iterator pointing to the first element of the valarray.
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.
constexpr auto cend(const _Container &__cont) noexcept(noexcept(std::end(__cont))) -> decltype(std::end(__cont))
Return an iterator pointing to one past the last element of the const container.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
constexpr auto cbegin(const _Container &__cont) noexcept(noexcept(std::begin(__cont))) -> decltype(std::begin(__cont))
Return an iterator pointing to the first element of the const container.
constexpr void _Destroy(_ForwardIterator __first, _ForwardIterator __last)
Primary class template hash.
A standard container which offers fixed time access to individual elements in any order.
constexpr iterator insert(const_iterator __position, const value_type &__x)
Inserts given value into vector before specified iterator.
constexpr iterator end() noexcept
vector()=default
Creates a vector with no elements.
constexpr iterator begin() noexcept
constexpr size_type capacity() const noexcept
constexpr void reserve(size_type __n)
Attempt to preallocate enough memory for specified number of elements.
constexpr pointer _M_allocate_and_copy(size_type __n, _ForwardIterator __first, _ForwardIterator __last)
constexpr void clear() noexcept
constexpr size_type size() const noexcept
constexpr vector & operator=(const vector &__x)
Vector assignment operator.
constexpr size_type max_size() const noexcept
static constexpr void deallocate(_Alloc &__a, pointer __p, size_type __n)
Deallocate memory.