59namespace std _GLIBCXX_VISIBILITY(default)
61_GLIBCXX_BEGIN_NAMESPACE_VERSION
62_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
64#pragma GCC diagnostic push
65#pragma GCC diagnostic ignored "-Wc++17-extensions"
67 template<
typename _Tp,
typename _Alloc>
74 __throw_length_error(__N(
"vector::reserve"));
77 const size_type __old_size =
size();
79#if __cplusplus >= 201103L
80 if constexpr (_S_use_relocate())
82 __tmp = this->_M_allocate(__n);
83 std::__relocate_a(this->_M_impl._M_start, this->_M_impl._M_finish,
84 __tmp, _M_get_Tp_allocator());
90 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_start),
91 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_finish));
92 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
93 _M_get_Tp_allocator());
95 _GLIBCXX_ASAN_ANNOTATE_REINIT;
96 _M_deallocate(this->_M_impl._M_start,
97 this->_M_impl._M_end_of_storage
98 - this->_M_impl._M_start);
99 this->_M_impl._M_start = __tmp;
100 this->_M_impl._M_finish = __tmp + __old_size;
101 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
104#pragma GCC diagnostic pop
106#if __cplusplus >= 201103L
107 template<
typename _Tp,
typename _Alloc>
108 template<
typename... _Args>
109#if __cplusplus > 201402L
111 typename vector<_Tp, _Alloc>::reference
118 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
120 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
121 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
123 ++this->_M_impl._M_finish;
124 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
128#if __cplusplus > 201402L
134 template<
typename _Tp,
typename _Alloc>
136 typename vector<_Tp, _Alloc>::iterator
138#if __cplusplus >= 201103L
139 insert(const_iterator __position,
const value_type& __x)
141 insert(iterator __position,
const value_type& __x)
144 const size_type __n = __position -
begin();
145 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
147 __glibcxx_assert(__position != const_iterator());
148 if (!(__position != const_iterator()))
149 __builtin_unreachable();
151 if (__position ==
end())
153 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
154 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
156 ++this->_M_impl._M_finish;
157 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
161#if __cplusplus >= 201103L
162 const auto __pos =
begin() + (__position -
cbegin());
165 _Temporary_value __x_copy(
this, __x);
166 _M_insert_aux(__pos,
std::move(__x_copy._M_val()));
168 _M_insert_aux(__position, __x);
173#if __cplusplus >= 201103L
174 _M_realloc_insert(
begin() + (__position -
cbegin()), __x);
176 _M_realloc_insert(__position, __x);
179 return iterator(this->_M_impl._M_start + __n);
182 template<
typename _Tp,
typename _Alloc>
184 typename vector<_Tp, _Alloc>::iterator
188 if (__position + 1 !=
end())
189 _GLIBCXX_MOVE3(__position + 1,
end(), __position);
190 --this->_M_impl._M_finish;
191 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
192 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
196 template<
typename _Tp,
typename _Alloc>
198 typename vector<_Tp, _Alloc>::iterator
199 vector<_Tp, _Alloc>::
200 _M_erase(iterator __first, iterator __last)
202 if (__first != __last)
205 _GLIBCXX_MOVE3(__last,
end(), __first);
206 _M_erase_at_end(__first.base() + (
end() - __last));
211 template<
typename _Tp,
typename _Alloc>
219 _GLIBCXX_ASAN_ANNOTATE_REINIT;
220#if __cplusplus >= 201103L
221 if (_Alloc_traits::_S_propagate_on_copy_assign())
223 if (!_Alloc_traits::_S_always_equal()
224 && _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
228 _M_deallocate(this->_M_impl._M_start,
229 this->_M_impl._M_end_of_storage
230 - this->_M_impl._M_start);
231 this->_M_impl._M_start =
nullptr;
232 this->_M_impl._M_finish =
nullptr;
233 this->_M_impl._M_end_of_storage =
nullptr;
235 std::__alloc_on_copy(_M_get_Tp_allocator(),
236 __x._M_get_Tp_allocator());
239 const size_type __xlen = __x.
size();
244 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
245 _M_get_Tp_allocator());
246 _M_deallocate(this->_M_impl._M_start,
247 this->_M_impl._M_end_of_storage
248 - this->_M_impl._M_start);
249 this->_M_impl._M_start = __tmp;
250 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen;
252 else if (
size() >= __xlen)
255 end(), _M_get_Tp_allocator());
259 std::copy(__x._M_impl._M_start, __x._M_impl._M_start +
size(),
260 this->_M_impl._M_start);
261 std::__uninitialized_copy_a(__x._M_impl._M_start +
size(),
262 __x._M_impl._M_finish,
263 this->_M_impl._M_finish,
264 _M_get_Tp_allocator());
266 this->_M_impl._M_finish = this->_M_impl._M_start + __xlen;
271 template<
typename _Tp,
typename _Alloc>
278 if (__n > capacity())
281 __builtin_unreachable();
282 vector __tmp(__n, __val, _M_get_Tp_allocator());
283 __tmp._M_impl._M_swap_data(this->_M_impl);
288 const size_type __add = __n - __sz;
289 _GLIBCXX_ASAN_ANNOTATE_GROW(__add);
290 this->_M_impl._M_finish =
291 std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
292 __add, __val, _M_get_Tp_allocator());
293 _GLIBCXX_ASAN_ANNOTATE_GREW(__add);
296 _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val));
299 template<
typename _Tp,
typename _Alloc>
300 template<
typename _InputIterator>
305 std::input_iterator_tag)
307 pointer __cur(this->_M_impl._M_start);
308 for (; __first != __last && __cur != this->_M_impl._M_finish;
309 ++__cur, (void)++__first)
311 if (__first == __last)
312 _M_erase_at_end(__cur);
314 _M_range_insert(
end(), __first, __last,
318 template<
typename _Tp,
typename _Alloc>
319 template<
typename _ForwardIterator>
323 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
324 std::forward_iterator_tag)
329 if (__len > capacity())
332 __builtin_unreachable();
334 _S_check_init_len(__len, _M_get_Tp_allocator());
335 pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
336 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
337 _M_get_Tp_allocator());
338 _GLIBCXX_ASAN_ANNOTATE_REINIT;
339 _M_deallocate(this->_M_impl._M_start,
340 this->_M_impl._M_end_of_storage
341 - this->_M_impl._M_start);
342 this->_M_impl._M_start = __tmp;
343 this->_M_impl._M_finish = this->_M_impl._M_start + __len;
344 this->_M_impl._M_end_of_storage = this->_M_impl._M_finish;
346 else if (__sz >= __len)
347 _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start));
350 _ForwardIterator __mid = __first;
352 std::copy(__first, __mid, this->_M_impl._M_start);
353 const size_type __attribute__((__unused__)) __n = __len - __sz;
354 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
355 this->_M_impl._M_finish =
356 std::__uninitialized_copy_a(__mid, __last,
357 this->_M_impl._M_finish,
358 _M_get_Tp_allocator());
359 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
363#if __cplusplus >= 201103L
364 template<
typename _Tp,
typename _Alloc>
370 const auto __n = __position -
cbegin();
371 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
372 if (__position ==
cend())
374 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
375 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
377 ++this->_M_impl._M_finish;
378 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
385 return iterator(this->_M_impl._M_start + __n);
388 template<
typename _Tp,
typename _Alloc>
389 template<
typename... _Args>
396 const auto __n = __position -
cbegin();
397 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
398 if (__position ==
cend())
400 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
401 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
403 ++this->_M_impl._M_finish;
404 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
417 return iterator(this->_M_impl._M_start + __n);
420 template<
typename _Tp,
typename _Alloc>
421 template<
typename _Arg>
427 template<
typename _Tp,
typename _Alloc>
433 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
434 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
435 _GLIBCXX_MOVE(*(this->_M_impl._M_finish - 1)));
436 ++this->_M_impl._M_finish;
437 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
438#if __cplusplus < 201103L
441 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
442 this->_M_impl._M_finish - 2,
443 this->_M_impl._M_finish - 1);
444#if __cplusplus < 201103L
445 *__position = __x_copy;
451#pragma GCC diagnostic push
452#pragma GCC diagnostic ignored "-Wc++17-extensions"
453#if __cplusplus >= 201103L
454 template<
typename _Tp,
typename _Alloc>
455 template<
typename... _Args>
461 template<
typename _Tp,
typename _Alloc>
467 const size_type __len = _M_check_len(1u,
"vector::_M_realloc_insert");
469 __builtin_unreachable();
470 pointer __old_start = this->_M_impl._M_start;
471 pointer __old_finish = this->_M_impl._M_finish;
473 pointer __new_start(this->_M_allocate(__len));
474 pointer __new_finish(__new_start);
477 _Guard_alloc __guard(__new_start, __len, *
this);
486#if __cplusplus >= 201103L
487 _Alloc_traits::construct(this->_M_impl,
488 std::__to_address(__new_start + __elems_before),
491 _Alloc_traits::construct(this->_M_impl,
492 __new_start + __elems_before,
496#if __cplusplus >= 201103L
497 if constexpr (_S_use_relocate())
500 __new_finish = std::__relocate_a(__old_start, __position.base(),
502 _M_get_Tp_allocator());
504 __new_finish = std::__relocate_a(__position.base(), __old_finish,
506 _M_get_Tp_allocator());
514 pointer _M_first, _M_last;
515 _Tp_alloc_type& _M_alloc;
518 _Guard_elts(pointer __elt, _Tp_alloc_type& __a)
519 : _M_first(__elt), _M_last(__elt + 1), _M_alloc(__a)
527 _Guard_elts(
const _Guard_elts&);
531 _Guard_elts __guard_elts(__new_start + __elems_before, _M_impl);
533 __new_finish = std::__uninitialized_move_if_noexcept_a(
534 __old_start, __position.base(),
535 __new_start, _M_get_Tp_allocator());
539 __guard_elts._M_first = __new_start;
541 __new_finish = std::__uninitialized_move_if_noexcept_a(
542 __position.base(), __old_finish,
543 __new_finish, _M_get_Tp_allocator());
546 __guard_elts._M_first = __old_start;
547 __guard_elts._M_last = __old_finish;
549 __guard._M_storage = __old_start;
550 __guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
555 this->_M_impl._M_start = __new_start;
556 this->_M_impl._M_finish = __new_finish;
557 this->_M_impl._M_end_of_storage = __new_start + __len;
560#if __cplusplus >= 201103L
561 template<
typename _Tp,
typename _Alloc>
562 template<
typename... _Args>
568 template<
typename _Tp,
typename _Alloc>
574 const size_type __len = _M_check_len(1u,
"vector::_M_realloc_append");
576 __builtin_unreachable();
577 pointer __old_start = this->_M_impl._M_start;
578 pointer __old_finish = this->_M_impl._M_finish;
580 pointer __new_start(this->_M_allocate(__len));
581 pointer __new_finish(__new_start);
584 _Guard_alloc __guard(__new_start, __len, *
this);
593#if __cplusplus >= 201103L
594 _Alloc_traits::construct(this->_M_impl,
595 std::__to_address(__new_start + __elems),
598 _Alloc_traits::construct(this->_M_impl,
599 __new_start + __elems,
603#if __cplusplus >= 201103L
604 if constexpr (_S_use_relocate())
607 __new_finish = std::__relocate_a(__old_start, __old_finish,
609 _M_get_Tp_allocator());
618 pointer _M_first, _M_last;
619 _Tp_alloc_type& _M_alloc;
622 _Guard_elts(pointer __elt, _Tp_alloc_type& __a)
623 : _M_first(__elt), _M_last(__elt + 1), _M_alloc(__a)
631 _Guard_elts(
const _Guard_elts&);
635 _Guard_elts __guard_elts(__new_start + __elems, _M_impl);
637 __new_finish = std::__uninitialized_move_if_noexcept_a(
638 __old_start, __old_finish,
639 __new_start, _M_get_Tp_allocator());
644 __guard_elts._M_first = __old_start;
645 __guard_elts._M_last = __old_finish;
647 __guard._M_storage = __old_start;
648 __guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
653 this->_M_impl._M_start = __new_start;
654 this->_M_impl._M_finish = __new_finish;
655 this->_M_impl._M_end_of_storage = __new_start + __len;
657#pragma GCC diagnostic pop
659 template<
typename _Tp,
typename _Alloc>
667 if (__position.base() == this->_M_impl._M_finish)
668 _M_fill_append(__n, __x);
669 else if (
size_type(this->_M_impl._M_end_of_storage
670 - this->_M_impl._M_finish) >= __n)
672#if __cplusplus < 201103L
675 _Temporary_value __tmp(
this, __x);
679 pointer __old_finish(this->_M_impl._M_finish);
680 if (__elems_after > __n)
682 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
683 std::__uninitialized_move_a(__old_finish - __n,
686 _M_get_Tp_allocator());
687 this->_M_impl._M_finish += __n;
688 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
689 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
690 __old_finish - __n, __old_finish);
691 std::fill(__position.base(), __position.base() + __n,
696 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
697 this->_M_impl._M_finish =
698 std::__uninitialized_fill_n_a(__old_finish,
701 _M_get_Tp_allocator());
702 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
703 std::__uninitialized_move_a(__position.base(), __old_finish,
704 this->_M_impl._M_finish,
705 _M_get_Tp_allocator());
706 this->_M_impl._M_finish += __elems_after;
707 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
708 std::fill(__position.base(), __old_finish, __x_copy);
715 pointer __old_start = this->_M_impl._M_start;
716 pointer __old_finish = this->_M_impl._M_finish;
717 const pointer __pos = __position.base();
720 _M_check_len(__n,
"vector::_M_fill_insert");
721 const size_type __elems_before = __pos - __old_start;
722 pointer __new_start(this->_M_allocate(__len));
723 pointer __new_finish(__new_start);
727 std::__uninitialized_fill_n_a(__new_start + __elems_before,
729 _M_get_Tp_allocator());
730 __new_finish = pointer();
733 = std::__uninitialized_move_if_noexcept_a
734 (__old_start, __pos, __new_start, _M_get_Tp_allocator());
739 = std::__uninitialized_move_if_noexcept_a
740 (__pos, __old_finish, __new_finish, _M_get_Tp_allocator());
746 __new_start + __elems_before + __n,
747 _M_get_Tp_allocator());
750 _M_get_Tp_allocator());
751 _M_deallocate(__new_start, __len);
752 __throw_exception_again;
754 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
755 _GLIBCXX_ASAN_ANNOTATE_REINIT;
756 _M_deallocate(__old_start,
757 this->_M_impl._M_end_of_storage - __old_start);
758 this->_M_impl._M_start = __new_start;
759 this->_M_impl._M_finish = __new_finish;
760 this->_M_impl._M_end_of_storage = __new_start + __len;
765 template<
typename _Tp,
typename _Alloc>
771 if (
size_type(this->_M_impl._M_end_of_storage
772 - this->_M_impl._M_finish) >= __n)
774 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
775 this->_M_impl._M_finish =
776 std::__uninitialized_fill_n_a(this->_M_impl._M_finish, __n, __x,
777 _M_get_Tp_allocator());
778 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
784 pointer __old_start = this->_M_impl._M_start;
785 pointer __old_finish = this->_M_impl._M_finish;
786 const size_type __old_size = __old_finish - __old_start;
789 _M_check_len(__n,
"vector::_M_fill_append");
790 pointer __new_start(this->_M_allocate(__len));
791 pointer __new_finish(__new_start + __old_size);
795 __new_finish = std::__uninitialized_fill_n_a(
796 __new_finish, __n, __x,
797 _M_get_Tp_allocator());
798 std::__uninitialized_move_if_noexcept_a(
799 __old_start, __old_finish, __new_start,
800 _M_get_Tp_allocator());
805 _M_get_Tp_allocator());
806 _M_deallocate(__new_start, __len);
807 __throw_exception_again;
809 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
810 _GLIBCXX_ASAN_ANNOTATE_REINIT;
811 _M_deallocate(__old_start,
812 this->_M_impl._M_end_of_storage - __old_start);
813 this->_M_impl._M_start = __new_start;
814 this->_M_impl._M_finish = __new_finish;
815 this->_M_impl._M_end_of_storage = __new_start + __len;
819#if __cplusplus >= 201103L
820#pragma GCC diagnostic push
821#pragma GCC diagnostic ignored "-Wc++17-extensions"
822 template<
typename _Tp,
typename _Alloc>
832 - this->_M_impl._M_finish);
834 if (__size > max_size() || __navail > max_size() - __size)
835 __builtin_unreachable();
839 if (!this->_M_impl._M_finish)
840 __builtin_unreachable();
842 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
843 this->_M_impl._M_finish =
844 std::__uninitialized_default_n_a(this->_M_impl._M_finish,
845 __n, _M_get_Tp_allocator());
846 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
852 pointer __old_start = this->_M_impl._M_start;
853 pointer __old_finish = this->_M_impl._M_finish;
856 _M_check_len(__n,
"vector::_M_default_append");
857 pointer __new_start(this->_M_allocate(__len));
860 _Guard_alloc __guard(__new_start, __len, *
this);
862 std::__uninitialized_default_n_a(__new_start + __size, __n,
863 _M_get_Tp_allocator());
865 if constexpr (_S_use_relocate())
867 std::__relocate_a(__old_start, __old_finish,
868 __new_start, _M_get_Tp_allocator());
875 pointer _M_first, _M_last;
876 _Tp_alloc_type& _M_alloc;
879 _Guard_elts(pointer __first, size_type __n,
881 : _M_first(__first), _M_last(__first + __n), _M_alloc(__a)
889 _Guard_elts(
const _Guard_elts&);
891 _Guard_elts __guard_elts(__new_start + __size, __n, _M_impl);
893 std::__uninitialized_move_if_noexcept_a(
894 __old_start, __old_finish, __new_start,
895 _M_get_Tp_allocator());
897 __guard_elts._M_first = __old_start;
898 __guard_elts._M_last = __old_finish;
900 _GLIBCXX_ASAN_ANNOTATE_REINIT;
901 __guard._M_storage = __old_start;
902 __guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
907 this->_M_impl._M_start = __new_start;
908 this->_M_impl._M_finish = __new_start + __size + __n;
909 this->_M_impl._M_end_of_storage = __new_start + __len;
913#pragma GCC diagnostic pop
915 template<
typename _Tp,
typename _Alloc>
921 if (capacity() ==
size())
923 _GLIBCXX_ASAN_ANNOTATE_REINIT;
924 return std::__shrink_to_fit_aux<vector>::_S_do_it(*
this);
928 template<
typename _Tp,
typename _Alloc>
929 template<
typename _InputIterator>
934 _InputIterator __last, std::input_iterator_tag)
938 for (; __first != __last; ++__first)
939 insert(
end(), *__first);
941 else if (__first != __last)
943 vector __tmp(__first, __last, _M_get_Tp_allocator());
945 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()),
946 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end()));
950 template<
typename _Tp,
typename _Alloc>
951 template<
typename _ForwardIterator>
956 _ForwardIterator __last, std::forward_iterator_tag)
958 if (__first != __last)
961 if (
size_type(this->_M_impl._M_end_of_storage
962 - this->_M_impl._M_finish) >= __n)
965 pointer __old_finish(this->_M_impl._M_finish);
966 if (__elems_after > __n)
968 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
969 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
970 this->_M_impl._M_finish,
971 this->_M_impl._M_finish,
972 _M_get_Tp_allocator());
973 this->_M_impl._M_finish += __n;
974 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
975 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
976 __old_finish - __n, __old_finish);
977 std::copy(__first, __last, __position);
981 _ForwardIterator __mid = __first;
983 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
984 std::__uninitialized_copy_a(__mid, __last,
985 this->_M_impl._M_finish,
986 _M_get_Tp_allocator());
987 this->_M_impl._M_finish += __n - __elems_after;
988 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
989 std::__uninitialized_move_a(__position.base(),
991 this->_M_impl._M_finish,
992 _M_get_Tp_allocator());
993 this->_M_impl._M_finish += __elems_after;
994 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
995 std::copy(__first, __mid, __position);
1003 pointer __old_start = this->_M_impl._M_start;
1004 pointer __old_finish = this->_M_impl._M_finish;
1007 _M_check_len(__n,
"vector::_M_range_insert");
1008#if __cplusplus < 201103L
1009 if (__len < (__n + (__old_finish - __old_start)))
1010 __builtin_unreachable();
1013 pointer __new_start(this->_M_allocate(__len));
1014 pointer __new_finish(__new_start);
1018 = std::__uninitialized_move_if_noexcept_a
1019 (__old_start, __position.base(),
1020 __new_start, _M_get_Tp_allocator());
1022 = std::__uninitialized_copy_a(__first, __last,
1024 _M_get_Tp_allocator());
1026 = std::__uninitialized_move_if_noexcept_a
1027 (__position.base(), __old_finish,
1028 __new_finish, _M_get_Tp_allocator());
1033 _M_get_Tp_allocator());
1034 _M_deallocate(__new_start, __len);
1035 __throw_exception_again;
1038 _M_get_Tp_allocator());
1039 _GLIBCXX_ASAN_ANNOTATE_REINIT;
1040 _M_deallocate(__old_start,
1041 this->_M_impl._M_end_of_storage - __old_start);
1042 this->_M_impl._M_start = __new_start;
1043 this->_M_impl._M_finish = __new_finish;
1044 this->_M_impl._M_end_of_storage = __new_start + __len;
1049#if __glibcxx_containers_ranges
1050 template<
typename _Tp,
typename _Alloc>
1051 template<__detail::__container_compatible_range<_Tp> _Rg>
1057 if (__pos ==
cend())
1059 const auto __ins_idx =
size();
1061 return begin() + __ins_idx;
1064 if constexpr (ranges::forward_range<_Rg>)
1066 const auto __ins_idx = __pos -
cbegin();
1068 const auto __n =
size_type(ranges::distance(__rg));
1070 return begin() + __ins_idx;
1073 pointer __old_start = this->_M_impl._M_start;
1075 pointer __old_finish = this->_M_impl._M_finish;
1077 pointer __ins = __old_start + __ins_idx;
1079 const auto __cap = this->_M_impl._M_end_of_storage - __old_finish;
1084 if (__elems_after > __n)
1086 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
1087 std::__uninitialized_move_a(__old_finish - __n,
1090 _M_get_Tp_allocator());
1091 this->_M_impl._M_finish += __n;
1092 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
1094 ranges::copy(__rg, __ins);
1098 auto __first = ranges::begin(__rg);
1099 const auto __last = ranges::end(__rg);
1100 auto __mid = ranges::next(__first, __elems_after);
1101 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
1103 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
1104 std::__uninitialized_move_a(__ins, __old_finish,
1105 this->_M_impl._M_finish,
1106 _M_get_Tp_allocator());
1107 this->_M_impl._M_finish += __elems_after;
1108 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
1109 ranges::copy(__first, __mid, __ins);
1115 = _M_check_len(__n,
"vector::insert_range");
1117 struct _Guard : _Guard_alloc
1120 pointer _M_finish = _Guard_alloc::_M_storage;
1122 using _Guard_alloc::_Guard_alloc;
1128 this->_M_vect._M_get_Tp_allocator());
1133 pointer __new_start(this->_M_allocate(__len));
1134 _Guard __guard(__new_start, __len, *
this);
1136 auto& __alloc = _M_get_Tp_allocator();
1144 = std::__uninitialized_move_if_noexcept_a(
1145 __old_start, __ins, __new_start, __alloc);
1148 _Base::_M_append_range_to(__rg, __guard._M_finish);
1152 = std::__uninitialized_move_if_noexcept_a(
1153 __ins, __old_finish, __guard._M_finish, __alloc);
1155 _GLIBCXX_ASAN_ANNOTATE_REINIT;
1159 this->_M_impl._M_start = __guard._M_storage;
1160 this->_M_impl._M_finish = __guard._M_finish;
1161 this->_M_impl._M_end_of_storage = __new_start + __len;
1162 __guard._M_storage = __old_start;
1163 __guard._M_finish = __old_finish;
1164 __guard._M_len = (__old_finish - __old_start) + __cap;
1169 return begin() + __ins_idx;
1173 _M_get_Tp_allocator()));
1178 template<
typename _Alloc>
1179 _GLIBCXX20_CONSTEXPR
1186 __builtin_unreachable();
1187 _Bit_pointer __q = this->_M_allocate(__n);
1189 iterator __finish(_M_copy_aligned(__begin, __end, __start));
1190 this->_M_deallocate();
1191 this->_M_impl._M_start = __start;
1192 this->_M_impl._M_finish = __finish;
1193 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
1196 template<
typename _Alloc>
1197 _GLIBCXX20_CONSTEXPR
1204 if (capacity() -
size() >= __n)
1206 std::copy_backward(__position,
end(),
1214 _M_check_len(__n,
"vector<bool>::_M_fill_insert");
1216 _Bit_pointer __q = this->_M_allocate(__len);
1218 iterator __i = _M_copy_aligned(__begin, __position, __start);
1220 iterator __finish = std::copy(__position, __end,
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 template<
typename _ForwardIterator>
1231 _GLIBCXX20_CONSTEXPR
1237 if (__first != __last)
1242 std::copy_backward(__position,
end(),
1243 this->_M_impl._M_finish
1244 + difference_type(__n));
1245 std::copy(__first, __last, __position);
1246 this->_M_impl._M_finish += difference_type(__n);
1250 const size_type __len =
1251 _M_check_len(__n,
"vector<bool>::_M_insert_range");
1252 const iterator __begin =
begin(), __end =
end();
1253 _Bit_pointer __q = this->_M_allocate(__len);
1255 iterator __i = _M_copy_aligned(__begin, __position, __start);
1256 __i = std::copy(__first, __last, __i);
1257 iterator __finish = std::copy(__position, __end, __i);
1258 this->_M_deallocate();
1259 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
1260 this->_M_impl._M_start = __start;
1261 this->_M_impl._M_finish = __finish;
1266 template<
typename _Alloc>
1267 _GLIBCXX20_CONSTEXPR
1272 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
1274 std::copy_backward(__position, this->_M_impl._M_finish,
1275 this->_M_impl._M_finish + 1);
1277 ++this->_M_impl._M_finish;
1281 const size_type __len =
1282 _M_check_len(size_type(1),
"vector<bool>::_M_insert_aux");
1283 _Bit_pointer __q = this->_M_allocate(__len);
1285 iterator __i = _M_copy_aligned(
begin(), __position, __start);
1287 iterator __finish = std::copy(__position,
end(), __i);
1288 this->_M_deallocate();
1289 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
1290 this->_M_impl._M_start = __start;
1291 this->_M_impl._M_finish = __finish;
1295 template<
typename _Alloc>
1296 _GLIBCXX20_CONSTEXPR
1297 typename vector<bool, _Alloc>::iterator
1301 if (__position + 1 !=
end())
1302 std::copy(__position + 1,
end(), __position);
1303 --this->_M_impl._M_finish;
1307 template<
typename _Alloc>
1308 _GLIBCXX20_CONSTEXPR
1309 typename vector<bool, _Alloc>::iterator
1313 if (__first != __last)
1314 _M_erase_at_end(std::copy(__last,
end(), __first));
1318#if __cplusplus >= 201103L
1319 template<
typename _Alloc>
1320 _GLIBCXX20_CONSTEXPR
1325 if (capacity() -
size() <
int(_S_word_bit))
1333 this->_M_deallocate();
1334 this->_M_impl._M_reset();
1343_GLIBCXX_END_NAMESPACE_CONTAINER
1344_GLIBCXX_END_NAMESPACE_VERSION
1347#if __cplusplus >= 201103L
1349namespace std _GLIBCXX_VISIBILITY(default)
1351_GLIBCXX_BEGIN_NAMESPACE_VERSION
1353 template<
typename _Alloc>
1356 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b)
const noexcept
1359 const size_t __words = __b.size() / _S_word_bit;
1362 const size_t __clength = __words *
sizeof(_Bit_type);
1363 __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
1366 const size_t __extrabits = __b.size() % _S_word_bit;
1369 _Bit_type __hiword = *__b._M_impl._M_finish._M_p;
1370 __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits);
1372 const size_t __clength
1373 = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__;
1375 __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
1377 __hash = std::_Hash_impl::hash(&__hiword, __clength);
1383_GLIBCXX_END_NAMESPACE_VERSION
1388#undef _GLIBCXX_ASAN_ANNOTATE_REINIT
1389#undef _GLIBCXX_ASAN_ANNOTATE_GROW
1390#undef _GLIBCXX_ASAN_ANNOTATE_GREW
1391#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 _BI2 move_backward(_BI1 __first, _BI1 __last, _BI2 __result)
Moves the range [first,last) into result.
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.
The ranges::subrange class template.
Forward iterators support a superset of input iterator operations.
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