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 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 const size_type __old_size = __size;
605 pointer __new_start(this->_M_allocate(__len));
606 pointer __new_finish(__new_start);
610 = std::__uninitialized_move_if_noexcept_a
611 (this->_M_impl._M_start, this->_M_impl._M_finish,
612 __new_start, _M_get_Tp_allocator());
614 std::__uninitialized_default_n_a(__new_finish, __n,
615 _M_get_Tp_allocator());
620 _M_get_Tp_allocator());
621 _M_deallocate(__new_start, __len);
622 __throw_exception_again;
624 _GLIBCXX_ASAN_ANNOTATE_REINIT;
625 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
626 _M_get_Tp_allocator());
627 _M_deallocate(this->_M_impl._M_start,
628 this->_M_impl._M_end_of_storage
629 - this->_M_impl._M_start);
630 this->_M_impl._M_start = __new_start;
631 this->_M_impl._M_finish = __new_finish;
632 this->_M_impl._M_end_of_storage = __new_start + __len;
637 template<
typename _Tp,
typename _Alloc>
639 vector<_Tp, _Alloc>::
642 if (capacity() == size())
644 _GLIBCXX_ASAN_ANNOTATE_REINIT;
645 return std::__shrink_to_fit_aux<vector>::_S_do_it(*
this);
649 template<
typename _Tp,
typename _Alloc>
650 template<
typename _InputIterator>
652 vector<_Tp, _Alloc>::
653 _M_range_insert(iterator __pos, _InputIterator __first,
658 for (; __first != __last; ++__first)
659 insert(
end(), *__first);
661 else if (__first != __last)
663 vector __tmp(__first, __last, _M_get_Tp_allocator());
665 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()),
666 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end()));
670 template<
typename _Tp,
typename _Alloc>
671 template<
typename _ForwardIterator>
673 vector<_Tp, _Alloc>::
674 _M_range_insert(iterator __position, _ForwardIterator __first,
677 if (__first != __last)
680 if (size_type(this->_M_impl._M_end_of_storage
681 - this->_M_impl._M_finish) >= __n)
683 const size_type __elems_after =
end() - __position;
684 pointer __old_finish(this->_M_impl._M_finish);
685 if (__elems_after > __n)
687 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
688 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
689 this->_M_impl._M_finish,
690 this->_M_impl._M_finish,
691 _M_get_Tp_allocator());
692 this->_M_impl._M_finish += __n;
693 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
694 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
695 __old_finish - __n, __old_finish);
696 std::copy(__first, __last, __position);
700 _ForwardIterator __mid = __first;
702 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
703 std::__uninitialized_copy_a(__mid, __last,
704 this->_M_impl._M_finish,
705 _M_get_Tp_allocator());
706 this->_M_impl._M_finish += __n - __elems_after;
707 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
708 std::__uninitialized_move_a(__position.base(),
710 this->_M_impl._M_finish,
711 _M_get_Tp_allocator());
712 this->_M_impl._M_finish += __elems_after;
713 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
714 std::copy(__first, __mid, __position);
719 const size_type __len =
720 _M_check_len(__n,
"vector::_M_range_insert");
721 pointer __new_start(this->_M_allocate(__len));
722 pointer __new_finish(__new_start);
726 = std::__uninitialized_move_if_noexcept_a
727 (this->_M_impl._M_start, __position.base(),
728 __new_start, _M_get_Tp_allocator());
730 = std::__uninitialized_copy_a(__first, __last,
732 _M_get_Tp_allocator());
734 = std::__uninitialized_move_if_noexcept_a
735 (__position.base(), this->_M_impl._M_finish,
736 __new_finish, _M_get_Tp_allocator());
741 _M_get_Tp_allocator());
742 _M_deallocate(__new_start, __len);
743 __throw_exception_again;
745 _GLIBCXX_ASAN_ANNOTATE_REINIT;
746 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
747 _M_get_Tp_allocator());
748 _M_deallocate(this->_M_impl._M_start,
749 this->_M_impl._M_end_of_storage
750 - this->_M_impl._M_start);
751 this->_M_impl._M_start = __new_start;
752 this->_M_impl._M_finish = __new_finish;
753 this->_M_impl._M_end_of_storage = __new_start + __len;
760 template<
typename _Alloc>
762 vector<bool, _Alloc>::
763 _M_reallocate(size_type __n)
765 _Bit_pointer __q = this->_M_allocate(__n);
767 iterator __finish(_M_copy_aligned(
begin(),
end(), __start));
768 this->_M_deallocate();
769 this->_M_impl._M_start = __start;
770 this->_M_impl._M_finish = __finish;
771 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
774 template<
typename _Alloc>
776 vector<bool, _Alloc>::
777 _M_fill_insert(iterator __position, size_type __n,
bool __x)
783 std::copy_backward(__position,
end(),
784 this->_M_impl._M_finish + difference_type(__n));
785 std::fill(__position, __position + difference_type(__n), __x);
786 this->_M_impl._M_finish += difference_type(__n);
790 const size_type __len =
791 _M_check_len(__n,
"vector<bool>::_M_fill_insert");
792 _Bit_pointer __q = this->_M_allocate(__len);
794 iterator __i = _M_copy_aligned(
begin(), __position, __start);
795 std::fill(__i, __i + difference_type(__n), __x);
796 iterator __finish = std::copy(__position,
end(),
797 __i + difference_type(__n));
798 this->_M_deallocate();
799 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
800 this->_M_impl._M_start = __start;
801 this->_M_impl._M_finish = __finish;
805 template<
typename _Alloc>
806 template<
typename _ForwardIterator>
808 vector<bool, _Alloc>::
809 _M_insert_range(iterator __position, _ForwardIterator __first,
812 if (__first != __last)
817 std::copy_backward(__position,
end(),
818 this->_M_impl._M_finish
819 + difference_type(__n));
820 std::copy(__first, __last, __position);
821 this->_M_impl._M_finish += difference_type(__n);
825 const size_type __len =
826 _M_check_len(__n,
"vector<bool>::_M_insert_range");
827 _Bit_pointer __q = this->_M_allocate(__len);
829 iterator __i = _M_copy_aligned(
begin(), __position, __start);
830 __i = std::copy(__first, __last, __i);
831 iterator __finish = std::copy(__position,
end(), __i);
832 this->_M_deallocate();
833 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
834 this->_M_impl._M_start = __start;
835 this->_M_impl._M_finish = __finish;
840 template<
typename _Alloc>
842 vector<bool, _Alloc>::
843 _M_insert_aux(iterator __position,
bool __x)
845 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
847 std::copy_backward(__position, this->_M_impl._M_finish,
848 this->_M_impl._M_finish + 1);
850 ++this->_M_impl._M_finish;
854 const size_type __len =
855 _M_check_len(size_type(1),
"vector<bool>::_M_insert_aux");
856 _Bit_pointer __q = this->_M_allocate(__len);
858 iterator __i = _M_copy_aligned(
begin(), __position, __start);
860 iterator __finish = std::copy(__position,
end(), __i);
861 this->_M_deallocate();
862 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
863 this->_M_impl._M_start = __start;
864 this->_M_impl._M_finish = __finish;
868 template<
typename _Alloc>
869 typename vector<bool, _Alloc>::iterator
870 vector<bool, _Alloc>::
871 _M_erase(iterator __position)
873 if (__position + 1 !=
end())
874 std::copy(__position + 1,
end(), __position);
875 --this->_M_impl._M_finish;
879 template<
typename _Alloc>
880 typename vector<bool, _Alloc>::iterator
881 vector<bool, _Alloc>::
882 _M_erase(iterator __first, iterator __last)
884 if (__first != __last)
885 _M_erase_at_end(std::copy(__last,
end(), __first));
889 #if __cplusplus >= 201103L 890 template<
typename _Alloc>
892 vector<bool, _Alloc>::
899 _M_reallocate(
size());
907 _GLIBCXX_END_NAMESPACE_CONTAINER
908 _GLIBCXX_END_NAMESPACE_VERSION
911 #if __cplusplus >= 201103L 913 namespace std _GLIBCXX_VISIBILITY(default)
915 _GLIBCXX_BEGIN_NAMESPACE_VERSION
917 template<
typename _Alloc>
919 hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
920 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b)
const noexcept
923 using _GLIBCXX_STD_C::_S_word_bit;
924 using _GLIBCXX_STD_C::_Bit_type;
926 const size_t __words = __b.size() / _S_word_bit;
929 const size_t __clength = __words *
sizeof(_Bit_type);
930 __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
933 const size_t __extrabits = __b.size() % _S_word_bit;
936 _Bit_type __hiword = *__b._M_impl._M_finish._M_p;
937 __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits);
939 const size_t __clength
940 = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__;
942 __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
944 __hash = std::_Hash_impl::hash(&__hiword, __clength);
950 _GLIBCXX_END_NAMESPACE_VERSION
955 #undef _GLIBCXX_ASAN_ANNOTATE_REINIT 956 #undef _GLIBCXX_ASAN_ANNOTATE_GROW 957 #undef _GLIBCXX_ASAN_ANNOTATE_GREW 958 #undef _GLIBCXX_ASAN_ANNOTATE_SHRINK iterator begin() noexcept
constexpr const _Tp * end(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to one past the last element of the initializer_list. ...
void reserve(size_type __n)
Attempt to preallocate enough memory for specified number of elements.
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 const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
A standard container which offers fixed time access to individual elements in any order...
size_type size() const noexcept
vector & operator=(const vector &__x)
Vector assignment operator.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
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.
ISO C++ entities toplevel namespace is std.
_GLIBCXX17_CONSTEXPR iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
void _Destroy(_Tp *__pointer)
_GLIBCXX17_CONSTEXPR void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
Forward iterators support a superset of input iterator operations.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
size_type capacity() const noexcept