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();
75 #if __cplusplus >= 201103L 76 if constexpr (_S_use_relocate())
78 __tmp = this->_M_allocate(__n);
79 std::__relocate_a(this->_M_impl._M_start,
80 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 106 typename vector<_Tp, _Alloc>::reference
113 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
115 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
116 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
117 std::forward<_Args>(__args)...);
118 ++this->_M_impl._M_finish;
119 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
122 _M_realloc_insert(
end(), std::forward<_Args>(__args)...);
123 #if __cplusplus > 201402L 129 template<
typename _Tp,
typename _Alloc>
130 typename vector<_Tp, _Alloc>::iterator
131 vector<_Tp, _Alloc>::
132 #if __cplusplus >= 201103L 135 insert(iterator __position,
const value_type& __x)
138 const size_type __n = __position -
begin();
139 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
140 if (__position ==
end())
142 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
143 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
145 ++this->_M_impl._M_finish;
146 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
150 #if __cplusplus >= 201103L 151 const auto __pos =
begin() + (__position -
cbegin());
154 _Temporary_value __x_copy(
this, __x);
155 _M_insert_aux(__pos, std::move(__x_copy._M_val()));
157 _M_insert_aux(__position, __x);
161 #if __cplusplus >= 201103L 162 _M_realloc_insert(
begin() + (__position -
cbegin()), __x);
164 _M_realloc_insert(__position, __x);
167 return iterator(this->_M_impl._M_start + __n);
170 template<
typename _Tp,
typename _Alloc>
171 typename vector<_Tp, _Alloc>::iterator
175 if (__position + 1 !=
end())
176 _GLIBCXX_MOVE3(__position + 1,
end(), __position);
177 --this->_M_impl._M_finish;
178 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
179 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
183 template<
typename _Tp,
typename _Alloc>
184 typename vector<_Tp, _Alloc>::iterator
185 vector<_Tp, _Alloc>::
186 _M_erase(iterator __first, iterator __last)
188 if (__first != __last)
191 _GLIBCXX_MOVE3(__last,
end(), __first);
192 _M_erase_at_end(__first.base() + (
end() - __last));
197 template<
typename _Tp,
typename _Alloc>
204 _GLIBCXX_ASAN_ANNOTATE_REINIT;
205 #if __cplusplus >= 201103L 206 if (_Alloc_traits::_S_propagate_on_copy_assign())
208 if (!_Alloc_traits::_S_always_equal()
209 && _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
213 _M_deallocate(this->_M_impl._M_start,
214 this->_M_impl._M_end_of_storage
215 - this->_M_impl._M_start);
216 this->_M_impl._M_start =
nullptr;
217 this->_M_impl._M_finish =
nullptr;
218 this->_M_impl._M_end_of_storage =
nullptr;
220 std::__alloc_on_copy(_M_get_Tp_allocator(),
221 __x._M_get_Tp_allocator());
224 const size_type __xlen = __x.
size();
225 if (__xlen > capacity())
227 pointer __tmp = _M_allocate_and_copy(__xlen, __x.
begin(),
229 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
230 _M_get_Tp_allocator());
231 _M_deallocate(this->_M_impl._M_start,
232 this->_M_impl._M_end_of_storage
233 - this->_M_impl._M_start);
234 this->_M_impl._M_start = __tmp;
235 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen;
237 else if (size() >= __xlen)
240 end(), _M_get_Tp_allocator());
244 std::copy(__x._M_impl._M_start, __x._M_impl._M_start + size(),
245 this->_M_impl._M_start);
246 std::__uninitialized_copy_a(__x._M_impl._M_start + size(),
247 __x._M_impl._M_finish,
248 this->_M_impl._M_finish,
249 _M_get_Tp_allocator());
251 this->_M_impl._M_finish = this->_M_impl._M_start + __xlen;
256 template<
typename _Tp,
typename _Alloc>
261 if (__n > capacity())
263 vector __tmp(__n, __val, _M_get_Tp_allocator());
264 __tmp._M_impl._M_swap_data(this->_M_impl);
266 else if (__n > size())
269 const size_type __add = __n - size();
270 _GLIBCXX_ASAN_ANNOTATE_GROW(__add);
271 this->_M_impl._M_finish =
272 std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
273 __add, __val, _M_get_Tp_allocator());
274 _GLIBCXX_ASAN_ANNOTATE_GREW(__add);
277 _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val));
280 template<
typename _Tp,
typename _Alloc>
281 template<
typename _InputIterator>
283 vector<_Tp, _Alloc>::
284 _M_assign_aux(_InputIterator __first, _InputIterator __last,
287 pointer __cur(this->_M_impl._M_start);
288 for (; __first != __last && __cur != this->_M_impl._M_finish;
289 ++__cur, (void)++__first)
291 if (__first == __last)
292 _M_erase_at_end(__cur);
294 _M_range_insert(
end(), __first, __last,
298 template<
typename _Tp,
typename _Alloc>
299 template<
typename _ForwardIterator>
301 vector<_Tp, _Alloc>::
302 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
307 if (__len > capacity())
309 _S_check_init_len(__len, _M_get_Tp_allocator());
310 pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
311 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
312 _M_get_Tp_allocator());
313 _GLIBCXX_ASAN_ANNOTATE_REINIT;
314 _M_deallocate(this->_M_impl._M_start,
315 this->_M_impl._M_end_of_storage
316 - this->_M_impl._M_start);
317 this->_M_impl._M_start = __tmp;
318 this->_M_impl._M_finish = this->_M_impl._M_start + __len;
319 this->_M_impl._M_end_of_storage = this->_M_impl._M_finish;
321 else if (size() >= __len)
322 _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start));
325 _ForwardIterator __mid = __first;
327 std::copy(__first, __mid, this->_M_impl._M_start);
328 const size_type __attribute__((__unused__)) __n = __len - size();
329 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
330 this->_M_impl._M_finish =
331 std::__uninitialized_copy_a(__mid, __last,
332 this->_M_impl._M_finish,
333 _M_get_Tp_allocator());
334 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
338 #if __cplusplus >= 201103L 339 template<
typename _Tp,
typename _Alloc>
341 vector<_Tp, _Alloc>::
342 _M_insert_rval(const_iterator __position, value_type&& __v) -> iterator
344 const auto __n = __position -
cbegin();
345 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
346 if (__position ==
cend())
348 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
349 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
351 ++this->_M_impl._M_finish;
352 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
355 _M_insert_aux(
begin() + __n, std::move(__v));
357 _M_realloc_insert(
begin() + __n, std::move(__v));
359 return iterator(this->_M_impl._M_start + __n);
362 template<
typename _Tp,
typename _Alloc>
363 template<
typename... _Args>
365 vector<_Tp, _Alloc>::
366 _M_emplace_aux(const_iterator __position, _Args&&... __args)
369 const auto __n = __position -
cbegin();
370 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
371 if (__position ==
cend())
373 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
374 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
375 std::forward<_Args>(__args)...);
376 ++this->_M_impl._M_finish;
377 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
384 _Temporary_value __tmp(
this, std::forward<_Args>(__args)...);
385 _M_insert_aux(
begin() + __n, std::move(__tmp._M_val()));
388 _M_realloc_insert(
begin() + __n, std::forward<_Args>(__args)...);
390 return iterator(this->_M_impl._M_start + __n);
393 template<
typename _Tp,
typename _Alloc>
394 template<
typename _Arg>
396 vector<_Tp, _Alloc>::
397 _M_insert_aux(iterator __position, _Arg&& __arg)
399 template<
typename _Tp,
typename _Alloc>
401 vector<_Tp, _Alloc>::
402 _M_insert_aux(iterator __position,
const _Tp& __x)
405 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
406 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
407 _GLIBCXX_MOVE(*(this->_M_impl._M_finish - 1)));
408 ++this->_M_impl._M_finish;
409 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
410 #if __cplusplus < 201103L 413 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
414 this->_M_impl._M_finish - 2,
415 this->_M_impl._M_finish - 1);
416 #if __cplusplus < 201103L 417 *__position = __x_copy;
419 *__position = std::forward<_Arg>(__arg);
423 #if __cplusplus >= 201103L 424 template<
typename _Tp,
typename _Alloc>
425 template<
typename... _Args>
427 vector<_Tp, _Alloc>::
428 _M_realloc_insert(iterator __position, _Args&&... __args)
430 template<
typename _Tp,
typename _Alloc>
432 vector<_Tp, _Alloc>::
433 _M_realloc_insert(iterator __position,
const _Tp& __x)
436 const size_type __len =
437 _M_check_len(size_type(1),
"vector::_M_realloc_insert");
438 pointer __old_start = this->_M_impl._M_start;
439 pointer __old_finish = this->_M_impl._M_finish;
440 const size_type __elems_before = __position -
begin();
441 pointer __new_start(this->_M_allocate(__len));
442 pointer __new_finish(__new_start);
450 _Alloc_traits::construct(this->_M_impl,
451 __new_start + __elems_before,
452 #
if __cplusplus >= 201103L
453 std::forward<_Args>(__args)...);
457 __new_finish = pointer();
459 #if __cplusplus >= 201103L 460 if constexpr (_S_use_relocate())
464 (__old_start, __position.base(),
465 __new_start, _M_get_Tp_allocator());
471 (__position.base(), __old_finish,
472 __new_finish, _M_get_Tp_allocator());
478 = std::__uninitialized_move_if_noexcept_a
479 (__old_start, __position.base(),
480 __new_start, _M_get_Tp_allocator());
485 = std::__uninitialized_move_if_noexcept_a
486 (__position.base(), __old_finish,
487 __new_finish, _M_get_Tp_allocator());
493 _Alloc_traits::destroy(this->_M_impl,
494 __new_start + __elems_before);
496 std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
497 _M_deallocate(__new_start, __len);
498 __throw_exception_again;
500 #if __cplusplus >= 201103L 501 if constexpr (!_S_use_relocate())
503 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
504 _GLIBCXX_ASAN_ANNOTATE_REINIT;
505 _M_deallocate(__old_start,
506 this->_M_impl._M_end_of_storage - __old_start);
507 this->_M_impl._M_start = __new_start;
508 this->_M_impl._M_finish = __new_finish;
509 this->_M_impl._M_end_of_storage = __new_start + __len;
512 template<
typename _Tp,
typename _Alloc>
514 vector<_Tp, _Alloc>::
515 _M_fill_insert(iterator __position, size_type __n,
const value_type& __x)
519 if (size_type(this->_M_impl._M_end_of_storage
520 - this->_M_impl._M_finish) >= __n)
522 #if __cplusplus < 201103L 523 value_type __x_copy = __x;
525 _Temporary_value __tmp(
this, __x);
526 value_type& __x_copy = __tmp._M_val();
528 const size_type __elems_after =
end() - __position;
529 pointer __old_finish(this->_M_impl._M_finish);
530 if (__elems_after > __n)
532 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
533 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
534 this->_M_impl._M_finish,
535 this->_M_impl._M_finish,
536 _M_get_Tp_allocator());
537 this->_M_impl._M_finish += __n;
538 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
539 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
540 __old_finish - __n, __old_finish);
541 std::fill(__position.base(), __position.base() + __n,
546 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
547 this->_M_impl._M_finish =
548 std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
551 _M_get_Tp_allocator());
552 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
553 std::__uninitialized_move_a(__position.base(), __old_finish,
554 this->_M_impl._M_finish,
555 _M_get_Tp_allocator());
556 this->_M_impl._M_finish += __elems_after;
557 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
558 std::fill(__position.base(), __old_finish, __x_copy);
563 const size_type __len =
564 _M_check_len(__n,
"vector::_M_fill_insert");
565 const size_type __elems_before = __position -
begin();
566 pointer __new_start(this->_M_allocate(__len));
567 pointer __new_finish(__new_start);
571 std::__uninitialized_fill_n_a(__new_start + __elems_before,
573 _M_get_Tp_allocator());
574 __new_finish = pointer();
577 = std::__uninitialized_move_if_noexcept_a
578 (this->_M_impl._M_start, __position.base(),
579 __new_start, _M_get_Tp_allocator());
584 = std::__uninitialized_move_if_noexcept_a
585 (__position.base(), this->_M_impl._M_finish,
586 __new_finish, _M_get_Tp_allocator());
592 __new_start + __elems_before + __n,
593 _M_get_Tp_allocator());
596 _M_get_Tp_allocator());
597 _M_deallocate(__new_start, __len);
598 __throw_exception_again;
600 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
601 _M_get_Tp_allocator());
602 _GLIBCXX_ASAN_ANNOTATE_REINIT;
603 _M_deallocate(this->_M_impl._M_start,
604 this->_M_impl._M_end_of_storage
605 - this->_M_impl._M_start);
606 this->_M_impl._M_start = __new_start;
607 this->_M_impl._M_finish = __new_finish;
608 this->_M_impl._M_end_of_storage = __new_start + __len;
613 #if __cplusplus >= 201103L 614 template<
typename _Tp,
typename _Alloc>
616 vector<_Tp, _Alloc>::
617 _M_default_append(size_type __n)
621 const size_type __size = size();
622 size_type __navail = size_type(this->_M_impl._M_end_of_storage
623 - this->_M_impl._M_finish);
625 if (__size > max_size() || __navail > max_size() - __size)
626 __builtin_unreachable();
630 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
631 this->_M_impl._M_finish =
632 std::__uninitialized_default_n_a(this->_M_impl._M_finish,
633 __n, _M_get_Tp_allocator());
634 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
638 const size_type __len =
639 _M_check_len(__n,
"vector::_M_default_append");
640 pointer __new_start(this->_M_allocate(__len));
641 #if __cplusplus >= 201103L 642 if constexpr (_S_use_relocate())
646 std::__uninitialized_default_n_a(__new_start + __size,
647 __n, _M_get_Tp_allocator());
651 _M_deallocate(__new_start, __len);
652 __throw_exception_again;
654 std::__relocate_a(this->_M_impl._M_start,
655 this->_M_impl._M_finish,
656 __new_start, _M_get_Tp_allocator());
661 pointer __destroy_from = pointer();
664 std::__uninitialized_default_n_a(__new_start + __size,
665 __n, _M_get_Tp_allocator());
666 __destroy_from = __new_start + __size;
667 std::__uninitialized_move_if_noexcept_a(
668 this->_M_impl._M_start, this->_M_impl._M_finish,
669 __new_start, _M_get_Tp_allocator());
675 _M_get_Tp_allocator());
676 _M_deallocate(__new_start, __len);
677 __throw_exception_again;
679 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
680 _M_get_Tp_allocator());
682 _GLIBCXX_ASAN_ANNOTATE_REINIT;
683 _M_deallocate(this->_M_impl._M_start,
684 this->_M_impl._M_end_of_storage
685 - this->_M_impl._M_start);
686 this->_M_impl._M_start = __new_start;
687 this->_M_impl._M_finish = __new_start + __size + __n;
688 this->_M_impl._M_end_of_storage = __new_start + __len;
693 template<
typename _Tp,
typename _Alloc>
695 vector<_Tp, _Alloc>::
698 if (capacity() == size())
700 _GLIBCXX_ASAN_ANNOTATE_REINIT;
701 return std::__shrink_to_fit_aux<vector>::_S_do_it(*
this);
705 template<
typename _Tp,
typename _Alloc>
706 template<
typename _InputIterator>
708 vector<_Tp, _Alloc>::
709 _M_range_insert(iterator __pos, _InputIterator __first,
714 for (; __first != __last; ++__first)
715 insert(
end(), *__first);
717 else if (__first != __last)
719 vector __tmp(__first, __last, _M_get_Tp_allocator());
721 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()),
722 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end()));
726 template<
typename _Tp,
typename _Alloc>
727 template<
typename _ForwardIterator>
729 vector<_Tp, _Alloc>::
730 _M_range_insert(iterator __position, _ForwardIterator __first,
733 if (__first != __last)
736 if (size_type(this->_M_impl._M_end_of_storage
737 - this->_M_impl._M_finish) >= __n)
739 const size_type __elems_after =
end() - __position;
740 pointer __old_finish(this->_M_impl._M_finish);
741 if (__elems_after > __n)
743 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
744 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
745 this->_M_impl._M_finish,
746 this->_M_impl._M_finish,
747 _M_get_Tp_allocator());
748 this->_M_impl._M_finish += __n;
749 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
750 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
751 __old_finish - __n, __old_finish);
752 std::copy(__first, __last, __position);
756 _ForwardIterator __mid = __first;
758 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
759 std::__uninitialized_copy_a(__mid, __last,
760 this->_M_impl._M_finish,
761 _M_get_Tp_allocator());
762 this->_M_impl._M_finish += __n - __elems_after;
763 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
764 std::__uninitialized_move_a(__position.base(),
766 this->_M_impl._M_finish,
767 _M_get_Tp_allocator());
768 this->_M_impl._M_finish += __elems_after;
769 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
770 std::copy(__first, __mid, __position);
775 const size_type __len =
776 _M_check_len(__n,
"vector::_M_range_insert");
777 pointer __new_start(this->_M_allocate(__len));
778 pointer __new_finish(__new_start);
782 = std::__uninitialized_move_if_noexcept_a
783 (this->_M_impl._M_start, __position.base(),
784 __new_start, _M_get_Tp_allocator());
786 = std::__uninitialized_copy_a(__first, __last,
788 _M_get_Tp_allocator());
790 = std::__uninitialized_move_if_noexcept_a
791 (__position.base(), this->_M_impl._M_finish,
792 __new_finish, _M_get_Tp_allocator());
797 _M_get_Tp_allocator());
798 _M_deallocate(__new_start, __len);
799 __throw_exception_again;
801 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
802 _M_get_Tp_allocator());
803 _GLIBCXX_ASAN_ANNOTATE_REINIT;
804 _M_deallocate(this->_M_impl._M_start,
805 this->_M_impl._M_end_of_storage
806 - this->_M_impl._M_start);
807 this->_M_impl._M_start = __new_start;
808 this->_M_impl._M_finish = __new_finish;
809 this->_M_impl._M_end_of_storage = __new_start + __len;
816 template<
typename _Alloc>
818 vector<bool, _Alloc>::
819 _M_reallocate(size_type __n)
821 _Bit_pointer __q = this->_M_allocate(__n);
823 iterator __finish(_M_copy_aligned(
begin(),
end(), __start));
824 this->_M_deallocate();
825 this->_M_impl._M_start = __start;
826 this->_M_impl._M_finish = __finish;
827 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
830 template<
typename _Alloc>
832 vector<bool, _Alloc>::
833 _M_fill_insert(iterator __position, size_type __n,
bool __x)
839 std::copy_backward(__position,
end(),
840 this->_M_impl._M_finish + difference_type(__n));
841 std::fill(__position, __position + difference_type(__n), __x);
842 this->_M_impl._M_finish += difference_type(__n);
846 const size_type __len =
847 _M_check_len(__n,
"vector<bool>::_M_fill_insert");
848 _Bit_pointer __q = this->_M_allocate(__len);
850 iterator __i = _M_copy_aligned(
begin(), __position, __start);
851 std::fill(__i, __i + difference_type(__n), __x);
852 iterator __finish = std::copy(__position,
end(),
853 __i + difference_type(__n));
854 this->_M_deallocate();
855 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
856 this->_M_impl._M_start = __start;
857 this->_M_impl._M_finish = __finish;
861 template<
typename _Alloc>
862 template<
typename _ForwardIterator>
864 vector<bool, _Alloc>::
865 _M_insert_range(iterator __position, _ForwardIterator __first,
868 if (__first != __last)
873 std::copy_backward(__position,
end(),
874 this->_M_impl._M_finish
875 + difference_type(__n));
876 std::copy(__first, __last, __position);
877 this->_M_impl._M_finish += difference_type(__n);
881 const size_type __len =
882 _M_check_len(__n,
"vector<bool>::_M_insert_range");
883 _Bit_pointer __q = this->_M_allocate(__len);
885 iterator __i = _M_copy_aligned(
begin(), __position, __start);
886 __i = std::copy(__first, __last, __i);
887 iterator __finish = std::copy(__position,
end(), __i);
888 this->_M_deallocate();
889 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
890 this->_M_impl._M_start = __start;
891 this->_M_impl._M_finish = __finish;
896 template<
typename _Alloc>
898 vector<bool, _Alloc>::
899 _M_insert_aux(iterator __position,
bool __x)
901 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
903 std::copy_backward(__position, this->_M_impl._M_finish,
904 this->_M_impl._M_finish + 1);
906 ++this->_M_impl._M_finish;
910 const size_type __len =
911 _M_check_len(size_type(1),
"vector<bool>::_M_insert_aux");
912 _Bit_pointer __q = this->_M_allocate(__len);
914 iterator __i = _M_copy_aligned(
begin(), __position, __start);
916 iterator __finish = std::copy(__position,
end(), __i);
917 this->_M_deallocate();
918 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
919 this->_M_impl._M_start = __start;
920 this->_M_impl._M_finish = __finish;
924 template<
typename _Alloc>
925 typename vector<bool, _Alloc>::iterator
926 vector<bool, _Alloc>::
927 _M_erase(iterator __position)
929 if (__position + 1 !=
end())
930 std::copy(__position + 1,
end(), __position);
931 --this->_M_impl._M_finish;
935 template<
typename _Alloc>
936 typename vector<bool, _Alloc>::iterator
937 vector<bool, _Alloc>::
938 _M_erase(iterator __first, iterator __last)
940 if (__first != __last)
941 _M_erase_at_end(std::copy(__last,
end(), __first));
945 #if __cplusplus >= 201103L 946 template<
typename _Alloc>
948 vector<bool, _Alloc>::
955 _M_reallocate(
size());
963 _GLIBCXX_END_NAMESPACE_CONTAINER
964 _GLIBCXX_END_NAMESPACE_VERSION
967 #if __cplusplus >= 201103L 969 namespace std _GLIBCXX_VISIBILITY(default)
971 _GLIBCXX_BEGIN_NAMESPACE_VERSION
973 template<
typename _Alloc>
975 hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
976 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b)
const noexcept
979 using _GLIBCXX_STD_C::_S_word_bit;
980 using _GLIBCXX_STD_C::_Bit_type;
982 const size_t __words = __b.size() / _S_word_bit;
985 const size_t __clength = __words *
sizeof(_Bit_type);
986 __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
989 const size_t __extrabits = __b.size() % _S_word_bit;
992 _Bit_type __hiword = *__b._M_impl._M_finish._M_p;
993 __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits);
995 const size_t __clength
996 = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__;
998 __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
1000 __hash = std::_Hash_impl::hash(&__hiword, __clength);
1006 _GLIBCXX_END_NAMESPACE_VERSION
1011 #undef _GLIBCXX_ASAN_ANNOTATE_REINIT 1012 #undef _GLIBCXX_ASAN_ANNOTATE_GROW 1013 #undef _GLIBCXX_ASAN_ANNOTATE_GREW 1014 #undef _GLIBCXX_ASAN_ANNOTATE_SHRINK
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.
iterator begin() 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.
constexpr const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
ISO C++ entities toplevel namespace is std.
void _Destroy(_Tp *__pointer)
_GLIBCXX17_CONSTEXPR iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
size_type size() const noexcept
_GLIBCXX17_CONSTEXPR void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
size_type capacity() const noexcept
void reserve(size_type __n)
Attempt to preallocate enough memory for specified number of elements.
Forward iterators support a superset of input iterator operations.
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.
A standard container which offers fixed time access to individual elements in any order.