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)
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();
236 if (__xlen > capacity())
238 pointer __tmp = _M_allocate_and_copy(__xlen, __x.
begin(),
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>
273 if (__n > capacity())
275 vector __tmp(__n, __val, _M_get_Tp_allocator());
276 __tmp._M_impl._M_swap_data(this->_M_impl);
278 else if (__n >
size())
281 const size_type __add = __n -
size();
282 _GLIBCXX_ASAN_ANNOTATE_GROW(__add);
283 this->_M_impl._M_finish =
284 std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
285 __add, __val, _M_get_Tp_allocator());
286 _GLIBCXX_ASAN_ANNOTATE_GREW(__add);
289 _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val));
292 template<
typename _Tp,
typename _Alloc>
293 template<
typename _InputIterator>
296 vector<_Tp, _Alloc>::
297 _M_assign_aux(_InputIterator __first, _InputIterator __last,
300 pointer __cur(this->_M_impl._M_start);
301 for (; __first != __last && __cur != this->_M_impl._M_finish;
302 ++__cur, (void)++__first)
304 if (__first == __last)
305 _M_erase_at_end(__cur);
307 _M_range_insert(
end(), __first, __last,
311 template<
typename _Tp,
typename _Alloc>
312 template<
typename _ForwardIterator>
315 vector<_Tp, _Alloc>::
316 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
321 if (__len > capacity())
323 _S_check_init_len(__len, _M_get_Tp_allocator());
324 pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
325 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
326 _M_get_Tp_allocator());
327 _GLIBCXX_ASAN_ANNOTATE_REINIT;
328 _M_deallocate(this->_M_impl._M_start,
329 this->_M_impl._M_end_of_storage
330 - this->_M_impl._M_start);
331 this->_M_impl._M_start = __tmp;
332 this->_M_impl._M_finish = this->_M_impl._M_start + __len;
333 this->_M_impl._M_end_of_storage = this->_M_impl._M_finish;
335 else if (
size() >= __len)
336 _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start));
339 _ForwardIterator __mid = __first;
341 std::copy(__first, __mid, this->_M_impl._M_start);
342 const size_type __attribute__((__unused__)) __n = __len -
size();
343 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
344 this->_M_impl._M_finish =
345 std::__uninitialized_copy_a(__mid, __last,
346 this->_M_impl._M_finish,
347 _M_get_Tp_allocator());
348 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
352#if __cplusplus >= 201103L
353 template<
typename _Tp,
typename _Alloc>
356 vector<_Tp, _Alloc>::
357 _M_insert_rval(const_iterator __position, value_type&& __v) -> iterator
359 const auto __n = __position -
cbegin();
360 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
361 if (__position ==
cend())
363 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
364 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
366 ++this->_M_impl._M_finish;
367 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
374 return iterator(this->_M_impl._M_start + __n);
377 template<
typename _Tp,
typename _Alloc>
378 template<
typename... _Args>
381 vector<_Tp, _Alloc>::
382 _M_emplace_aux(const_iterator __position, _Args&&... __args)
385 const auto __n = __position -
cbegin();
386 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
387 if (__position ==
cend())
389 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
390 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
391 std::forward<_Args>(__args)...);
392 ++this->_M_impl._M_finish;
393 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
400 _Temporary_value __tmp(
this, std::forward<_Args>(__args)...);
404 _M_realloc_insert(
begin() + __n, std::forward<_Args>(__args)...);
406 return iterator(this->_M_impl._M_start + __n);
409 template<
typename _Tp,
typename _Alloc>
410 template<
typename _Arg>
413 vector<_Tp, _Alloc>::
414 _M_insert_aux(iterator __position, _Arg&& __arg)
416 template<
typename _Tp,
typename _Alloc>
418 vector<_Tp, _Alloc>::
419 _M_insert_aux(iterator __position,
const _Tp& __x)
422 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
423 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
424 _GLIBCXX_MOVE(*(this->_M_impl._M_finish - 1)));
425 ++this->_M_impl._M_finish;
426 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
427#if __cplusplus < 201103L
430 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
431 this->_M_impl._M_finish - 2,
432 this->_M_impl._M_finish - 1);
433#if __cplusplus < 201103L
434 *__position = __x_copy;
436 *__position = std::forward<_Arg>(__arg);
440#if __cplusplus >= 201103L
441 template<
typename _Tp,
typename _Alloc>
442 template<
typename... _Args>
445 vector<_Tp, _Alloc>::
446 _M_realloc_insert(iterator __position, _Args&&... __args)
448 template<
typename _Tp,
typename _Alloc>
450 vector<_Tp, _Alloc>::
451 _M_realloc_insert(iterator __position,
const _Tp& __x)
454 const size_type __len =
455 _M_check_len(size_type(1),
"vector::_M_realloc_insert");
456 pointer __old_start = this->_M_impl._M_start;
457 pointer __old_finish = this->_M_impl._M_finish;
458 const size_type __elems_before = __position -
begin();
459 pointer __new_start(this->_M_allocate(__len));
460 pointer __new_finish(__new_start);
468 _Alloc_traits::construct(this->_M_impl,
469 __new_start + __elems_before,
470#
if __cplusplus >= 201103L
471 std::forward<_Args>(__args)...);
475 __new_finish = pointer();
477#if __cplusplus >= 201103L
478 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
480 __new_finish = _S_relocate(__old_start, __position.base(),
481 __new_start, _M_get_Tp_allocator());
485 __new_finish = _S_relocate(__position.base(), __old_finish,
486 __new_finish, _M_get_Tp_allocator());
492 = std::__uninitialized_move_if_noexcept_a
493 (__old_start, __position.base(),
494 __new_start, _M_get_Tp_allocator());
499 = std::__uninitialized_move_if_noexcept_a
500 (__position.base(), __old_finish,
501 __new_finish, _M_get_Tp_allocator());
507 _Alloc_traits::destroy(this->_M_impl,
508 __new_start + __elems_before);
510 std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
511 _M_deallocate(__new_start, __len);
512 __throw_exception_again;
514#if __cplusplus >= 201103L
515 if _GLIBCXX17_CONSTEXPR (!_S_use_relocate())
517 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
518 _GLIBCXX_ASAN_ANNOTATE_REINIT;
519 _M_deallocate(__old_start,
520 this->_M_impl._M_end_of_storage - __old_start);
521 this->_M_impl._M_start = __new_start;
522 this->_M_impl._M_finish = __new_finish;
523 this->_M_impl._M_end_of_storage = __new_start + __len;
526 template<
typename _Tp,
typename _Alloc>
529 vector<_Tp, _Alloc>::
530 _M_fill_insert(iterator __position, size_type __n,
const value_type& __x)
534 if (size_type(this->_M_impl._M_end_of_storage
535 - this->_M_impl._M_finish) >= __n)
537#if __cplusplus < 201103L
538 value_type __x_copy = __x;
540 _Temporary_value __tmp(
this, __x);
541 value_type& __x_copy = __tmp._M_val();
543 const size_type __elems_after =
end() - __position;
544 pointer __old_finish(this->_M_impl._M_finish);
545 if (__elems_after > __n)
547 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
548 std::__uninitialized_move_a(__old_finish - __n,
551 _M_get_Tp_allocator());
552 this->_M_impl._M_finish += __n;
553 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
554 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
555 __old_finish - __n, __old_finish);
556 std::fill(__position.base(), __position.base() + __n,
561 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
562 this->_M_impl._M_finish =
563 std::__uninitialized_fill_n_a(__old_finish,
566 _M_get_Tp_allocator());
567 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
568 std::__uninitialized_move_a(__position.base(), __old_finish,
569 this->_M_impl._M_finish,
570 _M_get_Tp_allocator());
571 this->_M_impl._M_finish += __elems_after;
572 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
573 std::fill(__position.base(), __old_finish, __x_copy);
580 pointer __old_start = this->_M_impl._M_start;
581 pointer __old_finish = this->_M_impl._M_finish;
582 const pointer __pos = __position.base();
584 const size_type __len =
585 _M_check_len(__n,
"vector::_M_fill_insert");
586 const size_type __elems_before = __pos - __old_start;
587 pointer __new_start(this->_M_allocate(__len));
588 pointer __new_finish(__new_start);
592 std::__uninitialized_fill_n_a(__new_start + __elems_before,
594 _M_get_Tp_allocator());
595 __new_finish = pointer();
598 = std::__uninitialized_move_if_noexcept_a
599 (__old_start, __pos, __new_start, _M_get_Tp_allocator());
604 = std::__uninitialized_move_if_noexcept_a
605 (__pos, __old_finish, __new_finish, _M_get_Tp_allocator());
611 __new_start + __elems_before + __n,
612 _M_get_Tp_allocator());
615 _M_get_Tp_allocator());
616 _M_deallocate(__new_start, __len);
617 __throw_exception_again;
619 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
620 _GLIBCXX_ASAN_ANNOTATE_REINIT;
621 _M_deallocate(__old_start,
622 this->_M_impl._M_end_of_storage - __old_start);
623 this->_M_impl._M_start = __new_start;
624 this->_M_impl._M_finish = __new_finish;
625 this->_M_impl._M_end_of_storage = __new_start + __len;
630#if __cplusplus >= 201103L
631 template<
typename _Tp,
typename _Alloc>
634 vector<_Tp, _Alloc>::
635 _M_default_append(size_type __n)
639 const size_type __size =
size();
640 size_type __navail = size_type(this->_M_impl._M_end_of_storage
641 - this->_M_impl._M_finish);
643 if (__size > max_size() || __navail > max_size() - __size)
644 __builtin_unreachable();
648 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
649 this->_M_impl._M_finish =
650 std::__uninitialized_default_n_a(this->_M_impl._M_finish,
651 __n, _M_get_Tp_allocator());
652 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
658 pointer __old_start = this->_M_impl._M_start;
659 pointer __old_finish = this->_M_impl._M_finish;
661 const size_type __len =
662 _M_check_len(__n,
"vector::_M_default_append");
663 pointer __new_start(this->_M_allocate(__len));
664 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
668 std::__uninitialized_default_n_a(__new_start + __size,
669 __n, _M_get_Tp_allocator());
673 _M_deallocate(__new_start, __len);
674 __throw_exception_again;
676 _S_relocate(__old_start, __old_finish,
677 __new_start, _M_get_Tp_allocator());
681 pointer __destroy_from = pointer();
684 std::__uninitialized_default_n_a(__new_start + __size,
685 __n, _M_get_Tp_allocator());
686 __destroy_from = __new_start + __size;
687 std::__uninitialized_move_if_noexcept_a(
688 __old_start, __old_finish,
689 __new_start, _M_get_Tp_allocator());
695 _M_get_Tp_allocator());
696 _M_deallocate(__new_start, __len);
697 __throw_exception_again;
700 _M_get_Tp_allocator());
702 _GLIBCXX_ASAN_ANNOTATE_REINIT;
703 _M_deallocate(__old_start,
704 this->_M_impl._M_end_of_storage - __old_start);
705 this->_M_impl._M_start = __new_start;
706 this->_M_impl._M_finish = __new_start + __size + __n;
707 this->_M_impl._M_end_of_storage = __new_start + __len;
712 template<
typename _Tp,
typename _Alloc>
715 vector<_Tp, _Alloc>::
718 if (capacity() ==
size())
720 _GLIBCXX_ASAN_ANNOTATE_REINIT;
721 return std::__shrink_to_fit_aux<vector>::_S_do_it(*
this);
725 template<
typename _Tp,
typename _Alloc>
726 template<
typename _InputIterator>
729 vector<_Tp, _Alloc>::
730 _M_range_insert(iterator __pos, _InputIterator __first,
735 for (; __first != __last; ++__first)
736 insert(
end(), *__first);
738 else if (__first != __last)
740 vector __tmp(__first, __last, _M_get_Tp_allocator());
742 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()),
743 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end()));
747 template<
typename _Tp,
typename _Alloc>
748 template<
typename _ForwardIterator>
755 if (__first != __last)
758 if (size_type(this->_M_impl._M_end_of_storage
759 - this->_M_impl._M_finish) >= __n)
761 const size_type __elems_after =
end() - __position;
762 pointer __old_finish(this->_M_impl._M_finish);
763 if (__elems_after > __n)
765 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
766 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
767 this->_M_impl._M_finish,
768 this->_M_impl._M_finish,
769 _M_get_Tp_allocator());
770 this->_M_impl._M_finish += __n;
771 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
772 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
773 __old_finish - __n, __old_finish);
774 std::copy(__first, __last, __position);
778 _ForwardIterator __mid = __first;
780 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
781 std::__uninitialized_copy_a(__mid, __last,
782 this->_M_impl._M_finish,
783 _M_get_Tp_allocator());
784 this->_M_impl._M_finish += __n - __elems_after;
785 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
786 std::__uninitialized_move_a(__position.base(),
788 this->_M_impl._M_finish,
789 _M_get_Tp_allocator());
790 this->_M_impl._M_finish += __elems_after;
791 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
792 std::copy(__first, __mid, __position);
800 pointer __old_start = this->_M_impl._M_start;
801 pointer __old_finish = this->_M_impl._M_finish;
803 const size_type __len =
804 _M_check_len(__n,
"vector::_M_range_insert");
805 pointer __new_start(this->_M_allocate(__len));
806 pointer __new_finish(__new_start);
810 = std::__uninitialized_move_if_noexcept_a
811 (__old_start, __position.base(),
812 __new_start, _M_get_Tp_allocator());
814 = std::__uninitialized_copy_a(__first, __last,
816 _M_get_Tp_allocator());
818 = std::__uninitialized_move_if_noexcept_a
819 (__position.base(), __old_finish,
820 __new_finish, _M_get_Tp_allocator());
825 _M_get_Tp_allocator());
826 _M_deallocate(__new_start, __len);
827 __throw_exception_again;
830 _M_get_Tp_allocator());
831 _GLIBCXX_ASAN_ANNOTATE_REINIT;
832 _M_deallocate(__old_start,
833 this->_M_impl._M_end_of_storage - __old_start);
834 this->_M_impl._M_start = __new_start;
835 this->_M_impl._M_finish = __new_finish;
836 this->_M_impl._M_end_of_storage = __new_start + __len;
843 template<
typename _Alloc>
849 _Bit_pointer __q = this->_M_allocate(__n);
852 this->_M_deallocate();
853 this->_M_impl._M_start = __start;
854 this->_M_impl._M_finish = __finish;
855 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
858 template<
typename _Alloc>
861 vector<bool, _Alloc>::
862 _M_fill_insert(iterator __position, size_type __n,
bool __x)
866 if (capacity() -
size() >= __n)
868 std::copy_backward(__position,
end(),
869 this->_M_impl._M_finish + difference_type(__n));
870 std::fill(__position, __position + difference_type(__n), __x);
871 this->_M_impl._M_finish += difference_type(__n);
875 const size_type __len =
876 _M_check_len(__n,
"vector<bool>::_M_fill_insert");
877 _Bit_pointer __q = this->_M_allocate(__len);
879 iterator __i = _M_copy_aligned(
begin(), __position, __start);
880 std::fill(__i, __i + difference_type(__n), __x);
881 iterator __finish = std::copy(__position,
end(),
882 __i + difference_type(__n));
883 this->_M_deallocate();
884 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
885 this->_M_impl._M_start = __start;
886 this->_M_impl._M_finish = __finish;
890 template<
typename _Alloc>
891 template<
typename _ForwardIterator>
894 vector<bool, _Alloc>::
895 _M_insert_range(iterator __position, _ForwardIterator __first,
898 if (__first != __last)
901 if (capacity() -
size() >= __n)
903 std::copy_backward(__position,
end(),
904 this->_M_impl._M_finish
905 + difference_type(__n));
906 std::copy(__first, __last, __position);
907 this->_M_impl._M_finish += difference_type(__n);
911 const size_type __len =
912 _M_check_len(__n,
"vector<bool>::_M_insert_range");
913 _Bit_pointer __q = this->_M_allocate(__len);
915 iterator __i = _M_copy_aligned(
begin(), __position, __start);
916 __i = std::copy(__first, __last, __i);
917 iterator __finish = std::copy(__position,
end(), __i);
918 this->_M_deallocate();
919 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
920 this->_M_impl._M_start = __start;
921 this->_M_impl._M_finish = __finish;
926 template<
typename _Alloc>
929 vector<bool, _Alloc>::
930 _M_insert_aux(iterator __position,
bool __x)
932 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
934 std::copy_backward(__position, this->_M_impl._M_finish,
935 this->_M_impl._M_finish + 1);
937 ++this->_M_impl._M_finish;
941 const size_type __len =
942 _M_check_len(size_type(1),
"vector<bool>::_M_insert_aux");
943 _Bit_pointer __q = this->_M_allocate(__len);
945 iterator __i = _M_copy_aligned(
begin(), __position, __start);
947 iterator __finish = std::copy(__position,
end(), __i);
948 this->_M_deallocate();
949 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
950 this->_M_impl._M_start = __start;
951 this->_M_impl._M_finish = __finish;
955 template<
typename _Alloc>
957 typename vector<bool, _Alloc>::iterator
958 vector<bool, _Alloc>::
959 _M_erase(iterator __position)
961 if (__position + 1 !=
end())
962 std::copy(__position + 1,
end(), __position);
963 --this->_M_impl._M_finish;
967 template<
typename _Alloc>
969 typename vector<bool, _Alloc>::iterator
970 vector<bool, _Alloc>::
971 _M_erase(iterator __first, iterator __last)
973 if (__first != __last)
974 _M_erase_at_end(std::copy(__last,
end(), __first));
978#if __cplusplus >= 201103L
979 template<
typename _Alloc>
982 vector<bool, _Alloc>::
985 if (capacity() -
size() <
int(_S_word_bit))
989 if (size_type __n =
size())
993 this->_M_deallocate();
994 this->_M_impl._M_reset();
1003_GLIBCXX_END_NAMESPACE_CONTAINER
1004_GLIBCXX_END_NAMESPACE_VERSION
1007#if __cplusplus >= 201103L
1009namespace std _GLIBCXX_VISIBILITY(default)
1011_GLIBCXX_BEGIN_NAMESPACE_VERSION
1013 template<
typename _Alloc>
1015 hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
1016 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b)
const noexcept
1019 const size_t __words = __b.size() / _S_word_bit;
1022 const size_t __clength = __words *
sizeof(_Bit_type);
1023 __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
1026 const size_t __extrabits = __b.size() % _S_word_bit;
1029 _Bit_type __hiword = *__b._M_impl._M_finish._M_p;
1030 __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits);
1032 const size_t __clength
1033 = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__;
1035 __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
1037 __hash = std::_Hash_impl::hash(&__hiword, __clength);
1043_GLIBCXX_END_NAMESPACE_VERSION
1048#undef _GLIBCXX_ASAN_ANNOTATE_REINIT
1049#undef _GLIBCXX_ASAN_ANNOTATE_GROW
1050#undef _GLIBCXX_ASAN_ANNOTATE_GREW
1051#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)
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 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.