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);
471 _Guard_alloc __guard(__new_start, __len, *
this);
480#if __cplusplus >= 201103L
481 _Alloc_traits::construct(this->_M_impl,
482 std::__to_address(__new_start + __elems_before),
485 _Alloc_traits::construct(this->_M_impl,
486 __new_start + __elems_before,
490#if __cplusplus >= 201103L
491 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
494 __new_finish = _S_relocate(__old_start, __position.base(),
495 __new_start, _M_get_Tp_allocator());
497 __new_finish = _S_relocate(__position.base(), __old_finish,
498 __new_finish, _M_get_Tp_allocator());
506 pointer _M_first, _M_last;
507 _Tp_alloc_type& _M_alloc;
510 _Guard_elts(pointer __elt, _Tp_alloc_type& __a)
511 : _M_first(__elt), _M_last(__elt + 1), _M_alloc(__a)
519 _Guard_elts(
const _Guard_elts&);
523 _Guard_elts __guard_elts(__new_start + __elems_before, _M_impl);
525 __new_finish = std::__uninitialized_move_if_noexcept_a(
526 __old_start, __position.base(),
527 __new_start, _M_get_Tp_allocator());
531 __guard_elts._M_first = __new_start;
533 __new_finish = std::__uninitialized_move_if_noexcept_a(
534 __position.base(), __old_finish,
535 __new_finish, _M_get_Tp_allocator());
538 __guard_elts._M_first = __old_start;
539 __guard_elts._M_last = __old_finish;
541 __guard._M_storage = __old_start;
542 __guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
547 this->_M_impl._M_start = __new_start;
548 this->_M_impl._M_finish = __new_finish;
549 this->_M_impl._M_end_of_storage = __new_start + __len;
552#if __cplusplus >= 201103L
553 template<
typename _Tp,
typename _Alloc>
554 template<
typename... _Args>
560 template<
typename _Tp,
typename _Alloc>
566 const size_type __len = _M_check_len(1u,
"vector::_M_realloc_append");
568 __builtin_unreachable ();
569 pointer __old_start = this->_M_impl._M_start;
570 pointer __old_finish = this->_M_impl._M_finish;
572 pointer __new_start(this->_M_allocate(__len));
573 pointer __new_finish(__new_start);
576 _Guard_alloc __guard(__new_start, __len, *
this);
585#if __cplusplus >= 201103L
586 _Alloc_traits::construct(this->_M_impl,
587 std::__to_address(__new_start + __elems),
590 _Alloc_traits::construct(this->_M_impl,
591 __new_start + __elems,
595#if __cplusplus >= 201103L
596 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
599 __new_finish = _S_relocate(__old_start, __old_finish,
600 __new_start, _M_get_Tp_allocator());
609 pointer _M_first, _M_last;
610 _Tp_alloc_type& _M_alloc;
613 _Guard_elts(pointer __elt, _Tp_alloc_type& __a)
614 : _M_first(__elt), _M_last(__elt + 1), _M_alloc(__a)
622 _Guard_elts(
const _Guard_elts&);
626 _Guard_elts __guard_elts(__new_start + __elems, _M_impl);
628 __new_finish = std::__uninitialized_move_if_noexcept_a(
629 __old_start, __old_finish,
630 __new_start, _M_get_Tp_allocator());
635 __guard_elts._M_first = __old_start;
636 __guard_elts._M_last = __old_finish;
638 __guard._M_storage = __old_start;
639 __guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
644 this->_M_impl._M_start = __new_start;
645 this->_M_impl._M_finish = __new_finish;
646 this->_M_impl._M_end_of_storage = __new_start + __len;
649 template<
typename _Tp,
typename _Alloc>
657 if (
size_type(this->_M_impl._M_end_of_storage
658 - this->_M_impl._M_finish) >= __n)
660#if __cplusplus < 201103L
663 _Temporary_value __tmp(
this, __x);
667 pointer __old_finish(this->_M_impl._M_finish);
668 if (__elems_after > __n)
670 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
671 std::__uninitialized_move_a(__old_finish - __n,
674 _M_get_Tp_allocator());
675 this->_M_impl._M_finish += __n;
676 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
677 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
678 __old_finish - __n, __old_finish);
679 std::fill(__position.base(), __position.base() + __n,
684 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
685 this->_M_impl._M_finish =
686 std::__uninitialized_fill_n_a(__old_finish,
689 _M_get_Tp_allocator());
690 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
691 std::__uninitialized_move_a(__position.base(), __old_finish,
692 this->_M_impl._M_finish,
693 _M_get_Tp_allocator());
694 this->_M_impl._M_finish += __elems_after;
695 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
696 std::fill(__position.base(), __old_finish, __x_copy);
703 pointer __old_start = this->_M_impl._M_start;
704 pointer __old_finish = this->_M_impl._M_finish;
705 const pointer __pos = __position.base();
708 _M_check_len(__n,
"vector::_M_fill_insert");
709 const size_type __elems_before = __pos - __old_start;
710 pointer __new_start(this->_M_allocate(__len));
711 pointer __new_finish(__new_start);
715 std::__uninitialized_fill_n_a(__new_start + __elems_before,
717 _M_get_Tp_allocator());
718 __new_finish = pointer();
721 = std::__uninitialized_move_if_noexcept_a
722 (__old_start, __pos, __new_start, _M_get_Tp_allocator());
727 = std::__uninitialized_move_if_noexcept_a
728 (__pos, __old_finish, __new_finish, _M_get_Tp_allocator());
734 __new_start + __elems_before + __n,
735 _M_get_Tp_allocator());
738 _M_get_Tp_allocator());
739 _M_deallocate(__new_start, __len);
740 __throw_exception_again;
742 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
743 _GLIBCXX_ASAN_ANNOTATE_REINIT;
744 _M_deallocate(__old_start,
745 this->_M_impl._M_end_of_storage - __old_start);
746 this->_M_impl._M_start = __new_start;
747 this->_M_impl._M_finish = __new_finish;
748 this->_M_impl._M_end_of_storage = __new_start + __len;
753#if __cplusplus >= 201103L
754 template<
typename _Tp,
typename _Alloc>
764 - this->_M_impl._M_finish);
766 if (__size > max_size() || __navail > max_size() - __size)
767 __builtin_unreachable();
771 if (!this->_M_impl._M_finish)
772 __builtin_unreachable();
774 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
775 this->_M_impl._M_finish =
776 std::__uninitialized_default_n_a(this->_M_impl._M_finish,
777 __n, _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;
788 _M_check_len(__n,
"vector::_M_default_append");
789 pointer __new_start(this->_M_allocate(__len));
792 _Guard_alloc __guard(__new_start, __len, *
this);
794 std::__uninitialized_default_n_a(__new_start + __size, __n,
795 _M_get_Tp_allocator());
797 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
799 _S_relocate(__old_start, __old_finish,
800 __new_start, _M_get_Tp_allocator());
807 pointer _M_first, _M_last;
808 _Tp_alloc_type& _M_alloc;
811 _Guard_elts(pointer __first, size_type __n,
813 : _M_first(__first), _M_last(__first + __n), _M_alloc(__a)
821 _Guard_elts(
const _Guard_elts&);
823 _Guard_elts __guard_elts(__new_start + __size, __n, _M_impl);
825 std::__uninitialized_move_if_noexcept_a(
826 __old_start, __old_finish, __new_start,
827 _M_get_Tp_allocator());
829 __guard_elts._M_first = __old_start;
830 __guard_elts._M_last = __old_finish;
832 _GLIBCXX_ASAN_ANNOTATE_REINIT;
833 __guard._M_storage = __old_start;
834 __guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
839 this->_M_impl._M_start = __new_start;
840 this->_M_impl._M_finish = __new_start + __size + __n;
841 this->_M_impl._M_end_of_storage = __new_start + __len;
846 template<
typename _Tp,
typename _Alloc>
852 if (capacity() ==
size())
854 _GLIBCXX_ASAN_ANNOTATE_REINIT;
855 return std::__shrink_to_fit_aux<vector>::_S_do_it(*
this);
859 template<
typename _Tp,
typename _Alloc>
860 template<
typename _InputIterator>
865 _InputIterator __last, std::input_iterator_tag)
869 for (; __first != __last; ++__first)
870 insert(
end(), *__first);
872 else if (__first != __last)
874 vector __tmp(__first, __last, _M_get_Tp_allocator());
876 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()),
877 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end()));
881 template<
typename _Tp,
typename _Alloc>
882 template<
typename _ForwardIterator>
887 _ForwardIterator __last, std::forward_iterator_tag)
889 if (__first != __last)
892 if (
size_type(this->_M_impl._M_end_of_storage
893 - this->_M_impl._M_finish) >= __n)
896 pointer __old_finish(this->_M_impl._M_finish);
897 if (__elems_after > __n)
899 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
900 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
901 this->_M_impl._M_finish,
902 this->_M_impl._M_finish,
903 _M_get_Tp_allocator());
904 this->_M_impl._M_finish += __n;
905 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
906 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
907 __old_finish - __n, __old_finish);
908 std::copy(__first, __last, __position);
912 _ForwardIterator __mid = __first;
914 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
915 std::__uninitialized_copy_a(__mid, __last,
916 this->_M_impl._M_finish,
917 _M_get_Tp_allocator());
918 this->_M_impl._M_finish += __n - __elems_after;
919 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
920 std::__uninitialized_move_a(__position.base(),
922 this->_M_impl._M_finish,
923 _M_get_Tp_allocator());
924 this->_M_impl._M_finish += __elems_after;
925 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
926 std::copy(__first, __mid, __position);
934 pointer __old_start = this->_M_impl._M_start;
935 pointer __old_finish = this->_M_impl._M_finish;
938 _M_check_len(__n,
"vector::_M_range_insert");
939#if __cplusplus < 201103L
940 if (__len < (__n + (__old_finish - __old_start)))
941 __builtin_unreachable();
944 pointer __new_start(this->_M_allocate(__len));
945 pointer __new_finish(__new_start);
949 = std::__uninitialized_move_if_noexcept_a
950 (__old_start, __position.base(),
951 __new_start, _M_get_Tp_allocator());
953 = std::__uninitialized_copy_a(__first, __last,
955 _M_get_Tp_allocator());
957 = std::__uninitialized_move_if_noexcept_a
958 (__position.base(), __old_finish,
959 __new_finish, _M_get_Tp_allocator());
964 _M_get_Tp_allocator());
965 _M_deallocate(__new_start, __len);
966 __throw_exception_again;
969 _M_get_Tp_allocator());
970 _GLIBCXX_ASAN_ANNOTATE_REINIT;
971 _M_deallocate(__old_start,
972 this->_M_impl._M_end_of_storage - __old_start);
973 this->_M_impl._M_start = __new_start;
974 this->_M_impl._M_finish = __new_finish;
975 this->_M_impl._M_end_of_storage = __new_start + __len;
980#if __glibcxx_containers_ranges
981 template<
typename _Tp,
typename _Alloc>
982 template<__detail::__container_compatible_range<_Tp> _Rg>
990 const auto __ins_idx =
size();
992 return begin() + __ins_idx;
995 if constexpr (ranges::forward_range<_Rg>)
998 pointer __old_start = this->_M_impl._M_start;
1000 pointer __old_finish = this->_M_impl._M_finish;
1002 const auto __ins_idx = __pos -
cbegin();
1003 pointer __ins = __old_start + __ins_idx;
1005 const auto __n =
size_type(ranges::distance(__rg));
1007 const auto __cap = this->_M_impl._M_end_of_storage - __old_finish;
1012 if (__elems_after > __n)
1014 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
1015 std::__uninitialized_move_a(__old_finish - __n,
1018 _M_get_Tp_allocator());
1019 this->_M_impl._M_finish += __n;
1020 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
1022 ranges::copy(__rg, __ins);
1026 auto __first = ranges::begin(__rg);
1027 const auto __last = ranges::end(__rg);
1028 auto __mid = ranges::next(__first, __elems_after);
1029 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
1031 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
1032 std::__uninitialized_move_a(__ins, __old_finish,
1033 this->_M_impl._M_finish,
1034 _M_get_Tp_allocator());
1035 this->_M_impl._M_finish += __elems_after;
1036 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
1037 ranges::copy(__first, __mid, __ins);
1043 = _M_check_len(__n,
"vector::insert_range");
1045 struct _Guard : _Guard_alloc
1048 pointer _M_finish = _Guard_alloc::_M_storage;
1050 using _Guard_alloc::_Guard_alloc;
1056 this->_M_vect._M_get_Tp_allocator());
1061 pointer __new_start(this->_M_allocate(__len));
1062 _Guard __guard(__new_start, __len, *
this);
1064 auto& __alloc = _M_get_Tp_allocator();
1072 = std::__uninitialized_move_if_noexcept_a(
1073 __old_start, __ins, __new_start, __alloc);
1076 _Base::_M_append_range_to(__rg, __guard._M_finish);
1080 = std::__uninitialized_move_if_noexcept_a(
1081 __ins, __old_finish, __guard._M_finish, __alloc);
1083 _GLIBCXX_ASAN_ANNOTATE_REINIT;
1087 this->_M_impl._M_start = __guard._M_storage;
1088 this->_M_impl._M_finish = __guard._M_finish;
1089 this->_M_impl._M_end_of_storage = __new_start + __len;
1090 __guard._M_storage = __old_start;
1091 __guard._M_finish = __old_finish;
1092 __guard._M_len = (__old_finish - __old_start) + __cap;
1097 return begin() + __ins_idx;
1101 _M_get_Tp_allocator()));
1106 template<
typename _Alloc>
1107 _GLIBCXX20_CONSTEXPR
1114 __builtin_unreachable();
1115 _Bit_pointer __q = this->_M_allocate(__n);
1117 iterator __finish(_M_copy_aligned(__begin, __end, __start));
1118 this->_M_deallocate();
1119 this->_M_impl._M_start = __start;
1120 this->_M_impl._M_finish = __finish;
1121 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
1124 template<
typename _Alloc>
1125 _GLIBCXX20_CONSTEXPR
1132 if (capacity() -
size() >= __n)
1134 std::copy_backward(__position,
end(),
1142 _M_check_len(__n,
"vector<bool>::_M_fill_insert");
1144 _Bit_pointer __q = this->_M_allocate(__len);
1146 iterator __i = _M_copy_aligned(__begin, __position, __start);
1148 iterator __finish = std::copy(__position, __end,
1150 this->_M_deallocate();
1151 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
1152 this->_M_impl._M_start = __start;
1153 this->_M_impl._M_finish = __finish;
1157 template<
typename _Alloc>
1158 template<
typename _ForwardIterator>
1159 _GLIBCXX20_CONSTEXPR
1163 _ForwardIterator __last, std::forward_iterator_tag)
1165 if (__first != __last)
1168 if (capacity() -
size() >= __n)
1170 std::copy_backward(__position,
end(),
1171 this->_M_impl._M_finish
1173 std::copy(__first, __last, __position);
1179 _M_check_len(__n,
"vector<bool>::_M_insert_range");
1181 _Bit_pointer __q = this->_M_allocate(__len);
1183 iterator __i = _M_copy_aligned(__begin, __position, __start);
1184 __i = std::copy(__first, __last, __i);
1185 iterator __finish = std::copy(__position, __end, __i);
1186 this->_M_deallocate();
1187 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
1188 this->_M_impl._M_start = __start;
1189 this->_M_impl._M_finish = __finish;
1194 template<
typename _Alloc>
1195 _GLIBCXX20_CONSTEXPR
1200 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
1202 std::copy_backward(__position, this->_M_impl._M_finish,
1203 this->_M_impl._M_finish + 1);
1205 ++this->_M_impl._M_finish;
1210 _M_check_len(
size_type(1),
"vector<bool>::_M_insert_aux");
1211 _Bit_pointer __q = this->_M_allocate(__len);
1213 iterator __i = _M_copy_aligned(
begin(), __position, __start);
1215 iterator __finish = std::copy(__position,
end(), __i);
1216 this->_M_deallocate();
1217 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
1218 this->_M_impl._M_start = __start;
1219 this->_M_impl._M_finish = __finish;
1223 template<
typename _Alloc>
1224 _GLIBCXX20_CONSTEXPR
1225 typename vector<bool, _Alloc>::iterator
1229 if (__position + 1 !=
end())
1230 std::copy(__position + 1,
end(), __position);
1231 --this->_M_impl._M_finish;
1235 template<
typename _Alloc>
1236 _GLIBCXX20_CONSTEXPR
1237 typename vector<bool, _Alloc>::iterator
1241 if (__first != __last)
1242 _M_erase_at_end(std::copy(__last,
end(), __first));
1246#if __cplusplus >= 201103L
1247 template<
typename _Alloc>
1248 _GLIBCXX20_CONSTEXPR
1257 if (size_type __n =
size())
1261 this->_M_deallocate();
1262 this->_M_impl._M_reset();
1271_GLIBCXX_END_NAMESPACE_CONTAINER
1272_GLIBCXX_END_NAMESPACE_VERSION
1275#if __cplusplus >= 201103L
1277namespace std _GLIBCXX_VISIBILITY(default)
1279_GLIBCXX_BEGIN_NAMESPACE_VERSION
1281 template<
typename _Alloc>
1283 hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
1284 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b)
const noexcept
1287 const size_t __words = __b.size() / _S_word_bit;
1290 const size_t __clength = __words *
sizeof(_Bit_type);
1291 __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
1294 const size_t __extrabits = __b.size() % _S_word_bit;
1297 _Bit_type __hiword = *__b._M_impl._M_finish._M_p;
1298 __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits);
1300 const size_t __clength
1301 = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__;
1303 __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
1305 __hash = std::_Hash_impl::hash(&__hiword, __clength);
1311_GLIBCXX_END_NAMESPACE_VERSION
1316#undef _GLIBCXX_ASAN_ANNOTATE_REINIT
1317#undef _GLIBCXX_ASAN_ANNOTATE_GROW
1318#undef _GLIBCXX_ASAN_ANNOTATE_GREW
1319#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)
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 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