59namespace std _GLIBCXX_VISIBILITY(default)
61_GLIBCXX_BEGIN_NAMESPACE_VERSION
62_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
64 template<
typename _Tp,
typename _Alloc>
70 if (__n > this->max_size())
71 __throw_length_error(__N(
"vector::reserve"));
72 if (this->capacity() < __n)
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());
86 __tmp = _M_allocate_and_copy(__n,
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,
118 std::forward<_Args>(__args)...);
119 ++this->_M_impl._M_finish;
120 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
123 _M_realloc_insert(
end(), std::forward<_Args>(__args)...);
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)
142 if (__position ==
end())
144 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
145 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
147 ++this->_M_impl._M_finish;
148 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
152#if __cplusplus >= 201103L
153 const auto __pos =
begin() + (__position -
cbegin());
156 _Temporary_value __x_copy(
this, __x);
157 _M_insert_aux(__pos,
std::move(__x_copy._M_val()));
159 _M_insert_aux(__position, __x);
163#if __cplusplus >= 201103L
164 _M_realloc_insert(
begin() + (__position -
cbegin()), __x);
166 _M_realloc_insert(__position, __x);
169 return iterator(this->_M_impl._M_start + __n);
172 template<
typename _Tp,
typename _Alloc>
174 typename vector<_Tp, _Alloc>::iterator
178 if (__position + 1 !=
end())
179 _GLIBCXX_MOVE3(__position + 1,
end(), __position);
180 --this->_M_impl._M_finish;
181 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
182 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
186 template<
typename _Tp,
typename _Alloc>
188 typename vector<_Tp, _Alloc>::iterator
189 vector<_Tp, _Alloc>::
190 _M_erase(iterator __first, iterator __last)
192 if (__first != __last)
195 _GLIBCXX_MOVE3(__last,
end(), __first);
196 _M_erase_at_end(__first.base() + (
end() - __last));
201 template<
typename _Tp,
typename _Alloc>
209 _GLIBCXX_ASAN_ANNOTATE_REINIT;
210#if __cplusplus >= 201103L
211 if (_Alloc_traits::_S_propagate_on_copy_assign())
213 if (!_Alloc_traits::_S_always_equal()
214 && _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
218 _M_deallocate(this->_M_impl._M_start,
219 this->_M_impl._M_end_of_storage
220 - this->_M_impl._M_start);
221 this->_M_impl._M_start =
nullptr;
222 this->_M_impl._M_finish =
nullptr;
223 this->_M_impl._M_end_of_storage =
nullptr;
225 std::__alloc_on_copy(_M_get_Tp_allocator(),
226 __x._M_get_Tp_allocator());
229 const size_type __xlen = __x.
size();
230 if (__xlen > capacity())
232 pointer __tmp = _M_allocate_and_copy(__xlen, __x.
begin(),
234 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
235 _M_get_Tp_allocator());
236 _M_deallocate(this->_M_impl._M_start,
237 this->_M_impl._M_end_of_storage
238 - this->_M_impl._M_start);
239 this->_M_impl._M_start = __tmp;
240 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen;
242 else if (
size() >= __xlen)
245 end(), _M_get_Tp_allocator());
249 std::copy(__x._M_impl._M_start, __x._M_impl._M_start +
size(),
250 this->_M_impl._M_start);
251 std::__uninitialized_copy_a(__x._M_impl._M_start +
size(),
252 __x._M_impl._M_finish,
253 this->_M_impl._M_finish,
254 _M_get_Tp_allocator());
256 this->_M_impl._M_finish = this->_M_impl._M_start + __xlen;
261 template<
typename _Tp,
typename _Alloc>
267 if (__n > capacity())
269 vector __tmp(__n, __val, _M_get_Tp_allocator());
270 __tmp._M_impl._M_swap_data(this->_M_impl);
272 else if (__n >
size())
275 const size_type __add = __n -
size();
276 _GLIBCXX_ASAN_ANNOTATE_GROW(__add);
277 this->_M_impl._M_finish =
278 std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
279 __add, __val, _M_get_Tp_allocator());
280 _GLIBCXX_ASAN_ANNOTATE_GREW(__add);
283 _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val));
286 template<
typename _Tp,
typename _Alloc>
287 template<
typename _InputIterator>
290 vector<_Tp, _Alloc>::
291 _M_assign_aux(_InputIterator __first, _InputIterator __last,
294 pointer __cur(this->_M_impl._M_start);
295 for (; __first != __last && __cur != this->_M_impl._M_finish;
296 ++__cur, (void)++__first)
298 if (__first == __last)
299 _M_erase_at_end(__cur);
301 _M_range_insert(
end(), __first, __last,
305 template<
typename _Tp,
typename _Alloc>
306 template<
typename _ForwardIterator>
309 vector<_Tp, _Alloc>::
310 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
315 if (__len > capacity())
317 _S_check_init_len(__len, _M_get_Tp_allocator());
318 pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
319 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
320 _M_get_Tp_allocator());
321 _GLIBCXX_ASAN_ANNOTATE_REINIT;
322 _M_deallocate(this->_M_impl._M_start,
323 this->_M_impl._M_end_of_storage
324 - this->_M_impl._M_start);
325 this->_M_impl._M_start = __tmp;
326 this->_M_impl._M_finish = this->_M_impl._M_start + __len;
327 this->_M_impl._M_end_of_storage = this->_M_impl._M_finish;
329 else if (
size() >= __len)
330 _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start));
333 _ForwardIterator __mid = __first;
335 std::copy(__first, __mid, this->_M_impl._M_start);
336 const size_type __attribute__((__unused__)) __n = __len -
size();
337 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
338 this->_M_impl._M_finish =
339 std::__uninitialized_copy_a(__mid, __last,
340 this->_M_impl._M_finish,
341 _M_get_Tp_allocator());
342 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
346#if __cplusplus >= 201103L
347 template<
typename _Tp,
typename _Alloc>
350 vector<_Tp, _Alloc>::
351 _M_insert_rval(const_iterator __position, value_type&& __v) -> iterator
353 const auto __n = __position -
cbegin();
354 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
355 if (__position ==
cend())
357 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
358 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
360 ++this->_M_impl._M_finish;
361 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
368 return iterator(this->_M_impl._M_start + __n);
371 template<
typename _Tp,
typename _Alloc>
372 template<
typename... _Args>
375 vector<_Tp, _Alloc>::
376 _M_emplace_aux(const_iterator __position, _Args&&... __args)
379 const auto __n = __position -
cbegin();
380 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
381 if (__position ==
cend())
383 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
384 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
385 std::forward<_Args>(__args)...);
386 ++this->_M_impl._M_finish;
387 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
394 _Temporary_value __tmp(
this, std::forward<_Args>(__args)...);
398 _M_realloc_insert(
begin() + __n, std::forward<_Args>(__args)...);
400 return iterator(this->_M_impl._M_start + __n);
403 template<
typename _Tp,
typename _Alloc>
404 template<
typename _Arg>
407 vector<_Tp, _Alloc>::
408 _M_insert_aux(iterator __position, _Arg&& __arg)
410 template<
typename _Tp,
typename _Alloc>
412 vector<_Tp, _Alloc>::
413 _M_insert_aux(iterator __position,
const _Tp& __x)
416 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
417 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
418 _GLIBCXX_MOVE(*(this->_M_impl._M_finish - 1)));
419 ++this->_M_impl._M_finish;
420 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
421#if __cplusplus < 201103L
424 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
425 this->_M_impl._M_finish - 2,
426 this->_M_impl._M_finish - 1);
427#if __cplusplus < 201103L
428 *__position = __x_copy;
430 *__position = std::forward<_Arg>(__arg);
434#if __cplusplus >= 201103L
435 template<
typename _Tp,
typename _Alloc>
436 template<
typename... _Args>
439 vector<_Tp, _Alloc>::
440 _M_realloc_insert(iterator __position, _Args&&... __args)
442 template<
typename _Tp,
typename _Alloc>
444 vector<_Tp, _Alloc>::
445 _M_realloc_insert(iterator __position,
const _Tp& __x)
448 const size_type __len =
449 _M_check_len(size_type(1),
"vector::_M_realloc_insert");
450 pointer __old_start = this->_M_impl._M_start;
451 pointer __old_finish = this->_M_impl._M_finish;
452 const size_type __elems_before = __position -
begin();
453 pointer __new_start(this->_M_allocate(__len));
454 pointer __new_finish(__new_start);
462 _Alloc_traits::construct(this->_M_impl,
463 __new_start + __elems_before,
464#
if __cplusplus >= 201103L
465 std::forward<_Args>(__args)...);
469 __new_finish = pointer();
471#if __cplusplus >= 201103L
472 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
474 __new_finish = _S_relocate(__old_start, __position.base(),
475 __new_start, _M_get_Tp_allocator());
479 __new_finish = _S_relocate(__position.base(), __old_finish,
480 __new_finish, _M_get_Tp_allocator());
486 = std::__uninitialized_move_if_noexcept_a
487 (__old_start, __position.base(),
488 __new_start, _M_get_Tp_allocator());
493 = std::__uninitialized_move_if_noexcept_a
494 (__position.base(), __old_finish,
495 __new_finish, _M_get_Tp_allocator());
501 _Alloc_traits::destroy(this->_M_impl,
502 __new_start + __elems_before);
504 std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
505 _M_deallocate(__new_start, __len);
506 __throw_exception_again;
508#if __cplusplus >= 201103L
509 if _GLIBCXX17_CONSTEXPR (!_S_use_relocate())
511 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
512 _GLIBCXX_ASAN_ANNOTATE_REINIT;
513 _M_deallocate(__old_start,
514 this->_M_impl._M_end_of_storage - __old_start);
515 this->_M_impl._M_start = __new_start;
516 this->_M_impl._M_finish = __new_finish;
517 this->_M_impl._M_end_of_storage = __new_start + __len;
520 template<
typename _Tp,
typename _Alloc>
523 vector<_Tp, _Alloc>::
524 _M_fill_insert(iterator __position, size_type __n,
const value_type& __x)
528 if (size_type(this->_M_impl._M_end_of_storage
529 - this->_M_impl._M_finish) >= __n)
531#if __cplusplus < 201103L
532 value_type __x_copy = __x;
534 _Temporary_value __tmp(
this, __x);
535 value_type& __x_copy = __tmp._M_val();
537 const size_type __elems_after =
end() - __position;
538 pointer __old_finish(this->_M_impl._M_finish);
539 if (__elems_after > __n)
541 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
542 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
543 this->_M_impl._M_finish,
544 this->_M_impl._M_finish,
545 _M_get_Tp_allocator());
546 this->_M_impl._M_finish += __n;
547 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
548 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
549 __old_finish - __n, __old_finish);
550 std::fill(__position.base(), __position.base() + __n,
555 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
556 this->_M_impl._M_finish =
557 std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
560 _M_get_Tp_allocator());
561 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
562 std::__uninitialized_move_a(__position.base(), __old_finish,
563 this->_M_impl._M_finish,
564 _M_get_Tp_allocator());
565 this->_M_impl._M_finish += __elems_after;
566 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
567 std::fill(__position.base(), __old_finish, __x_copy);
572 const size_type __len =
573 _M_check_len(__n,
"vector::_M_fill_insert");
574 const size_type __elems_before = __position -
begin();
575 pointer __new_start(this->_M_allocate(__len));
576 pointer __new_finish(__new_start);
580 std::__uninitialized_fill_n_a(__new_start + __elems_before,
582 _M_get_Tp_allocator());
583 __new_finish = pointer();
586 = std::__uninitialized_move_if_noexcept_a
587 (this->_M_impl._M_start, __position.base(),
588 __new_start, _M_get_Tp_allocator());
593 = std::__uninitialized_move_if_noexcept_a
594 (__position.base(), this->_M_impl._M_finish,
595 __new_finish, _M_get_Tp_allocator());
601 __new_start + __elems_before + __n,
602 _M_get_Tp_allocator());
605 _M_get_Tp_allocator());
606 _M_deallocate(__new_start, __len);
607 __throw_exception_again;
609 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
610 _M_get_Tp_allocator());
611 _GLIBCXX_ASAN_ANNOTATE_REINIT;
612 _M_deallocate(this->_M_impl._M_start,
613 this->_M_impl._M_end_of_storage
614 - this->_M_impl._M_start);
615 this->_M_impl._M_start = __new_start;
616 this->_M_impl._M_finish = __new_finish;
617 this->_M_impl._M_end_of_storage = __new_start + __len;
622#if __cplusplus >= 201103L
623 template<
typename _Tp,
typename _Alloc>
626 vector<_Tp, _Alloc>::
627 _M_default_append(size_type __n)
631 const size_type __size =
size();
632 size_type __navail = size_type(this->_M_impl._M_end_of_storage
633 - this->_M_impl._M_finish);
635 if (__size > max_size() || __navail > max_size() - __size)
636 __builtin_unreachable();
640 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
641 this->_M_impl._M_finish =
642 std::__uninitialized_default_n_a(this->_M_impl._M_finish,
643 __n, _M_get_Tp_allocator());
644 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
648 const size_type __len =
649 _M_check_len(__n,
"vector::_M_default_append");
650 pointer __new_start(this->_M_allocate(__len));
651 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
655 std::__uninitialized_default_n_a(__new_start + __size,
656 __n, _M_get_Tp_allocator());
660 _M_deallocate(__new_start, __len);
661 __throw_exception_again;
663 _S_relocate(this->_M_impl._M_start, this->_M_impl._M_finish,
664 __new_start, _M_get_Tp_allocator());
668 pointer __destroy_from = pointer();
671 std::__uninitialized_default_n_a(__new_start + __size,
672 __n, _M_get_Tp_allocator());
673 __destroy_from = __new_start + __size;
674 std::__uninitialized_move_if_noexcept_a(
675 this->_M_impl._M_start, this->_M_impl._M_finish,
676 __new_start, _M_get_Tp_allocator());
682 _M_get_Tp_allocator());
683 _M_deallocate(__new_start, __len);
684 __throw_exception_again;
686 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
687 _M_get_Tp_allocator());
689 _GLIBCXX_ASAN_ANNOTATE_REINIT;
690 _M_deallocate(this->_M_impl._M_start,
691 this->_M_impl._M_end_of_storage
692 - this->_M_impl._M_start);
693 this->_M_impl._M_start = __new_start;
694 this->_M_impl._M_finish = __new_start + __size + __n;
695 this->_M_impl._M_end_of_storage = __new_start + __len;
700 template<
typename _Tp,
typename _Alloc>
703 vector<_Tp, _Alloc>::
706 if (capacity() ==
size())
708 _GLIBCXX_ASAN_ANNOTATE_REINIT;
709 return std::__shrink_to_fit_aux<vector>::_S_do_it(*
this);
713 template<
typename _Tp,
typename _Alloc>
714 template<
typename _InputIterator>
717 vector<_Tp, _Alloc>::
718 _M_range_insert(iterator __pos, _InputIterator __first,
723 for (; __first != __last; ++__first)
724 insert(
end(), *__first);
726 else if (__first != __last)
728 vector __tmp(__first, __last, _M_get_Tp_allocator());
730 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()),
731 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end()));
735 template<
typename _Tp,
typename _Alloc>
736 template<
typename _ForwardIterator>
739 vector<_Tp, _Alloc>::
740 _M_range_insert(iterator __position, _ForwardIterator __first,
743 if (__first != __last)
746 if (size_type(this->_M_impl._M_end_of_storage
747 - this->_M_impl._M_finish) >= __n)
749 const size_type __elems_after =
end() - __position;
750 pointer __old_finish(this->_M_impl._M_finish);
751 if (__elems_after > __n)
753 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
754 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
755 this->_M_impl._M_finish,
756 this->_M_impl._M_finish,
757 _M_get_Tp_allocator());
758 this->_M_impl._M_finish += __n;
759 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
760 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
761 __old_finish - __n, __old_finish);
762 std::copy(__first, __last, __position);
766 _ForwardIterator __mid = __first;
768 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
769 std::__uninitialized_copy_a(__mid, __last,
770 this->_M_impl._M_finish,
771 _M_get_Tp_allocator());
772 this->_M_impl._M_finish += __n - __elems_after;
773 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
774 std::__uninitialized_move_a(__position.base(),
776 this->_M_impl._M_finish,
777 _M_get_Tp_allocator());
778 this->_M_impl._M_finish += __elems_after;
779 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
780 std::copy(__first, __mid, __position);
785 const size_type __len =
786 _M_check_len(__n,
"vector::_M_range_insert");
787 pointer __new_start(this->_M_allocate(__len));
788 pointer __new_finish(__new_start);
792 = std::__uninitialized_move_if_noexcept_a
793 (this->_M_impl._M_start, __position.base(),
794 __new_start, _M_get_Tp_allocator());
796 = std::__uninitialized_copy_a(__first, __last,
798 _M_get_Tp_allocator());
800 = std::__uninitialized_move_if_noexcept_a
801 (__position.base(), this->_M_impl._M_finish,
802 __new_finish, _M_get_Tp_allocator());
807 _M_get_Tp_allocator());
808 _M_deallocate(__new_start, __len);
809 __throw_exception_again;
811 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
812 _M_get_Tp_allocator());
813 _GLIBCXX_ASAN_ANNOTATE_REINIT;
814 _M_deallocate(this->_M_impl._M_start,
815 this->_M_impl._M_end_of_storage
816 - this->_M_impl._M_start);
817 this->_M_impl._M_start = __new_start;
818 this->_M_impl._M_finish = __new_finish;
819 this->_M_impl._M_end_of_storage = __new_start + __len;
826 template<
typename _Alloc>
829 vector<bool, _Alloc>::
830 _M_reallocate(size_type __n)
832 _Bit_pointer __q = this->_M_allocate(__n);
834 iterator __finish(_M_copy_aligned(
begin(),
end(), __start));
835 this->_M_deallocate();
836 this->_M_impl._M_start = __start;
837 this->_M_impl._M_finish = __finish;
838 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
841 template<
typename _Alloc>
844 vector<bool, _Alloc>::
845 _M_fill_insert(iterator __position, size_type __n,
bool __x)
851 std::copy_backward(__position,
end(),
852 this->_M_impl._M_finish + difference_type(__n));
853 std::fill(__position, __position + difference_type(__n), __x);
854 this->_M_impl._M_finish += difference_type(__n);
858 const size_type __len =
859 _M_check_len(__n,
"vector<bool>::_M_fill_insert");
860 _Bit_pointer __q = this->_M_allocate(__len);
862 iterator __i = _M_copy_aligned(
begin(), __position, __start);
863 std::fill(__i, __i + difference_type(__n), __x);
864 iterator __finish = std::copy(__position,
end(),
865 __i + difference_type(__n));
866 this->_M_deallocate();
867 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
868 this->_M_impl._M_start = __start;
869 this->_M_impl._M_finish = __finish;
873 template<
typename _Alloc>
874 template<
typename _ForwardIterator>
877 vector<bool, _Alloc>::
878 _M_insert_range(iterator __position, _ForwardIterator __first,
881 if (__first != __last)
886 std::copy_backward(__position,
end(),
887 this->_M_impl._M_finish
888 + difference_type(__n));
889 std::copy(__first, __last, __position);
890 this->_M_impl._M_finish += difference_type(__n);
894 const size_type __len =
895 _M_check_len(__n,
"vector<bool>::_M_insert_range");
896 _Bit_pointer __q = this->_M_allocate(__len);
898 iterator __i = _M_copy_aligned(
begin(), __position, __start);
899 __i = std::copy(__first, __last, __i);
900 iterator __finish = std::copy(__position,
end(), __i);
901 this->_M_deallocate();
902 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
903 this->_M_impl._M_start = __start;
904 this->_M_impl._M_finish = __finish;
909 template<
typename _Alloc>
912 vector<bool, _Alloc>::
913 _M_insert_aux(iterator __position,
bool __x)
915 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
917 std::copy_backward(__position, this->_M_impl._M_finish,
918 this->_M_impl._M_finish + 1);
920 ++this->_M_impl._M_finish;
924 const size_type __len =
925 _M_check_len(size_type(1),
"vector<bool>::_M_insert_aux");
926 _Bit_pointer __q = this->_M_allocate(__len);
928 iterator __i = _M_copy_aligned(
begin(), __position, __start);
930 iterator __finish = std::copy(__position,
end(), __i);
931 this->_M_deallocate();
932 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
933 this->_M_impl._M_start = __start;
934 this->_M_impl._M_finish = __finish;
938 template<
typename _Alloc>
940 typename vector<bool, _Alloc>::iterator
941 vector<bool, _Alloc>::
942 _M_erase(iterator __position)
944 if (__position + 1 !=
end())
945 std::copy(__position + 1,
end(), __position);
946 --this->_M_impl._M_finish;
950 template<
typename _Alloc>
952 typename vector<bool, _Alloc>::iterator
953 vector<bool, _Alloc>::
954 _M_erase(iterator __first, iterator __last)
956 if (__first != __last)
957 _M_erase_at_end(std::copy(__last,
end(), __first));
961#if __cplusplus >= 201103L
962 template<
typename _Alloc>
965 vector<bool, _Alloc>::
972 if (size_type __n =
size())
976 this->_M_deallocate();
977 this->_M_impl._M_reset();
986_GLIBCXX_END_NAMESPACE_CONTAINER
987_GLIBCXX_END_NAMESPACE_VERSION
990#if __cplusplus >= 201103L
992namespace std _GLIBCXX_VISIBILITY(default)
994_GLIBCXX_BEGIN_NAMESPACE_VERSION
996 template<
typename _Alloc>
998 hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
999 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b)
const noexcept
1002 const size_t __words = __b.size() / _S_word_bit;
1005 const size_t __clength = __words *
sizeof(_Bit_type);
1006 __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
1009 const size_t __extrabits = __b.size() % _S_word_bit;
1012 _Bit_type __hiword = *__b._M_impl._M_finish._M_p;
1013 __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits);
1015 const size_t __clength
1016 = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__;
1018 __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
1020 __hash = std::_Hash_impl::hash(&__hiword, __clength);
1026_GLIBCXX_END_NAMESPACE_VERSION
1031#undef _GLIBCXX_ASAN_ANNOTATE_REINIT
1032#undef _GLIBCXX_ASAN_ANNOTATE_GROW
1033#undef _GLIBCXX_ASAN_ANNOTATE_GREW
1034#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.
_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, _Allocator &__alloc)
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 end() noexcept
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 size_type size() const noexcept
constexpr vector & operator=(const vector &__x)
Vector assignment operator.