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 _GLIBCXX17_CONSTEXPR (_S_use_relocate())
78 __tmp = this->_M_allocate(__n);
79 _S_relocate(this->_M_impl._M_start, this->_M_impl._M_finish,
80 __tmp, _M_get_Tp_allocator());
85 __tmp = _M_allocate_and_copy(__n,
86 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_start),
87 _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_finish));
88 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
89 _M_get_Tp_allocator());
91 _GLIBCXX_ASAN_ANNOTATE_REINIT;
92 _M_deallocate(this->_M_impl._M_start,
93 this->_M_impl._M_end_of_storage
94 - this->_M_impl._M_start);
95 this->_M_impl._M_start = __tmp;
96 this->_M_impl._M_finish = __tmp + __old_size;
97 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
101 #if __cplusplus >= 201103L
102 template<
typename _Tp,
typename _Alloc>
103 template<
typename... _Args>
104 #if __cplusplus > 201402L
105 typename vector<_Tp, _Alloc>::reference
112 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
114 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
115 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
116 std::forward<_Args>(__args)...);
117 ++this->_M_impl._M_finish;
118 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
121 _M_realloc_insert(
end(), std::forward<_Args>(__args)...);
122 #if __cplusplus > 201402L
128 template<
typename _Tp,
typename _Alloc>
129 typename vector<_Tp, _Alloc>::iterator
131 #if __cplusplus >= 201103L
132 insert(const_iterator __position,
const value_type& __x)
134 insert(iterator __position,
const value_type& __x)
137 const size_type __n = __position -
begin();
138 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
139 if (__position ==
end())
141 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
142 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
144 ++this->_M_impl._M_finish;
145 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
149 #if __cplusplus >= 201103L
150 const auto __pos =
begin() + (__position -
cbegin());
153 _Temporary_value __x_copy(
this, __x);
154 _M_insert_aux(__pos,
std::move(__x_copy._M_val()));
156 _M_insert_aux(__position, __x);
160 #if __cplusplus >= 201103L
161 _M_realloc_insert(
begin() + (__position -
cbegin()), __x);
163 _M_realloc_insert(__position, __x);
166 return iterator(this->_M_impl._M_start + __n);
169 template<
typename _Tp,
typename _Alloc>
170 typename vector<_Tp, _Alloc>::iterator
174 if (__position + 1 !=
end())
175 _GLIBCXX_MOVE3(__position + 1,
end(), __position);
176 --this->_M_impl._M_finish;
177 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
178 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
182 template<
typename _Tp,
typename _Alloc>
183 typename vector<_Tp, _Alloc>::iterator
184 vector<_Tp, _Alloc>::
185 _M_erase(iterator __first, iterator __last)
187 if (__first != __last)
190 _GLIBCXX_MOVE3(__last,
end(), __first);
191 _M_erase_at_end(__first.base() + (
end() - __last));
196 template<
typename _Tp,
typename _Alloc>
203 _GLIBCXX_ASAN_ANNOTATE_REINIT;
204 #if __cplusplus >= 201103L
205 if (_Alloc_traits::_S_propagate_on_copy_assign())
207 if (!_Alloc_traits::_S_always_equal()
208 && _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
212 _M_deallocate(this->_M_impl._M_start,
213 this->_M_impl._M_end_of_storage
214 - this->_M_impl._M_start);
215 this->_M_impl._M_start =
nullptr;
216 this->_M_impl._M_finish =
nullptr;
217 this->_M_impl._M_end_of_storage =
nullptr;
219 std::__alloc_on_copy(_M_get_Tp_allocator(),
220 __x._M_get_Tp_allocator());
223 const size_type __xlen = __x.
size();
224 if (__xlen > capacity())
226 pointer __tmp = _M_allocate_and_copy(__xlen, __x.
begin(),
228 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
229 _M_get_Tp_allocator());
230 _M_deallocate(this->_M_impl._M_start,
231 this->_M_impl._M_end_of_storage
232 - this->_M_impl._M_start);
233 this->_M_impl._M_start = __tmp;
234 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen;
236 else if (size() >= __xlen)
239 end(), _M_get_Tp_allocator());
243 std::copy(__x._M_impl._M_start, __x._M_impl._M_start + size(),
244 this->_M_impl._M_start);
245 std::__uninitialized_copy_a(__x._M_impl._M_start + size(),
246 __x._M_impl._M_finish,
247 this->_M_impl._M_finish,
248 _M_get_Tp_allocator());
250 this->_M_impl._M_finish = this->_M_impl._M_start + __xlen;
255 template<
typename _Tp,
typename _Alloc>
260 if (__n > capacity())
262 vector __tmp(__n, __val, _M_get_Tp_allocator());
263 __tmp._M_impl._M_swap_data(this->_M_impl);
265 else if (__n > size())
268 const size_type __add = __n - size();
269 _GLIBCXX_ASAN_ANNOTATE_GROW(__add);
270 this->_M_impl._M_finish =
271 std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
272 __add, __val, _M_get_Tp_allocator());
273 _GLIBCXX_ASAN_ANNOTATE_GREW(__add);
276 _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val));
279 template<
typename _Tp,
typename _Alloc>
280 template<
typename _InputIterator>
282 vector<_Tp, _Alloc>::
283 _M_assign_aux(_InputIterator __first, _InputIterator __last,
286 pointer __cur(this->_M_impl._M_start);
287 for (; __first != __last && __cur != this->_M_impl._M_finish;
288 ++__cur, (void)++__first)
290 if (__first == __last)
291 _M_erase_at_end(__cur);
293 _M_range_insert(
end(), __first, __last,
297 template<
typename _Tp,
typename _Alloc>
298 template<
typename _ForwardIterator>
300 vector<_Tp, _Alloc>::
301 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
306 if (__len > capacity())
308 _S_check_init_len(__len, _M_get_Tp_allocator());
309 pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
310 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
311 _M_get_Tp_allocator());
312 _GLIBCXX_ASAN_ANNOTATE_REINIT;
313 _M_deallocate(this->_M_impl._M_start,
314 this->_M_impl._M_end_of_storage
315 - this->_M_impl._M_start);
316 this->_M_impl._M_start = __tmp;
317 this->_M_impl._M_finish = this->_M_impl._M_start + __len;
318 this->_M_impl._M_end_of_storage = this->_M_impl._M_finish;
320 else if (size() >= __len)
321 _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start));
324 _ForwardIterator __mid = __first;
326 std::copy(__first, __mid, this->_M_impl._M_start);
327 const size_type __attribute__((__unused__)) __n = __len - size();
328 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
329 this->_M_impl._M_finish =
330 std::__uninitialized_copy_a(__mid, __last,
331 this->_M_impl._M_finish,
332 _M_get_Tp_allocator());
333 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
337 #if __cplusplus >= 201103L
338 template<
typename _Tp,
typename _Alloc>
340 vector<_Tp, _Alloc>::
341 _M_insert_rval(const_iterator __position, value_type&& __v) -> iterator
343 const auto __n = __position -
cbegin();
344 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
345 if (__position ==
cend())
347 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
348 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
350 ++this->_M_impl._M_finish;
351 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
358 return iterator(this->_M_impl._M_start + __n);
361 template<
typename _Tp,
typename _Alloc>
362 template<
typename... _Args>
364 vector<_Tp, _Alloc>::
365 _M_emplace_aux(const_iterator __position, _Args&&... __args)
368 const auto __n = __position -
cbegin();
369 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
370 if (__position ==
cend())
372 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
373 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
374 std::forward<_Args>(__args)...);
375 ++this->_M_impl._M_finish;
376 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
383 _Temporary_value __tmp(
this, std::forward<_Args>(__args)...);
387 _M_realloc_insert(
begin() + __n, std::forward<_Args>(__args)...);
389 return iterator(this->_M_impl._M_start + __n);
392 template<
typename _Tp,
typename _Alloc>
393 template<
typename _Arg>
395 vector<_Tp, _Alloc>::
396 _M_insert_aux(iterator __position, _Arg&& __arg)
398 template<
typename _Tp,
typename _Alloc>
400 vector<_Tp, _Alloc>::
401 _M_insert_aux(iterator __position,
const _Tp& __x)
404 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
405 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
406 _GLIBCXX_MOVE(*(this->_M_impl._M_finish - 1)));
407 ++this->_M_impl._M_finish;
408 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
409 #if __cplusplus < 201103L
412 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
413 this->_M_impl._M_finish - 2,
414 this->_M_impl._M_finish - 1);
415 #if __cplusplus < 201103L
416 *__position = __x_copy;
418 *__position = std::forward<_Arg>(__arg);
422 #if __cplusplus >= 201103L
423 template<
typename _Tp,
typename _Alloc>
424 template<
typename... _Args>
426 vector<_Tp, _Alloc>::
427 _M_realloc_insert(iterator __position, _Args&&... __args)
429 template<
typename _Tp,
typename _Alloc>
431 vector<_Tp, _Alloc>::
432 _M_realloc_insert(iterator __position,
const _Tp& __x)
435 const size_type __len =
436 _M_check_len(size_type(1),
"vector::_M_realloc_insert");
437 pointer __old_start = this->_M_impl._M_start;
438 pointer __old_finish = this->_M_impl._M_finish;
439 const size_type __elems_before = __position -
begin();
440 pointer __new_start(this->_M_allocate(__len));
441 pointer __new_finish(__new_start);
449 _Alloc_traits::construct(this->_M_impl,
450 __new_start + __elems_before,
451 #
if __cplusplus >= 201103L
452 std::forward<_Args>(__args)...);
456 __new_finish = pointer();
458 #if __cplusplus >= 201103L
459 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
461 __new_finish = _S_relocate(__old_start, __position.base(),
462 __new_start, _M_get_Tp_allocator());
466 __new_finish = _S_relocate(__position.base(), __old_finish,
467 __new_finish, _M_get_Tp_allocator());
473 = std::__uninitialized_move_if_noexcept_a
474 (__old_start, __position.base(),
475 __new_start, _M_get_Tp_allocator());
480 = std::__uninitialized_move_if_noexcept_a
481 (__position.base(), __old_finish,
482 __new_finish, _M_get_Tp_allocator());
488 _Alloc_traits::destroy(this->_M_impl,
489 __new_start + __elems_before);
491 std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
492 _M_deallocate(__new_start, __len);
493 __throw_exception_again;
495 #if __cplusplus >= 201103L
496 if _GLIBCXX17_CONSTEXPR (!_S_use_relocate())
498 std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
499 _GLIBCXX_ASAN_ANNOTATE_REINIT;
500 _M_deallocate(__old_start,
501 this->_M_impl._M_end_of_storage - __old_start);
502 this->_M_impl._M_start = __new_start;
503 this->_M_impl._M_finish = __new_finish;
504 this->_M_impl._M_end_of_storage = __new_start + __len;
507 template<
typename _Tp,
typename _Alloc>
509 vector<_Tp, _Alloc>::
510 _M_fill_insert(iterator __position, size_type __n,
const value_type& __x)
514 if (size_type(this->_M_impl._M_end_of_storage
515 - this->_M_impl._M_finish) >= __n)
517 #if __cplusplus < 201103L
518 value_type __x_copy = __x;
520 _Temporary_value __tmp(
this, __x);
521 value_type& __x_copy = __tmp._M_val();
523 const size_type __elems_after =
end() - __position;
524 pointer __old_finish(this->_M_impl._M_finish);
525 if (__elems_after > __n)
527 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
528 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
529 this->_M_impl._M_finish,
530 this->_M_impl._M_finish,
531 _M_get_Tp_allocator());
532 this->_M_impl._M_finish += __n;
533 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
534 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
535 __old_finish - __n, __old_finish);
536 std::fill(__position.base(), __position.base() + __n,
541 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
542 this->_M_impl._M_finish =
543 std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
546 _M_get_Tp_allocator());
547 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
548 std::__uninitialized_move_a(__position.base(), __old_finish,
549 this->_M_impl._M_finish,
550 _M_get_Tp_allocator());
551 this->_M_impl._M_finish += __elems_after;
552 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
553 std::fill(__position.base(), __old_finish, __x_copy);
558 const size_type __len =
559 _M_check_len(__n,
"vector::_M_fill_insert");
560 const size_type __elems_before = __position -
begin();
561 pointer __new_start(this->_M_allocate(__len));
562 pointer __new_finish(__new_start);
566 std::__uninitialized_fill_n_a(__new_start + __elems_before,
568 _M_get_Tp_allocator());
569 __new_finish = pointer();
572 = std::__uninitialized_move_if_noexcept_a
573 (this->_M_impl._M_start, __position.base(),
574 __new_start, _M_get_Tp_allocator());
579 = std::__uninitialized_move_if_noexcept_a
580 (__position.base(), this->_M_impl._M_finish,
581 __new_finish, _M_get_Tp_allocator());
587 __new_start + __elems_before + __n,
588 _M_get_Tp_allocator());
591 _M_get_Tp_allocator());
592 _M_deallocate(__new_start, __len);
593 __throw_exception_again;
595 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
596 _M_get_Tp_allocator());
597 _GLIBCXX_ASAN_ANNOTATE_REINIT;
598 _M_deallocate(this->_M_impl._M_start,
599 this->_M_impl._M_end_of_storage
600 - this->_M_impl._M_start);
601 this->_M_impl._M_start = __new_start;
602 this->_M_impl._M_finish = __new_finish;
603 this->_M_impl._M_end_of_storage = __new_start + __len;
608 #if __cplusplus >= 201103L
609 template<
typename _Tp,
typename _Alloc>
611 vector<_Tp, _Alloc>::
612 _M_default_append(size_type __n)
616 const size_type __size = size();
617 size_type __navail = size_type(this->_M_impl._M_end_of_storage
618 - this->_M_impl._M_finish);
620 if (__size > max_size() || __navail > max_size() - __size)
621 __builtin_unreachable();
625 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
626 this->_M_impl._M_finish =
627 std::__uninitialized_default_n_a(this->_M_impl._M_finish,
628 __n, _M_get_Tp_allocator());
629 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
633 const size_type __len =
634 _M_check_len(__n,
"vector::_M_default_append");
635 pointer __new_start(this->_M_allocate(__len));
636 if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
640 std::__uninitialized_default_n_a(__new_start + __size,
641 __n, _M_get_Tp_allocator());
645 _M_deallocate(__new_start, __len);
646 __throw_exception_again;
648 _S_relocate(this->_M_impl._M_start, this->_M_impl._M_finish,
649 __new_start, _M_get_Tp_allocator());
653 pointer __destroy_from = pointer();
656 std::__uninitialized_default_n_a(__new_start + __size,
657 __n, _M_get_Tp_allocator());
658 __destroy_from = __new_start + __size;
659 std::__uninitialized_move_if_noexcept_a(
660 this->_M_impl._M_start, this->_M_impl._M_finish,
661 __new_start, _M_get_Tp_allocator());
667 _M_get_Tp_allocator());
668 _M_deallocate(__new_start, __len);
669 __throw_exception_again;
671 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
672 _M_get_Tp_allocator());
674 _GLIBCXX_ASAN_ANNOTATE_REINIT;
675 _M_deallocate(this->_M_impl._M_start,
676 this->_M_impl._M_end_of_storage
677 - this->_M_impl._M_start);
678 this->_M_impl._M_start = __new_start;
679 this->_M_impl._M_finish = __new_start + __size + __n;
680 this->_M_impl._M_end_of_storage = __new_start + __len;
685 template<
typename _Tp,
typename _Alloc>
687 vector<_Tp, _Alloc>::
690 if (capacity() == size())
692 _GLIBCXX_ASAN_ANNOTATE_REINIT;
693 return std::__shrink_to_fit_aux<vector>::_S_do_it(*
this);
697 template<
typename _Tp,
typename _Alloc>
698 template<
typename _InputIterator>
706 for (; __first != __last; ++__first)
707 insert(
end(), *__first);
709 else if (__first != __last)
711 vector __tmp(__first, __last, _M_get_Tp_allocator());
713 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.
begin()),
714 _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.
end()));
718 template<
typename _Tp,
typename _Alloc>
719 template<
typename _ForwardIterator>
725 if (__first != __last)
728 if (size_type(this->_M_impl._M_end_of_storage
729 - this->_M_impl._M_finish) >= __n)
731 const size_type __elems_after =
end() - __position;
732 pointer __old_finish(this->_M_impl._M_finish);
733 if (__elems_after > __n)
735 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
736 std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
737 this->_M_impl._M_finish,
738 this->_M_impl._M_finish,
739 _M_get_Tp_allocator());
740 this->_M_impl._M_finish += __n;
741 _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
742 _GLIBCXX_MOVE_BACKWARD3(__position.base(),
743 __old_finish - __n, __old_finish);
744 std::copy(__first, __last, __position);
748 _ForwardIterator __mid = __first;
750 _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
751 std::__uninitialized_copy_a(__mid, __last,
752 this->_M_impl._M_finish,
753 _M_get_Tp_allocator());
754 this->_M_impl._M_finish += __n - __elems_after;
755 _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
756 std::__uninitialized_move_a(__position.base(),
758 this->_M_impl._M_finish,
759 _M_get_Tp_allocator());
760 this->_M_impl._M_finish += __elems_after;
761 _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
762 std::copy(__first, __mid, __position);
767 const size_type __len =
768 _M_check_len(__n,
"vector::_M_range_insert");
769 pointer __new_start(this->_M_allocate(__len));
770 pointer __new_finish(__new_start);
774 = std::__uninitialized_move_if_noexcept_a
775 (this->_M_impl._M_start, __position.base(),
776 __new_start, _M_get_Tp_allocator());
778 = std::__uninitialized_copy_a(__first, __last,
780 _M_get_Tp_allocator());
782 = std::__uninitialized_move_if_noexcept_a
783 (__position.base(), this->_M_impl._M_finish,
784 __new_finish, _M_get_Tp_allocator());
789 _M_get_Tp_allocator());
790 _M_deallocate(__new_start, __len);
791 __throw_exception_again;
793 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
794 _M_get_Tp_allocator());
795 _GLIBCXX_ASAN_ANNOTATE_REINIT;
796 _M_deallocate(this->_M_impl._M_start,
797 this->_M_impl._M_end_of_storage
798 - this->_M_impl._M_start);
799 this->_M_impl._M_start = __new_start;
800 this->_M_impl._M_finish = __new_finish;
801 this->_M_impl._M_end_of_storage = __new_start + __len;
808 template<
typename _Alloc>
810 vector<bool, _Alloc>::
811 _M_reallocate(size_type __n)
813 _Bit_pointer __q = this->_M_allocate(__n);
815 iterator __finish(_M_copy_aligned(
begin(),
end(), __start));
816 this->_M_deallocate();
817 this->_M_impl._M_start = __start;
818 this->_M_impl._M_finish = __finish;
819 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
822 template<
typename _Alloc>
824 vector<bool, _Alloc>::
825 _M_fill_insert(iterator __position, size_type __n,
bool __x)
831 std::copy_backward(__position,
end(),
832 this->_M_impl._M_finish + difference_type(__n));
833 std::fill(__position, __position + difference_type(__n), __x);
834 this->_M_impl._M_finish += difference_type(__n);
838 const size_type __len =
839 _M_check_len(__n,
"vector<bool>::_M_fill_insert");
840 _Bit_pointer __q = this->_M_allocate(__len);
842 iterator __i = _M_copy_aligned(
begin(), __position, __start);
843 std::fill(__i, __i + difference_type(__n), __x);
844 iterator __finish = std::copy(__position,
end(),
845 __i + difference_type(__n));
846 this->_M_deallocate();
847 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
848 this->_M_impl._M_start = __start;
849 this->_M_impl._M_finish = __finish;
853 template<
typename _Alloc>
854 template<
typename _ForwardIterator>
856 vector<bool, _Alloc>::
857 _M_insert_range(iterator __position, _ForwardIterator __first,
860 if (__first != __last)
865 std::copy_backward(__position,
end(),
866 this->_M_impl._M_finish
867 + difference_type(__n));
868 std::copy(__first, __last, __position);
869 this->_M_impl._M_finish += difference_type(__n);
873 const size_type __len =
874 _M_check_len(__n,
"vector<bool>::_M_insert_range");
875 _Bit_pointer __q = this->_M_allocate(__len);
877 iterator __i = _M_copy_aligned(
begin(), __position, __start);
878 __i = std::copy(__first, __last, __i);
879 iterator __finish = std::copy(__position,
end(), __i);
880 this->_M_deallocate();
881 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
882 this->_M_impl._M_start = __start;
883 this->_M_impl._M_finish = __finish;
888 template<
typename _Alloc>
890 vector<bool, _Alloc>::
891 _M_insert_aux(iterator __position,
bool __x)
893 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
895 std::copy_backward(__position, this->_M_impl._M_finish,
896 this->_M_impl._M_finish + 1);
898 ++this->_M_impl._M_finish;
902 const size_type __len =
903 _M_check_len(size_type(1),
"vector<bool>::_M_insert_aux");
904 _Bit_pointer __q = this->_M_allocate(__len);
906 iterator __i = _M_copy_aligned(
begin(), __position, __start);
908 iterator __finish = std::copy(__position,
end(), __i);
909 this->_M_deallocate();
910 this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
911 this->_M_impl._M_start = __start;
912 this->_M_impl._M_finish = __finish;
916 template<
typename _Alloc>
917 typename vector<bool, _Alloc>::iterator
918 vector<bool, _Alloc>::
919 _M_erase(iterator __position)
921 if (__position + 1 !=
end())
922 std::copy(__position + 1,
end(), __position);
923 --this->_M_impl._M_finish;
927 template<
typename _Alloc>
928 typename vector<bool, _Alloc>::iterator
929 vector<bool, _Alloc>::
930 _M_erase(iterator __first, iterator __last)
932 if (__first != __last)
933 _M_erase_at_end(std::copy(__last,
end(), __first));
937 #if __cplusplus >= 201103L
938 template<
typename _Alloc>
940 vector<bool, _Alloc>::
947 if (size_type __n =
size())
951 this->_M_deallocate();
952 this->_M_impl._M_reset();
961 _GLIBCXX_END_NAMESPACE_CONTAINER
962 _GLIBCXX_END_NAMESPACE_VERSION
965 #if __cplusplus >= 201103L
967 namespace std _GLIBCXX_VISIBILITY(default)
969 _GLIBCXX_BEGIN_NAMESPACE_VERSION
971 template<
typename _Alloc>
973 hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
974 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b)
const noexcept
977 using _GLIBCXX_STD_C::_S_word_bit;
978 using _GLIBCXX_STD_C::_Bit_type;
980 const size_t __words = __b.size() / _S_word_bit;
983 const size_t __clength = __words *
sizeof(_Bit_type);
984 __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
987 const size_t __extrabits = __b.size() % _S_word_bit;
990 _Bit_type __hiword = *__b._M_impl._M_finish._M_p;
991 __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits);
993 const size_t __clength
994 = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__;
996 __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
998 __hash = std::_Hash_impl::hash(&__hiword, __clength);
1004 _GLIBCXX_END_NAMESPACE_VERSION
1009 #undef _GLIBCXX_ASAN_ANNOTATE_REINIT
1010 #undef _GLIBCXX_ASAN_ANNOTATE_GROW
1011 #undef _GLIBCXX_ASAN_ANNOTATE_GREW
1012 #undef _GLIBCXX_ASAN_ANNOTATE_SHRINK
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
_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 void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
void _Destroy(_ForwardIterator __first, _ForwardIterator __last, _Allocator &__alloc)
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.
Forward iterators support a superset of input iterator operations.
A standard container which offers fixed time access to individual elements in any order.
void reserve(size_type __n)
Attempt to preallocate enough memory for specified number of elements.
vector & operator=(const vector &__x)
Vector assignment operator.
iterator begin() noexcept
size_type size() const noexcept
size_type capacity() const noexcept