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_at_least(__n);
83 std::__relocate_a(this->_M_impl._M_start, this->_M_impl._M_finish,
84 __tmp.__ptr, _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());
96 __tmp.__ptr, __tmp.__ptr + __old_size, __tmp.__count);
99#pragma GCC diagnostic pop
101#if __cplusplus >= 201103L
102 template<
typename _Tp,
typename _Alloc>
103 template<
typename... _Args>
104# if __cplusplus > 201402L
106 typename vector<_Tp, _Alloc>::reference
113 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
115 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
116 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
118 ++this->_M_impl._M_finish;
119 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
123# if __cplusplus > 201402L
129 template<
typename _Tp,
typename _Alloc>
131 typename vector<_Tp, _Alloc>::iterator
133#if __cplusplus >= 201103L
134 insert(const_iterator __position,
const value_type& __x)
136 insert(iterator __position,
const value_type& __x)
139 const size_type __n = __position -
begin();
140 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
142 __glibcxx_assert(__position != const_iterator());
143 if (!(__position != const_iterator()))
144 __builtin_unreachable();
146 if (__position ==
end())
148 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
149 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
151 ++this->_M_impl._M_finish;
152 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
156#if __cplusplus >= 201103L
157 const auto __pos =
begin() + (__position -
cbegin());
160 _Temporary_value __x_copy(
this, __x);
161 _M_insert_aux(__pos,
std::move(__x_copy._M_val()));
163 _M_insert_aux(__position, __x);
168#if __cplusplus >= 201103L
169 _M_realloc_insert(
begin() + (__position -
cbegin()), __x);
171 _M_realloc_insert(__position, __x);
174 return iterator(this->_M_impl._M_start + __n);
177 template<
typename _Tp,
typename _Alloc>
179 typename vector<_Tp, _Alloc>::iterator
183 if (__position + 1 !=
end())
184 _GLIBCXX_MOVE3(__position + 1,
end(), __position);
185 --this->_M_impl._M_finish;
186 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
187 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
191 template<
typename _Tp,
typename _Alloc>
193 typename vector<_Tp, _Alloc>::iterator
194 vector<_Tp, _Alloc>::
195 _M_erase(iterator __first, iterator __last)
197 if (__first != __last)
200 _GLIBCXX_MOVE3(__last,
end(), __first);
201 _M_erase_at_end(__first.base() + (
end() - __last));
206 template<
typename _Tp,
typename _Alloc>
214 _GLIBCXX_ASAN_ANNOTATE_REINIT;
215#if __cplusplus >= 201103L
216 if (_Alloc_traits::_S_propagate_on_copy_assign())
218 if (!_Alloc_traits::_S_always_equal()
219 && _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
223 _M_deallocate(this->_M_impl._M_start,
224 this->_M_impl._M_end_of_storage
225 - this->_M_impl._M_start);
226 this->_M_impl._M_start =
nullptr;
227 this->_M_impl._M_finish =
nullptr;
228 this->_M_impl._M_end_of_storage =
nullptr;
230 std::__alloc_on_copy(_M_get_Tp_allocator(),
231 __x._M_get_Tp_allocator());
234 const size_type __xlen = __x.
size();
236 _M_replace_with(__xlen, __x.
begin(), __x.
end());
237 else if (
size() >= __xlen)
239 end(), _M_get_Tp_allocator());
242 std::copy(__x._M_impl._M_start, __x._M_impl._M_start +
size(),
243 this->_M_impl._M_start);
244 std::__uninitialized_copy_a(__x._M_impl._M_start +
size(),
245 __x._M_impl._M_finish,
246 this->_M_impl._M_finish,
247 _M_get_Tp_allocator());
249 this->_M_impl._M_finish = this->_M_impl._M_start + __xlen;
254 template<
typename _Tp,
typename _Alloc>
261 if (__n > capacity())
264 __builtin_unreachable();
265 vector __tmp(__n, __val, _M_get_Tp_allocator());
266 __tmp._M_impl._M_swap_data(this->_M_impl);
271 const size_type __add = __n - __sz;
272 _GLIBCXX_ASAN_ANNOTATE_GROW(__add);
273 this->_M_impl._M_finish =
274 std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
275 __add, __val, _M_get_Tp_allocator());
276 _GLIBCXX_ASAN_ANNOTATE_GREW(__add);
279 _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val));
282 template<
typename _Tp,
typename _Alloc>
283 template<
typename _InputIterator>
288 std::input_iterator_tag)
290 pointer __cur(this->_M_impl._M_start);
291 for (; __first != __last && __cur != this->_M_impl._M_finish;
292 ++__cur, (void)++__first)
294 if (__first == __last)
295 _M_erase_at_end(__cur);
297 _M_range_insert(
end(), __first, __last,
298 std::__iterator_category(__first));
301 template<
typename _Tp,
typename _Alloc>
302 template<
typename _ForwardIterator>
306 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
307 std::forward_iterator_tag)
312 if (__len > capacity())
315 __builtin_unreachable();
317 _S_check_init_len(__len, _M_get_Tp_allocator());
318 _M_replace_with(__len, __first, __last);
320 else if (__sz >= __len)
321 _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start));
324 _ForwardIterator __mid = __first;
326 std::copy(__first, __mid, this->_M_impl._M_start);
327 const size_type __attribute__((__unused__)) __n = __len - __sz;
328 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
329 this->_M_impl._M_finish =
330 std::__uninitialized_copy_a(__mid, __last,
331 this->_M_impl._M_finish,
332 _M_get_Tp_allocator());
333 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
337#if __cplusplus >= 201103L
338 template<
typename _Tp,
typename _Alloc>
344 const auto __n = __position -
cbegin();
345 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
346 if (__position ==
cend())
348 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
349 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
351 ++this->_M_impl._M_finish;
352 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
359 return iterator(this->_M_impl._M_start + __n);
362 template<
typename _Tp,
typename _Alloc>
363 template<
typename... _Args>
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);
391 return iterator(this->_M_impl._M_start + __n);
394 template<
typename _Tp,
typename _Alloc>
395 template<
typename _Arg>
401 template<
typename _Tp,
typename _Alloc>
407 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
408 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
409 _GLIBCXX_MOVE(*(this->_M_impl._M_finish - 1)));
410 ++this->_M_impl._M_finish;
411 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
412#if __cplusplus < 201103L
415 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
416 this->_M_impl._M_finish - 2,
417 this->_M_impl._M_finish - 1);
418#if __cplusplus < 201103L
419 *__position = __x_copy;
425#pragma GCC diagnostic push
426#pragma GCC diagnostic ignored "-Wc++17-extensions"
427#if __cplusplus >= 201103L
428 template<
typename _Tp,
typename _Alloc>
429 template<
typename... _Args>
435 template<
typename _Tp,
typename _Alloc>
441 const size_type __len1 = _M_check_len(1u,
"vector::_M_realloc_insert");
443 __builtin_unreachable();
444 pointer __old_start = this->_M_impl._M_start;
445 pointer __old_finish = this->_M_impl._M_finish;
447 _Alloc_result __r = this->_M_allocate_at_least(__len1);
449 pointer __new_start(__r.__ptr);
450 pointer __new_finish(__new_start);
453 _Guard_alloc __guard(__new_start, __len, *
this);
462#if __cplusplus >= 201103L
463 _Alloc_traits::construct(this->_M_impl,
464 std::__to_address(__new_start + __elems_before),
467 _Alloc_traits::construct(this->_M_impl,
468 __new_start + __elems_before,
472#if __cplusplus >= 201103L
473 if constexpr (_S_use_relocate())
476 __new_finish = std::__relocate_a(__old_start, __position.base(),
478 _M_get_Tp_allocator());
480 __new_finish = std::__relocate_a(__position.base(), __old_finish,
482 _M_get_Tp_allocator());
490 pointer _M_first, _M_last;
491 _Tp_alloc_type& _M_alloc;
494 _Guard_elts(pointer __elt, _Tp_alloc_type& __a)
495 : _M_first(__elt), _M_last(__elt + 1), _M_alloc(__a)
503 _Guard_elts(
const _Guard_elts&);
507 _Guard_elts __guard_elts(__new_start + __elems_before, _M_impl);
509 __new_finish = std::__uninitialized_move_if_noexcept_a(
510 __old_start, __position.base(),
511 __new_start, _M_get_Tp_allocator());
515 __guard_elts._M_first = __new_start;
517 __new_finish = std::__uninitialized_move_if_noexcept_a(
518 __position.base(), __old_finish,
519 __new_finish, _M_get_Tp_allocator());
522 __guard_elts._M_first = __old_start;
523 __guard_elts._M_last = __old_finish;
525 __guard._M_storage = __old_start;
526 __guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
531 this->_M_impl._M_start = __new_start;
532 this->_M_impl._M_finish = __new_finish;
533 this->_M_impl._M_end_of_storage = __new_start + __len;
536#if __cplusplus >= 201103L
537 template<
typename _Tp,
typename _Alloc>
538 template<
typename... _Args>
544 template<
typename _Tp,
typename _Alloc>
550 const size_type __len = _M_check_len(1u,
"vector::_M_realloc_append");
552 __builtin_unreachable();
553 const pointer __old_start = this->_M_impl._M_start;
554 const pointer __old_finish = this->_M_impl._M_finish;
556 const _Alloc_result __r = this->_M_allocate_at_least(__len);
558 const pointer __new_start(__r.__ptr);
559 pointer __new_finish(__new_start);
562 _Guard_alloc __guard(__new_start, __rlen, *
this);
571#if __cplusplus >= 201103L
572 _Alloc_traits::construct(this->_M_impl,
573 std::__to_address(__new_start + __elems),
576 _Alloc_traits::construct(this->_M_impl,
577 __new_start + __elems,
581#if __cplusplus >= 201103L
582 if constexpr (_S_use_relocate())
585 __new_finish = std::__relocate_a(__old_start, __old_finish,
587 _M_get_Tp_allocator());
596 pointer _M_first, _M_last;
597 _Tp_alloc_type& _M_alloc;
600 _Guard_elts(pointer __elt, _Tp_alloc_type& __a)
601 : _M_first(__elt), _M_last(__elt + 1), _M_alloc(__a)
609 _Guard_elts(
const _Guard_elts&);
613 _Guard_elts __guard_elts(__new_start + __elems, _M_impl);
615 __new_finish = std::__uninitialized_move_if_noexcept_a(
616 __old_start, __old_finish,
617 __new_start, _M_get_Tp_allocator());
622 __guard_elts._M_first = __old_start;
623 __guard_elts._M_last = __old_finish;
625 __guard._M_storage = __old_start;
626 __guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
631 this->_M_impl._M_start = __new_start;
632 this->_M_impl._M_finish = __new_finish;
633 this->_M_impl._M_end_of_storage = __new_start + __rlen;
635#pragma GCC diagnostic pop
637 template<
typename _Tp,
typename _Alloc>
645 if (__position.base() == this->_M_impl._M_finish)
646 _M_fill_append(__n, __x);
647 else if (
size_type(this->_M_impl._M_end_of_storage
648 - this->_M_impl._M_finish) >= __n)
650#if __cplusplus < 201103L
653 _Temporary_value __tmp(
this, __x);
657 pointer __old_finish(this->_M_impl._M_finish);
658 if (__elems_after > __n)
660 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
661 std::__uninitialized_move_a(__old_finish - __n,
664 _M_get_Tp_allocator());
665 this->_M_impl._M_finish += __n;
666 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
667 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
668 __old_finish - __n, __old_finish);
669 std::fill(__position.base(), __position.base() + __n,
674 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
675 this->_M_impl._M_finish =
676 std::__uninitialized_fill_n_a(__old_finish,
679 _M_get_Tp_allocator());
680 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
681 std::__uninitialized_move_a(__position.base(), __old_finish,
682 this->_M_impl._M_finish,
683 _M_get_Tp_allocator());
684 this->_M_impl._M_finish += __elems_after;
685 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
686 std::fill(__position.base(), __old_finish, __x_copy);
693 pointer __old_start = this->_M_impl._M_start;
694 pointer __old_finish = this->_M_impl._M_finish;
695 const pointer __pos = __position.base();
698 _M_check_len(__n,
"vector::_M_fill_insert");
699 const size_type __elems_before = __pos - __old_start;
700 _Alloc_result __r = this->_M_allocate_at_least(__len1);
702 pointer __new_start(__r.__ptr);
703 pointer __new_finish(__new_start);
707 std::__uninitialized_fill_n_a(__new_start + __elems_before,
709 _M_get_Tp_allocator());
710 __new_finish = pointer();
711 __new_finish = std::__uninitialized_move_if_noexcept_a(
712 __old_start, __pos, __new_start, _M_get_Tp_allocator());
714 __new_finish = std::__uninitialized_move_if_noexcept_a(
715 __pos, __old_finish, __new_finish, _M_get_Tp_allocator());
719 if (__new_finish == pointer())
721 __new_start + __elems_before + __n,
722 _M_get_Tp_allocator());
725 _M_get_Tp_allocator());
726 _M_deallocate(__new_start, __len);
727 __throw_exception_again;
729 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
730 _M_replace_storage(__new_start, __new_finish, __len);
735 template<
typename _Tp,
typename _Alloc>
741 if (
size_type(this->_M_impl._M_end_of_storage
742 - this->_M_impl._M_finish) >= __n)
744 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
745 this->_M_impl._M_finish =
746 std::__uninitialized_fill_n_a(this->_M_impl._M_finish, __n, __x,
747 _M_get_Tp_allocator());
748 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
754 pointer __old_start = this->_M_impl._M_start;
755 pointer __old_finish = this->_M_impl._M_finish;
756 const size_type __old_size = __old_finish - __old_start;
758 size_type __len = _M_check_len(__n,
"vector::_M_fill_append");
759 _Alloc_result __r = this->_M_allocate_at_least(__len);
761 pointer __new_start(__r.__ptr);
762 pointer __new_finish(__new_start + __old_size);
766 __new_finish = std::__uninitialized_fill_n_a(
767 __new_finish, __n, __x,
768 _M_get_Tp_allocator());
769 std::__uninitialized_move_if_noexcept_a(
770 __old_start, __old_finish, __new_start,
771 _M_get_Tp_allocator());
776 _M_get_Tp_allocator());
777 _M_deallocate(__new_start, __len);
778 __throw_exception_again;
780 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
781 _M_replace_storage(__new_start, __new_finish, __len);
785#if __cplusplus >= 201103L
786#pragma GCC diagnostic push
787#pragma GCC diagnostic ignored "-Wc++17-extensions"
788 template<
typename _Tp,
typename _Alloc>
798 - this->_M_impl._M_finish);
800 if (__size > max_size() || __navail > max_size() - __size)
801 __builtin_unreachable();
805 if (!this->_M_impl._M_finish)
806 __builtin_unreachable();
808 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
809 this->_M_impl._M_finish =
810 std::__uninitialized_default_n_a(this->_M_impl._M_finish,
811 __n, _M_get_Tp_allocator());
812 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
818 pointer __old_start = this->_M_impl._M_start;
819 pointer __old_finish = this->_M_impl._M_finish;
822 _M_check_len(__n,
"vector::_M_default_append");
823 _Alloc_result __r = this->_M_allocate_at_least(__len1);
825 pointer __new_start(__r.__ptr);
828 _Guard_alloc __guard(__new_start, __len, *
this);
830 std::__uninitialized_default_n_a(__new_start + __size, __n,
831 _M_get_Tp_allocator());
833 if constexpr (_S_use_relocate())
835 std::__relocate_a(__old_start, __old_finish,
836 __new_start, _M_get_Tp_allocator());
843 pointer _M_first, _M_last;
844 _Tp_alloc_type& _M_alloc;
847 _Guard_elts(pointer __first, size_type __n,
849 : _M_first(__first), _M_last(__first + __n), _M_alloc(__a)
857 _Guard_elts(
const _Guard_elts&);
859 _Guard_elts __guard_elts(__new_start + __size, __n, _M_impl);
861 std::__uninitialized_move_if_noexcept_a(
862 __old_start, __old_finish, __new_start,
863 _M_get_Tp_allocator());
865 __guard_elts._M_first = __old_start;
866 __guard_elts._M_last = __old_finish;
868 _GLIBCXX_ASAN_ANNOTATE_REINIT;
869 __guard._M_storage = __old_start;
870 __guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
875 this->_M_impl._M_start = __new_start;
876 this->_M_impl._M_finish = __new_start + __size + __n;
877 this->_M_impl._M_end_of_storage = __new_start + __len;
881#pragma GCC diagnostic pop
883 template<
typename _Tp,
typename _Alloc>
889 if (capacity() ==
size())
891 _GLIBCXX_ASAN_ANNOTATE_REINIT;
892 return std::__shrink_to_fit_aux<vector>::_S_do_it(*
this);
896 template<
typename _Tp,
typename _Alloc>
897 template<
typename _InputIterator>
902 _InputIterator __last, std::input_iterator_tag)
906 for (; __first != __last; ++__first)
907 insert(
end(), *__first);
909 else if (__first != __last)
911 vector __tmp(__first, __last, _M_get_Tp_allocator());
913 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()),
914 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end()));
918 template<
typename _Tp,
typename _Alloc>
919 template<
typename _ForwardIterator>
924 _ForwardIterator __last, std::forward_iterator_tag)
926 if (__first != __last)
929 if (
size_type(this->_M_impl._M_end_of_storage
930 - this->_M_impl._M_finish) >= __n)
933 pointer __old_finish(this->_M_impl._M_finish);
934 if (__elems_after > __n)
936 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
937 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
938 this->_M_impl._M_finish,
939 this->_M_impl._M_finish,
940 _M_get_Tp_allocator());
941 this->_M_impl._M_finish += __n;
942 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
943 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
944 __old_finish - __n, __old_finish);
945 std::copy(__first, __last, __position);
949 _ForwardIterator __mid = __first;
951 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
952 std::__uninitialized_copy_a(__mid, __last,
953 this->_M_impl._M_finish,
954 _M_get_Tp_allocator());
955 this->_M_impl._M_finish += __n - __elems_after;
956 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
957 std::__uninitialized_move_a(__position.base(),
959 this->_M_impl._M_finish,
960 _M_get_Tp_allocator());
961 this->_M_impl._M_finish += __elems_after;
962 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
963 std::copy(__first, __mid, __position);
971 pointer __old_start = this->_M_impl._M_start;
972 pointer __old_finish = this->_M_impl._M_finish;
975 _M_check_len(__n,
"vector::_M_range_insert");
976#if __cplusplus < 201103L
977 if (__ask < (__n + (__old_finish - __old_start)))
978 __builtin_unreachable();
981 _Alloc_result __r = this->_M_allocate_at_least(__ask);
983 pointer __new_start(__r.__ptr);
984 pointer __new_finish(__new_start);
988 = std::__uninitialized_move_if_noexcept_a
989 (__old_start, __position.base(),
990 __new_start, _M_get_Tp_allocator());
992 = std::__uninitialized_copy_a(__first, __last,
994 _M_get_Tp_allocator());
996 = std::__uninitialized_move_if_noexcept_a
997 (__position.base(), __old_finish,
998 __new_finish, _M_get_Tp_allocator());
1003 _M_get_Tp_allocator());
1004 _M_deallocate(__new_start, __got);
1005 __throw_exception_again;
1008 _M_get_Tp_allocator());
1009 _M_replace_storage(__new_start, __new_finish, __got);
1014#if __glibcxx_containers_ranges
1015 template<
typename _Tp,
typename _Alloc>
1016 template<__detail::__container_compatible_range<_Tp> _Rg>
1022 if (__pos ==
cend())
1024 const auto __ins_idx =
size();
1026 return begin() + __ins_idx;
1031 const auto __ins_idx = __pos -
cbegin();
1033 const auto __n =
size_type(ranges::distance(__rg));
1035 return begin() + __ins_idx;
1038 pointer __old_start = this->_M_impl._M_start;
1040 pointer __old_finish = this->_M_impl._M_finish;
1042 pointer __ins = __old_start + __ins_idx;
1044 const auto __cap = this->_M_impl._M_end_of_storage - __old_finish;
1049 if (__elems_after > __n)
1051 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
1052 std::__uninitialized_move_a(__old_finish - __n,
1055 _M_get_Tp_allocator());
1056 this->_M_impl._M_finish += __n;
1057 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
1059 ranges::copy(__rg, __ins);
1063 auto __first = ranges::begin(__rg);
1064 const auto __last = ranges::end(__rg);
1065 auto __mid = ranges::next(__first, __elems_after);
1066 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
1068 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
1069 std::__uninitialized_move_a(__ins, __old_finish,
1070 this->_M_impl._M_finish,
1071 _M_get_Tp_allocator());
1072 this->_M_impl._M_finish += __elems_after;
1073 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
1074 ranges::copy(__first, __mid, __ins);
1080 = _M_check_len(__n,
"vector::insert_range");
1082 struct _Guard : _Guard_alloc
1085 pointer _M_finish = _Guard_alloc::_M_storage;
1087 using _Guard_alloc::_Guard_alloc;
1093 this->_M_vect._M_get_Tp_allocator());
1098 _Alloc_result __r = this->_M_allocate_at_least(__ask);
1100 pointer __new_start(__r.__ptr);
1101 _Guard __guard(__new_start, __got, *
this);
1103 auto& __alloc = _M_get_Tp_allocator();
1111 = std::__uninitialized_move_if_noexcept_a(
1112 __old_start, __ins, __new_start, __alloc);
1115 _Base::_M_append_range_to(__rg, __guard._M_finish);
1119 = std::__uninitialized_move_if_noexcept_a(
1120 __ins, __old_finish, __guard._M_finish, __alloc);
1122 _GLIBCXX_ASAN_ANNOTATE_REINIT;
1126 this->_M_impl._M_start = __guard._M_storage;
1127 this->_M_impl._M_finish = __guard._M_finish;
1128 this->_M_impl._M_end_of_storage = __new_start + __got;
1129 __guard._M_storage = __old_start;
1130 __guard._M_finish = __old_finish;
1131 __guard._M_len = (__old_finish - __old_start) + __cap;
1136 return begin() + __ins_idx;
1140 _M_get_Tp_allocator()));
1145 template<
typename _Alloc>
1146 _GLIBCXX20_CONSTEXPR
1153 __builtin_unreachable();
1154 _Bit_pointer __q = this->_M_allocate(__n);
1156 iterator __finish(_M_copy_aligned(__begin, __end, __start));
1157 this->_M_deallocate();
1158 this->_M_impl._M_start = __start;
1159 this->_M_impl._M_finish = __finish;
1160 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
1163 template<
typename _Alloc>
1164 _GLIBCXX20_CONSTEXPR
1171 if (capacity() -
size() >= __n)
1173 std::copy_backward(__position,
end(),
1181 _M_check_len(__n,
"vector<bool>::_M_fill_insert");
1183 _Bit_pointer __q = this->_M_allocate(__len);
1185 iterator __i = _M_copy_aligned(__begin, __position, __start);
1187 iterator __finish = std::copy(__position, __end,
1189 this->_M_deallocate();
1190 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
1191 this->_M_impl._M_start = __start;
1192 this->_M_impl._M_finish = __finish;
1196 template<
typename _Alloc>
1197 template<
typename _ForwardIterator>
1198 _GLIBCXX20_CONSTEXPR
1202 _ForwardIterator __last, std::forward_iterator_tag)
1204 if (__first != __last)
1207 if (capacity() -
size() >= __n)
1209 std::copy_backward(__position,
end(),
1210 this->_M_impl._M_finish
1212 std::copy(__first, __last, __position);
1218 _M_check_len(__n,
"vector<bool>::_M_insert_range");
1220 _Bit_pointer __q = this->_M_allocate(__len);
1222 iterator __i = _M_copy_aligned(__begin, __position, __start);
1223 __i = std::copy(__first, __last, __i);
1224 iterator __finish = std::copy(__position, __end, __i);
1225 this->_M_deallocate();
1226 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
1227 this->_M_impl._M_start = __start;
1228 this->_M_impl._M_finish = __finish;
1233 template<
typename _Alloc>
1234 _GLIBCXX20_CONSTEXPR
1239 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
1241 std::copy_backward(__position, this->_M_impl._M_finish,
1242 this->_M_impl._M_finish + 1);
1244 ++this->_M_impl._M_finish;
1249 _M_check_len(
size_type(1),
"vector<bool>::_M_insert_aux");
1250 _Bit_pointer __q = this->_M_allocate(__len);
1252 iterator __i = _M_copy_aligned(
begin(), __position, __start);
1254 iterator __finish = std::copy(__position,
end(), __i);
1255 this->_M_deallocate();
1256 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
1257 this->_M_impl._M_start = __start;
1258 this->_M_impl._M_finish = __finish;
1262 template<
typename _Alloc>
1263 _GLIBCXX20_CONSTEXPR
1264 typename vector<bool, _Alloc>::iterator
1268 if (__position + 1 !=
end())
1269 std::copy(__position + 1,
end(), __position);
1270 --this->_M_impl._M_finish;
1274 template<
typename _Alloc>
1275 _GLIBCXX20_CONSTEXPR
1276 typename vector<bool, _Alloc>::iterator
1280 if (__first != __last)
1281 _M_erase_at_end(std::copy(__last,
end(), __first));
1285#if __cplusplus >= 201103L
1286 template<
typename _Alloc>
1287 _GLIBCXX20_CONSTEXPR
1296 if (size_type __n =
size())
1300 this->_M_deallocate();
1301 this->_M_impl._M_reset();
1310_GLIBCXX_END_NAMESPACE_CONTAINER
1311_GLIBCXX_END_NAMESPACE_VERSION
1314#if __cplusplus >= 201103L
1316namespace std _GLIBCXX_VISIBILITY(default)
1318_GLIBCXX_BEGIN_NAMESPACE_VERSION
1320 template<
typename _Alloc>
1322 hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
1323 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b)
const noexcept
1326 const size_t __words = __b.size() / _S_word_bit;
1329 const size_t __clength = __words *
sizeof(_Bit_type);
1330 __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
1333 const size_t __extrabits = __b.size() % _S_word_bit;
1336 _Bit_type __hiword = *__b._M_impl._M_finish._M_p;
1337 __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits);
1339 const size_t __clength
1340 = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__;
1342 __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
1344 __hash = std::_Hash_impl::hash(&__hiword, __clength);
1350_GLIBCXX_END_NAMESPACE_VERSION
1355#undef _GLIBCXX_ASAN_ANNOTATE_REINIT
1356#undef _GLIBCXX_ASAN_ANNOTATE_GROW
1357#undef _GLIBCXX_ASAN_ANNOTATE_GREW
1358#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.
constexpr _BI2 move_backward(_BI1 __first, _BI1 __last, _BI2 __result)
Moves the range [first,last) into result.
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 end(_Container &__cont) noexcept(noexcept(__cont.end())) -> decltype(__cont.end())
Return an iterator pointing to one past the last element of the 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)
constexpr auto begin(_Container &__cont) noexcept(noexcept(__cont.begin())) -> decltype(__cont.begin())
Return an iterator pointing to the first element of the container.
The ranges::subrange class template.
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 _Alloc_result _M_allocate_and_copy(size_type __n, _ForwardIterator __first, _ForwardIterator __last)
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 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
A range for which ranges::begin returns a forward iterator.