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(__old_finish - __n,
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(__old_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);
574 pointer __old_start = this->_M_impl._M_start;
575 pointer __old_finish = this->_M_impl._M_finish;
576 const pointer __pos = __position.base();
578 const size_type __len =
579 _M_check_len(__n,
"vector::_M_fill_insert");
580 const size_type __elems_before = __pos - __old_start;
581 pointer __new_start(this->_M_allocate(__len));
582 pointer __new_finish(__new_start);
586 std::__uninitialized_fill_n_a(__new_start + __elems_before,
588 _M_get_Tp_allocator());
589 __new_finish = pointer();
592 = std::__uninitialized_move_if_noexcept_a
593 (__old_start, __pos, __new_start, _M_get_Tp_allocator());
598 = std::__uninitialized_move_if_noexcept_a
599 (__pos, __old_finish, __new_finish, _M_get_Tp_allocator());
605 __new_start + __elems_before + __n,
606 _M_get_Tp_allocator());
609 _M_get_Tp_allocator());
610 _M_deallocate(__new_start, __len);
611 __throw_exception_again;
613 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
614 _GLIBCXX_ASAN_ANNOTATE_REINIT;
615 _M_deallocate(__old_start,
616 this->_M_impl._M_end_of_storage - __old_start);
617 this->_M_impl._M_start = __new_start;
618 this->_M_impl._M_finish = __new_finish;
619 this->_M_impl._M_end_of_storage = __new_start + __len;
624#if __cplusplus >= 201103L
625 template<
typename _Tp,
typename _Alloc>
628 vector<_Tp, _Alloc>::
629 _M_default_append(size_type __n)
633 const size_type __size =
size();
634 size_type __navail = size_type(this->_M_impl._M_end_of_storage
635 - this->_M_impl._M_finish);
637 if (__size > max_size() || __navail > max_size() - __size)
638 __builtin_unreachable();
642 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
643 this->_M_impl._M_finish =
644 std::__uninitialized_default_n_a(this->_M_impl._M_finish,
645 __n, _M_get_Tp_allocator());
646 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
652 pointer __old_start = this->_M_impl._M_start;
653 pointer __old_finish = this->_M_impl._M_finish;
655 const size_type __len =
656 _M_check_len(__n,
"vector::_M_default_append");
657 pointer __new_start(this->_M_allocate(__len));
658 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
662 std::__uninitialized_default_n_a(__new_start + __size,
663 __n, _M_get_Tp_allocator());
667 _M_deallocate(__new_start, __len);
668 __throw_exception_again;
670 _S_relocate(__old_start, __old_finish,
671 __new_start, _M_get_Tp_allocator());
675 pointer __destroy_from = pointer();
678 std::__uninitialized_default_n_a(__new_start + __size,
679 __n, _M_get_Tp_allocator());
680 __destroy_from = __new_start + __size;
681 std::__uninitialized_move_if_noexcept_a(
682 __old_start, __old_finish,
683 __new_start, _M_get_Tp_allocator());
689 _M_get_Tp_allocator());
690 _M_deallocate(__new_start, __len);
691 __throw_exception_again;
694 _M_get_Tp_allocator());
696 _GLIBCXX_ASAN_ANNOTATE_REINIT;
697 _M_deallocate(__old_start,
698 this->_M_impl._M_end_of_storage - __old_start);
699 this->_M_impl._M_start = __new_start;
700 this->_M_impl._M_finish = __new_start + __size + __n;
701 this->_M_impl._M_end_of_storage = __new_start + __len;
706 template<
typename _Tp,
typename _Alloc>
709 vector<_Tp, _Alloc>::
712 if (capacity() ==
size())
714 _GLIBCXX_ASAN_ANNOTATE_REINIT;
715 return std::__shrink_to_fit_aux<vector>::_S_do_it(*
this);
719 template<
typename _Tp,
typename _Alloc>
720 template<
typename _InputIterator>
723 vector<_Tp, _Alloc>::
724 _M_range_insert(iterator __pos, _InputIterator __first,
729 for (; __first != __last; ++__first)
730 insert(
end(), *__first);
732 else if (__first != __last)
734 vector __tmp(__first, __last, _M_get_Tp_allocator());
736 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()),
737 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end()));
741 template<
typename _Tp,
typename _Alloc>
742 template<
typename _ForwardIterator>
745 vector<_Tp, _Alloc>::
746 _M_range_insert(iterator __position, _ForwardIterator __first,
749 if (__first != __last)
752 if (size_type(this->_M_impl._M_end_of_storage
753 - this->_M_impl._M_finish) >= __n)
755 const size_type __elems_after =
end() - __position;
756 pointer __old_finish(this->_M_impl._M_finish);
757 if (__elems_after > __n)
759 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
760 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
761 this->_M_impl._M_finish,
762 this->_M_impl._M_finish,
763 _M_get_Tp_allocator());
764 this->_M_impl._M_finish += __n;
765 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
766 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
767 __old_finish - __n, __old_finish);
768 std::copy(__first, __last, __position);
772 _ForwardIterator __mid = __first;
774 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
775 std::__uninitialized_copy_a(__mid, __last,
776 this->_M_impl._M_finish,
777 _M_get_Tp_allocator());
778 this->_M_impl._M_finish += __n - __elems_after;
779 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
780 std::__uninitialized_move_a(__position.base(),
782 this->_M_impl._M_finish,
783 _M_get_Tp_allocator());
784 this->_M_impl._M_finish += __elems_after;
785 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
786 std::copy(__first, __mid, __position);
794 pointer __old_start = this->_M_impl._M_start;
795 pointer __old_finish = this->_M_impl._M_finish;
797 const size_type __len =
798 _M_check_len(__n,
"vector::_M_range_insert");
799 pointer __new_start(this->_M_allocate(__len));
800 pointer __new_finish(__new_start);
804 = std::__uninitialized_move_if_noexcept_a
805 (__old_start, __position.base(),
806 __new_start, _M_get_Tp_allocator());
808 = std::__uninitialized_copy_a(__first, __last,
810 _M_get_Tp_allocator());
812 = std::__uninitialized_move_if_noexcept_a
813 (__position.base(), __old_finish,
814 __new_finish, _M_get_Tp_allocator());
819 _M_get_Tp_allocator());
820 _M_deallocate(__new_start, __len);
821 __throw_exception_again;
824 _M_get_Tp_allocator());
825 _GLIBCXX_ASAN_ANNOTATE_REINIT;
826 _M_deallocate(__old_start,
827 this->_M_impl._M_end_of_storage - __old_start);
828 this->_M_impl._M_start = __new_start;
829 this->_M_impl._M_finish = __new_finish;
830 this->_M_impl._M_end_of_storage = __new_start + __len;
837 template<
typename _Alloc>
843 _Bit_pointer __q = this->_M_allocate(__n);
846 this->_M_deallocate();
847 this->_M_impl._M_start = __start;
848 this->_M_impl._M_finish = __finish;
849 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
852 template<
typename _Alloc>
855 vector<bool, _Alloc>::
856 _M_fill_insert(iterator __position, size_type __n,
bool __x)
860 if (capacity() -
size() >= __n)
862 std::copy_backward(__position,
end(),
863 this->_M_impl._M_finish + difference_type(__n));
864 std::fill(__position, __position + difference_type(__n), __x);
865 this->_M_impl._M_finish += difference_type(__n);
869 const size_type __len =
870 _M_check_len(__n,
"vector<bool>::_M_fill_insert");
871 _Bit_pointer __q = this->_M_allocate(__len);
873 iterator __i = _M_copy_aligned(
begin(), __position, __start);
874 std::fill(__i, __i + difference_type(__n), __x);
875 iterator __finish = std::copy(__position,
end(),
876 __i + difference_type(__n));
877 this->_M_deallocate();
878 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
879 this->_M_impl._M_start = __start;
880 this->_M_impl._M_finish = __finish;
884 template<
typename _Alloc>
885 template<
typename _ForwardIterator>
888 vector<bool, _Alloc>::
889 _M_insert_range(iterator __position, _ForwardIterator __first,
892 if (__first != __last)
895 if (capacity() -
size() >= __n)
897 std::copy_backward(__position,
end(),
898 this->_M_impl._M_finish
899 + difference_type(__n));
900 std::copy(__first, __last, __position);
901 this->_M_impl._M_finish += difference_type(__n);
905 const size_type __len =
906 _M_check_len(__n,
"vector<bool>::_M_insert_range");
907 _Bit_pointer __q = this->_M_allocate(__len);
909 iterator __i = _M_copy_aligned(
begin(), __position, __start);
910 __i = std::copy(__first, __last, __i);
911 iterator __finish = std::copy(__position,
end(), __i);
912 this->_M_deallocate();
913 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
914 this->_M_impl._M_start = __start;
915 this->_M_impl._M_finish = __finish;
920 template<
typename _Alloc>
923 vector<bool, _Alloc>::
924 _M_insert_aux(iterator __position,
bool __x)
926 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
928 std::copy_backward(__position, this->_M_impl._M_finish,
929 this->_M_impl._M_finish + 1);
931 ++this->_M_impl._M_finish;
935 const size_type __len =
936 _M_check_len(size_type(1),
"vector<bool>::_M_insert_aux");
937 _Bit_pointer __q = this->_M_allocate(__len);
939 iterator __i = _M_copy_aligned(
begin(), __position, __start);
941 iterator __finish = std::copy(__position,
end(), __i);
942 this->_M_deallocate();
943 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
944 this->_M_impl._M_start = __start;
945 this->_M_impl._M_finish = __finish;
949 template<
typename _Alloc>
951 typename vector<bool, _Alloc>::iterator
952 vector<bool, _Alloc>::
953 _M_erase(iterator __position)
955 if (__position + 1 !=
end())
956 std::copy(__position + 1,
end(), __position);
957 --this->_M_impl._M_finish;
961 template<
typename _Alloc>
963 typename vector<bool, _Alloc>::iterator
964 vector<bool, _Alloc>::
965 _M_erase(iterator __first, iterator __last)
967 if (__first != __last)
968 _M_erase_at_end(std::copy(__last,
end(), __first));
972#if __cplusplus >= 201103L
973 template<
typename _Alloc>
976 vector<bool, _Alloc>::
979 if (capacity() -
size() <
int(_S_word_bit))
983 if (size_type __n =
size())
987 this->_M_deallocate();
988 this->_M_impl._M_reset();
997_GLIBCXX_END_NAMESPACE_CONTAINER
998_GLIBCXX_END_NAMESPACE_VERSION
1001#if __cplusplus >= 201103L
1003namespace std _GLIBCXX_VISIBILITY(default)
1005_GLIBCXX_BEGIN_NAMESPACE_VERSION
1007 template<
typename _Alloc>
1009 hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
1010 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b)
const noexcept
1013 const size_t __words = __b.size() / _S_word_bit;
1016 const size_t __clength = __words *
sizeof(_Bit_type);
1017 __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
1020 const size_t __extrabits = __b.size() % _S_word_bit;
1023 _Bit_type __hiword = *__b._M_impl._M_finish._M_p;
1024 __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits);
1026 const size_t __clength
1027 = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__;
1029 __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
1031 __hash = std::_Hash_impl::hash(&__hiword, __clength);
1037_GLIBCXX_END_NAMESPACE_VERSION
1042#undef _GLIBCXX_ASAN_ANNOTATE_REINIT
1043#undef _GLIBCXX_ASAN_ANNOTATE_GROW
1044#undef _GLIBCXX_ASAN_ANNOTATE_GREW
1045#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 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.