59 namespace std _GLIBCXX_VISIBILITY(default)
61 _GLIBCXX_BEGIN_NAMESPACE_VERSION
62 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
64 template<
typename _Tp,
typename _Alloc>
69 if (__n > this->max_size())
70 __throw_length_error(__N(
"vector::reserve"));
71 if (this->capacity() < __n)
73 const size_type __old_size = size();
74 pointer __tmp = _M_allocate_and_copy(__n,
75 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_start),
76 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_finish));
77 _GLIBCXX_ASAN_ANNOTATE_REINIT;
78 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
79 _M_get_Tp_allocator());
80 _M_deallocate(this->_M_impl._M_start,
81 this->_M_impl._M_end_of_storage
82 - this->_M_impl._M_start);
83 this->_M_impl._M_start = __tmp;
84 this->_M_impl._M_finish = __tmp + __old_size;
85 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
89 #if __cplusplus >= 201103L 90 template<
typename _Tp,
typename _Alloc>
91 template<
typename... _Args>
92 #if __cplusplus > 201402L 93 typename vector<_Tp, _Alloc>::reference
100 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
102 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
103 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
104 std::forward<_Args>(__args)...);
105 ++this->_M_impl._M_finish;
106 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
109 _M_realloc_insert(
end(), std::forward<_Args>(__args)...);
110 #if __cplusplus > 201402L 116 template<
typename _Tp,
typename _Alloc>
117 typename vector<_Tp, _Alloc>::iterator
118 vector<_Tp, _Alloc>::
119 #if __cplusplus >= 201103L 122 insert(iterator __position,
const value_type& __x)
125 const size_type __n = __position -
begin();
126 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
127 if (__position ==
end())
129 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
130 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
132 ++this->_M_impl._M_finish;
133 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
137 #if __cplusplus >= 201103L 138 const auto __pos =
begin() + (__position -
cbegin());
141 _Temporary_value __x_copy(
this, __x);
142 _M_insert_aux(__pos, std::move(__x_copy._M_val()));
144 _M_insert_aux(__position, __x);
148 #if __cplusplus >= 201103L 149 _M_realloc_insert(
begin() + (__position -
cbegin()), __x);
151 _M_realloc_insert(__position, __x);
154 return iterator(this->_M_impl._M_start + __n);
157 template<
typename _Tp,
typename _Alloc>
158 typename vector<_Tp, _Alloc>::iterator
162 if (__position + 1 !=
end())
163 _GLIBCXX_MOVE3(__position + 1,
end(), __position);
164 --this->_M_impl._M_finish;
165 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
166 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
170 template<
typename _Tp,
typename _Alloc>
171 typename vector<_Tp, _Alloc>::iterator
172 vector<_Tp, _Alloc>::
173 _M_erase(iterator __first, iterator __last)
175 if (__first != __last)
178 _GLIBCXX_MOVE3(__last,
end(), __first);
179 _M_erase_at_end(__first.base() + (
end() - __last));
184 template<
typename _Tp,
typename _Alloc>
191 _GLIBCXX_ASAN_ANNOTATE_REINIT;
192 #if __cplusplus >= 201103L 193 if (_Alloc_traits::_S_propagate_on_copy_assign())
195 if (!_Alloc_traits::_S_always_equal()
196 && _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
200 _M_deallocate(this->_M_impl._M_start,
201 this->_M_impl._M_end_of_storage
202 - this->_M_impl._M_start);
203 this->_M_impl._M_start =
nullptr;
204 this->_M_impl._M_finish =
nullptr;
205 this->_M_impl._M_end_of_storage =
nullptr;
207 std::__alloc_on_copy(_M_get_Tp_allocator(),
208 __x._M_get_Tp_allocator());
211 const size_type __xlen = __x.
size();
212 if (__xlen > capacity())
214 pointer __tmp = _M_allocate_and_copy(__xlen, __x.
begin(),
216 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
217 _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 = __tmp;
222 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen;
224 else if (size() >= __xlen)
227 end(), _M_get_Tp_allocator());
231 std::copy(__x._M_impl._M_start, __x._M_impl._M_start + size(),
232 this->_M_impl._M_start);
233 std::__uninitialized_copy_a(__x._M_impl._M_start + size(),
234 __x._M_impl._M_finish,
235 this->_M_impl._M_finish,
236 _M_get_Tp_allocator());
238 this->_M_impl._M_finish = this->_M_impl._M_start + __xlen;
243 template<
typename _Tp,
typename _Alloc>
248 if (__n > capacity())
250 vector __tmp(__n, __val, _M_get_Tp_allocator());
251 __tmp._M_impl._M_swap_data(this->_M_impl);
253 else if (__n > size())
256 const size_type __add = __n - size();
257 _GLIBCXX_ASAN_ANNOTATE_GROW(__add);
258 this->_M_impl._M_finish =
259 std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
260 __add, __val, _M_get_Tp_allocator());
261 _GLIBCXX_ASAN_ANNOTATE_GREW(__add);
264 _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val));
267 template<
typename _Tp,
typename _Alloc>
268 template<
typename _InputIterator>
270 vector<_Tp, _Alloc>::
271 _M_assign_aux(_InputIterator __first, _InputIterator __last,
274 pointer __cur(this->_M_impl._M_start);
275 for (; __first != __last && __cur != this->_M_impl._M_finish;
278 if (__first == __last)
279 _M_erase_at_end(__cur);
281 _M_range_insert(
end(), __first, __last,
285 template<
typename _Tp,
typename _Alloc>
286 template<
typename _ForwardIterator>
288 vector<_Tp, _Alloc>::
289 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
294 if (__len > capacity())
296 pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
297 _GLIBCXX_ASAN_ANNOTATE_REINIT;
298 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
299 _M_get_Tp_allocator());
300 _M_deallocate(this->_M_impl._M_start,
301 this->_M_impl._M_end_of_storage
302 - this->_M_impl._M_start);
303 this->_M_impl._M_start = __tmp;
304 this->_M_impl._M_finish = this->_M_impl._M_start + __len;
305 this->_M_impl._M_end_of_storage = this->_M_impl._M_finish;
307 else if (size() >= __len)
308 _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start));
311 _ForwardIterator __mid = __first;
313 std::copy(__first, __mid, this->_M_impl._M_start);
314 const size_type __attribute__((__unused__)) __n = __len - size();
315 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
316 this->_M_impl._M_finish =
317 std::__uninitialized_copy_a(__mid, __last,
318 this->_M_impl._M_finish,
319 _M_get_Tp_allocator());
320 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
324 #if __cplusplus >= 201103L 325 template<
typename _Tp,
typename _Alloc>
327 vector<_Tp, _Alloc>::
328 _M_insert_rval(const_iterator __position, value_type&& __v) -> iterator
330 const auto __n = __position -
cbegin();
331 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
332 if (__position ==
cend())
334 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
335 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
337 ++this->_M_impl._M_finish;
338 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
341 _M_insert_aux(
begin() + __n, std::move(__v));
343 _M_realloc_insert(
begin() + __n, std::move(__v));
345 return iterator(this->_M_impl._M_start + __n);
348 template<
typename _Tp,
typename _Alloc>
349 template<
typename... _Args>
351 vector<_Tp, _Alloc>::
352 _M_emplace_aux(const_iterator __position, _Args&&... __args)
355 const auto __n = __position -
cbegin();
356 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
357 if (__position ==
cend())
359 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
360 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
361 std::forward<_Args>(__args)...);
362 ++this->_M_impl._M_finish;
363 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
370 _Temporary_value __tmp(
this, std::forward<_Args>(__args)...);
371 _M_insert_aux(
begin() + __n, std::move(__tmp._M_val()));
374 _M_realloc_insert(
begin() + __n, std::forward<_Args>(__args)...);
376 return iterator(this->_M_impl._M_start + __n);
379 template<
typename _Tp,
typename _Alloc>
380 template<
typename _Arg>
382 vector<_Tp, _Alloc>::
383 _M_insert_aux(iterator __position, _Arg&& __arg)
385 template<
typename _Tp,
typename _Alloc>
387 vector<_Tp, _Alloc>::
388 _M_insert_aux(iterator __position,
const _Tp& __x)
391 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
392 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
393 _GLIBCXX_MOVE(*(this->_M_impl._M_finish - 1)));
394 ++this->_M_impl._M_finish;
395 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
396 #if __cplusplus < 201103L 399 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
400 this->_M_impl._M_finish - 2,
401 this->_M_impl._M_finish - 1);
402 #if __cplusplus < 201103L 403 *__position = __x_copy;
405 *__position = std::forward<_Arg>(__arg);
409 #if __cplusplus >= 201103L 410 template<
typename _Tp,
typename _Alloc>
411 template<
typename... _Args>
413 vector<_Tp, _Alloc>::
414 _M_realloc_insert(iterator __position, _Args&&... __args)
416 template<
typename _Tp,
typename _Alloc>
418 vector<_Tp, _Alloc>::
419 _M_realloc_insert(iterator __position,
const _Tp& __x)
422 const size_type __len =
423 _M_check_len(size_type(1),
"vector::_M_realloc_insert");
424 pointer __old_start = this->_M_impl._M_start;
425 pointer __old_finish = this->_M_impl._M_finish;
426 const size_type __elems_before = __position -
begin();
427 pointer __new_start(this->_M_allocate(__len));
428 pointer __new_finish(__new_start);
436 _Alloc_traits::construct(this->_M_impl,
437 __new_start + __elems_before,
438 #
if __cplusplus >= 201103L
439 std::forward<_Args>(__args)...);
443 __new_finish = pointer();
446 = std::__uninitialized_move_if_noexcept_a
447 (__old_start, __position.base(),
448 __new_start, _M_get_Tp_allocator());
453 = std::__uninitialized_move_if_noexcept_a
454 (__position.base(), __old_finish,
455 __new_finish, _M_get_Tp_allocator());
460 _Alloc_traits::destroy(this->_M_impl,
461 __new_start + __elems_before);
463 std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
464 _M_deallocate(__new_start, __len);
465 __throw_exception_again;
467 _GLIBCXX_ASAN_ANNOTATE_REINIT;
468 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
469 _M_deallocate(__old_start,
470 this->_M_impl._M_end_of_storage - __old_start);
471 this->_M_impl._M_start = __new_start;
472 this->_M_impl._M_finish = __new_finish;
473 this->_M_impl._M_end_of_storage = __new_start + __len;
476 template<
typename _Tp,
typename _Alloc>
478 vector<_Tp, _Alloc>::
479 _M_fill_insert(iterator __position, size_type __n,
const value_type& __x)
483 if (size_type(this->_M_impl._M_end_of_storage
484 - this->_M_impl._M_finish) >= __n)
486 #if __cplusplus < 201103L 487 value_type __x_copy = __x;
489 _Temporary_value __tmp(
this, __x);
490 value_type& __x_copy = __tmp._M_val();
492 const size_type __elems_after =
end() - __position;
493 pointer __old_finish(this->_M_impl._M_finish);
494 if (__elems_after > __n)
496 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
497 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
498 this->_M_impl._M_finish,
499 this->_M_impl._M_finish,
500 _M_get_Tp_allocator());
501 this->_M_impl._M_finish += __n;
502 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
503 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
504 __old_finish - __n, __old_finish);
505 std::fill(__position.base(), __position.base() + __n,
510 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
511 this->_M_impl._M_finish =
512 std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
515 _M_get_Tp_allocator());
516 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
517 std::__uninitialized_move_a(__position.base(), __old_finish,
518 this->_M_impl._M_finish,
519 _M_get_Tp_allocator());
520 this->_M_impl._M_finish += __elems_after;
521 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
522 std::fill(__position.base(), __old_finish, __x_copy);
527 const size_type __len =
528 _M_check_len(__n,
"vector::_M_fill_insert");
529 const size_type __elems_before = __position -
begin();
530 pointer __new_start(this->_M_allocate(__len));
531 pointer __new_finish(__new_start);
535 std::__uninitialized_fill_n_a(__new_start + __elems_before,
537 _M_get_Tp_allocator());
538 __new_finish = pointer();
541 = std::__uninitialized_move_if_noexcept_a
542 (this->_M_impl._M_start, __position.base(),
543 __new_start, _M_get_Tp_allocator());
548 = std::__uninitialized_move_if_noexcept_a
549 (__position.base(), this->_M_impl._M_finish,
550 __new_finish, _M_get_Tp_allocator());
556 __new_start + __elems_before + __n,
557 _M_get_Tp_allocator());
560 _M_get_Tp_allocator());
561 _M_deallocate(__new_start, __len);
562 __throw_exception_again;
564 _GLIBCXX_ASAN_ANNOTATE_REINIT;
565 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
566 _M_get_Tp_allocator());
567 _M_deallocate(this->_M_impl._M_start,
568 this->_M_impl._M_end_of_storage
569 - this->_M_impl._M_start);
570 this->_M_impl._M_start = __new_start;
571 this->_M_impl._M_finish = __new_finish;
572 this->_M_impl._M_end_of_storage = __new_start + __len;
577 #if __cplusplus >= 201103L 578 template<
typename _Tp,
typename _Alloc>
580 vector<_Tp, _Alloc>::
581 _M_default_append(size_type __n)
585 const size_type __size = size();
586 size_type __navail = size_type(this->_M_impl._M_end_of_storage
587 - this->_M_impl._M_finish);
589 if (__size > max_size() || __navail > max_size() - __size)
590 __builtin_unreachable();
594 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
595 this->_M_impl._M_finish =
596 std::__uninitialized_default_n_a(this->_M_impl._M_finish,
597 __n, _M_get_Tp_allocator());
598 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
602 const size_type __len =
603 _M_check_len(__n,
"vector::_M_default_append");
604 pointer __new_start(this->_M_allocate(__len));
605 pointer __destroy_from = pointer();
608 std::__uninitialized_default_n_a(__new_start + __size,
609 __n, _M_get_Tp_allocator());
610 __destroy_from = __new_start + __size;
611 std::__uninitialized_move_if_noexcept_a(
612 this->_M_impl._M_start, this->_M_impl._M_finish,
613 __new_start, _M_get_Tp_allocator());
619 _M_get_Tp_allocator());
620 _M_deallocate(__new_start, __len);
621 __throw_exception_again;
623 _GLIBCXX_ASAN_ANNOTATE_REINIT;
624 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
625 _M_get_Tp_allocator());
626 _M_deallocate(this->_M_impl._M_start,
627 this->_M_impl._M_end_of_storage
628 - this->_M_impl._M_start);
629 this->_M_impl._M_start = __new_start;
630 this->_M_impl._M_finish = __new_start + __size + __n;
631 this->_M_impl._M_end_of_storage = __new_start + __len;
636 template<
typename _Tp,
typename _Alloc>
638 vector<_Tp, _Alloc>::
641 if (capacity() == size())
643 _GLIBCXX_ASAN_ANNOTATE_REINIT;
644 return std::__shrink_to_fit_aux<vector>::_S_do_it(*
this);
648 template<
typename _Tp,
typename _Alloc>
649 template<
typename _InputIterator>
651 vector<_Tp, _Alloc>::
652 _M_range_insert(iterator __pos, _InputIterator __first,
657 for (; __first != __last; ++__first)
658 insert(
end(), *__first);
660 else if (__first != __last)
662 vector __tmp(__first, __last, _M_get_Tp_allocator());
664 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()),
665 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end()));
669 template<
typename _Tp,
typename _Alloc>
670 template<
typename _ForwardIterator>
672 vector<_Tp, _Alloc>::
673 _M_range_insert(iterator __position, _ForwardIterator __first,
676 if (__first != __last)
679 if (size_type(this->_M_impl._M_end_of_storage
680 - this->_M_impl._M_finish) >= __n)
682 const size_type __elems_after =
end() - __position;
683 pointer __old_finish(this->_M_impl._M_finish);
684 if (__elems_after > __n)
686 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
687 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
688 this->_M_impl._M_finish,
689 this->_M_impl._M_finish,
690 _M_get_Tp_allocator());
691 this->_M_impl._M_finish += __n;
692 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
693 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
694 __old_finish - __n, __old_finish);
695 std::copy(__first, __last, __position);
699 _ForwardIterator __mid = __first;
701 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
702 std::__uninitialized_copy_a(__mid, __last,
703 this->_M_impl._M_finish,
704 _M_get_Tp_allocator());
705 this->_M_impl._M_finish += __n - __elems_after;
706 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
707 std::__uninitialized_move_a(__position.base(),
709 this->_M_impl._M_finish,
710 _M_get_Tp_allocator());
711 this->_M_impl._M_finish += __elems_after;
712 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
713 std::copy(__first, __mid, __position);
718 const size_type __len =
719 _M_check_len(__n,
"vector::_M_range_insert");
720 pointer __new_start(this->_M_allocate(__len));
721 pointer __new_finish(__new_start);
725 = std::__uninitialized_move_if_noexcept_a
726 (this->_M_impl._M_start, __position.base(),
727 __new_start, _M_get_Tp_allocator());
729 = std::__uninitialized_copy_a(__first, __last,
731 _M_get_Tp_allocator());
733 = std::__uninitialized_move_if_noexcept_a
734 (__position.base(), this->_M_impl._M_finish,
735 __new_finish, _M_get_Tp_allocator());
740 _M_get_Tp_allocator());
741 _M_deallocate(__new_start, __len);
742 __throw_exception_again;
744 _GLIBCXX_ASAN_ANNOTATE_REINIT;
745 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
746 _M_get_Tp_allocator());
747 _M_deallocate(this->_M_impl._M_start,
748 this->_M_impl._M_end_of_storage
749 - this->_M_impl._M_start);
750 this->_M_impl._M_start = __new_start;
751 this->_M_impl._M_finish = __new_finish;
752 this->_M_impl._M_end_of_storage = __new_start + __len;
759 template<
typename _Alloc>
761 vector<bool, _Alloc>::
762 _M_reallocate(size_type __n)
764 _Bit_pointer __q = this->_M_allocate(__n);
766 iterator __finish(_M_copy_aligned(
begin(),
end(), __start));
767 this->_M_deallocate();
768 this->_M_impl._M_start = __start;
769 this->_M_impl._M_finish = __finish;
770 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
773 template<
typename _Alloc>
775 vector<bool, _Alloc>::
776 _M_fill_insert(iterator __position, size_type __n,
bool __x)
782 std::copy_backward(__position,
end(),
783 this->_M_impl._M_finish + difference_type(__n));
784 std::fill(__position, __position + difference_type(__n), __x);
785 this->_M_impl._M_finish += difference_type(__n);
789 const size_type __len =
790 _M_check_len(__n,
"vector<bool>::_M_fill_insert");
791 _Bit_pointer __q = this->_M_allocate(__len);
793 iterator __i = _M_copy_aligned(
begin(), __position, __start);
794 std::fill(__i, __i + difference_type(__n), __x);
795 iterator __finish = std::copy(__position,
end(),
796 __i + difference_type(__n));
797 this->_M_deallocate();
798 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
799 this->_M_impl._M_start = __start;
800 this->_M_impl._M_finish = __finish;
804 template<
typename _Alloc>
805 template<
typename _ForwardIterator>
807 vector<bool, _Alloc>::
808 _M_insert_range(iterator __position, _ForwardIterator __first,
811 if (__first != __last)
816 std::copy_backward(__position,
end(),
817 this->_M_impl._M_finish
818 + difference_type(__n));
819 std::copy(__first, __last, __position);
820 this->_M_impl._M_finish += difference_type(__n);
824 const size_type __len =
825 _M_check_len(__n,
"vector<bool>::_M_insert_range");
826 _Bit_pointer __q = this->_M_allocate(__len);
828 iterator __i = _M_copy_aligned(
begin(), __position, __start);
829 __i = std::copy(__first, __last, __i);
830 iterator __finish = std::copy(__position,
end(), __i);
831 this->_M_deallocate();
832 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
833 this->_M_impl._M_start = __start;
834 this->_M_impl._M_finish = __finish;
839 template<
typename _Alloc>
841 vector<bool, _Alloc>::
842 _M_insert_aux(iterator __position,
bool __x)
844 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
846 std::copy_backward(__position, this->_M_impl._M_finish,
847 this->_M_impl._M_finish + 1);
849 ++this->_M_impl._M_finish;
853 const size_type __len =
854 _M_check_len(size_type(1),
"vector<bool>::_M_insert_aux");
855 _Bit_pointer __q = this->_M_allocate(__len);
857 iterator __i = _M_copy_aligned(
begin(), __position, __start);
859 iterator __finish = std::copy(__position,
end(), __i);
860 this->_M_deallocate();
861 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
862 this->_M_impl._M_start = __start;
863 this->_M_impl._M_finish = __finish;
867 template<
typename _Alloc>
868 typename vector<bool, _Alloc>::iterator
869 vector<bool, _Alloc>::
870 _M_erase(iterator __position)
872 if (__position + 1 !=
end())
873 std::copy(__position + 1,
end(), __position);
874 --this->_M_impl._M_finish;
878 template<
typename _Alloc>
879 typename vector<bool, _Alloc>::iterator
880 vector<bool, _Alloc>::
881 _M_erase(iterator __first, iterator __last)
883 if (__first != __last)
884 _M_erase_at_end(std::copy(__last,
end(), __first));
888 #if __cplusplus >= 201103L 889 template<
typename _Alloc>
891 vector<bool, _Alloc>::
898 _M_reallocate(
size());
906 _GLIBCXX_END_NAMESPACE_CONTAINER
907 _GLIBCXX_END_NAMESPACE_VERSION
910 #if __cplusplus >= 201103L 912 namespace std _GLIBCXX_VISIBILITY(default)
914 _GLIBCXX_BEGIN_NAMESPACE_VERSION
916 template<
typename _Alloc>
918 hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
919 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b)
const noexcept
922 using _GLIBCXX_STD_C::_S_word_bit;
923 using _GLIBCXX_STD_C::_Bit_type;
925 const size_t __words = __b.size() / _S_word_bit;
928 const size_t __clength = __words *
sizeof(_Bit_type);
929 __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
932 const size_t __extrabits = __b.size() % _S_word_bit;
935 _Bit_type __hiword = *__b._M_impl._M_finish._M_p;
936 __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits);
938 const size_t __clength
939 = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__;
941 __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
943 __hash = std::_Hash_impl::hash(&__hiword, __clength);
949 _GLIBCXX_END_NAMESPACE_VERSION
954 #undef _GLIBCXX_ASAN_ANNOTATE_REINIT 955 #undef _GLIBCXX_ASAN_ANNOTATE_GROW 956 #undef _GLIBCXX_ASAN_ANNOTATE_GREW 957 #undef _GLIBCXX_ASAN_ANNOTATE_SHRINK A standard container which offers fixed time access to individual elements in any order.
_GLIBCXX17_CONSTEXPR iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
void _Destroy(_Tp *__pointer)
Forward iterators support a superset of input iterator operations.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
_GLIBCXX17_CONSTEXPR void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
vector & operator=(const vector &__x)
Vector assignment operator.
ISO C++ entities toplevel namespace is std.
iterator begin() noexcept
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
constexpr const _Tp * end(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to one past the last element of the initializer_list.
size_type capacity() const noexcept
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.
void reserve(size_type __n)
Attempt to preallocate enough memory for specified number of elements.
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 const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
size_type size() const noexcept