129 vector<_Tp, _Allocator>, _Allocator, __gnu_debug::_Safe_sequence>,
130 public _GLIBCXX_STD_C::vector<_Tp, _Allocator>,
132 vector<_Tp, _Allocator>,
133 _GLIBCXX_STD_C::vector<_Tp, _Allocator> >
135 typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator>
_Base;
144 template<
typename _ItT,
typename _SeqT,
typename _CatT>
145 friend class ::__gnu_debug::_Safe_iterator;
152 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
158 typedef typename _Base::reference reference;
159 typedef typename _Base::const_reference const_reference;
166 typedef typename _Base::size_type size_type;
167 typedef typename _Base::difference_type difference_type;
169 typedef _Tp value_type;
170 typedef _Allocator allocator_type;
171 typedef typename _Base::pointer pointer;
172 typedef typename _Base::const_pointer const_pointer;
178#if __cplusplus < 201103L
179 vector() _GLIBCXX_NOEXCEPT
187 vector(
const _Allocator& __a) _GLIBCXX_NOEXCEPT
190#if __cplusplus >= 201103L
193 vector(size_type __n,
const _Allocator& __a = _Allocator())
197 vector(size_type __n,
const __type_identity_t<_Tp>& __value,
198 const _Allocator& __a = _Allocator())
199 :
_Base(__n, __value, __a) { }
202 vector(size_type __n,
const _Tp& __value = _Tp(),
203 const _Allocator& __a = _Allocator())
204 :
_Base(__n, __value, __a) { }
207#if __cplusplus >= 201103L
208 template<
class _InputIterator,
209 typename = std::_RequireInputIter<_InputIterator>>
211 template<
class _InputIterator>
214 vector(_InputIterator __first, _InputIterator __last,
215 const _Allocator& __a = _Allocator())
217 : __glibcxx_check_valid_constructor_range(__first, __last)),
220#if __cplusplus < 201103L
224 ~vector() _GLIBCXX_NOEXCEPT { }
230 vector(
const vector& __x,
const __type_identity_t<allocator_type>& __a)
231 :
_Base(__x, __a) { }
234 vector(
vector&& __x,
const __type_identity_t<allocator_type>& __a)
237 _Base,
const allocator_type&>::value )
244 const allocator_type& __a = allocator_type())
245 :
_Base(__l, __a) { }
247#if __glibcxx_ranges_to_container
252 template<std::__detail::__container_compatible_range<_Tp> _Rg>
254 vector(std::from_range_t __t, _Rg&& __rg,
255 const allocator_type& __a = allocator_type())
256 :
_Base(__t, std::forward<_Rg>(__rg), __a)
266 :
_Base(__x._M_ref) { }
268#if __cplusplus >= 201103L
270 operator=(
const vector&) =
default;
273 operator=(
vector&&) =
default;
279 _Base::operator=(__l);
280 if (!std::__is_constant_evaluated())
282 this->_M_invalidate_all();
283 this->_M_update_guaranteed_capacity();
289#if __cplusplus >= 201103L
290 template<
typename _InputIterator,
291 typename = std::_RequireInputIter<_InputIterator>>
293 template<
typename _InputIterator>
297 assign(_InputIterator __first, _InputIterator __last)
299 if (std::__is_constant_evaluated())
300 return _Base::assign(__gnu_debug::__unsafe(__first),
301 __gnu_debug::__unsafe(__last));
304 __glibcxx_check_valid_range2(__first, __last, __dist);
306 if (__dist.
second >= __gnu_debug::__dp_sign)
307 _Base::assign(__gnu_debug::__unsafe(__first),
308 __gnu_debug::__unsafe(__last));
310 _Base::assign(__first, __last);
312 this->_M_invalidate_all();
313 this->_M_update_guaranteed_capacity();
318 assign(size_type __n,
const _Tp& __u)
320 _Base::assign(__n, __u);
321 if (!std::__is_constant_evaluated())
323 this->_M_invalidate_all();
324 this->_M_update_guaranteed_capacity();
328#if __cplusplus >= 201103L
331 assign(initializer_list<value_type> __l)
334 if (!std::__is_constant_evaluated())
336 this->_M_invalidate_all();
337 this->_M_update_guaranteed_capacity();
342 using _Base::get_allocator;
348 begin() _GLIBCXX_NOEXCEPT
349 {
return iterator(_Base::begin(),
this); }
354 begin() const _GLIBCXX_NOEXCEPT
355 {
return const_iterator(_Base::begin(),
this); }
360 end() _GLIBCXX_NOEXCEPT
361 {
return iterator(_Base::end(),
this); }
366 end() const _GLIBCXX_NOEXCEPT
367 {
return const_iterator(_Base::end(),
this); }
372 rbegin() _GLIBCXX_NOEXCEPT
373 {
return reverse_iterator(end()); }
377 const_reverse_iterator
378 rbegin() const _GLIBCXX_NOEXCEPT
379 {
return const_reverse_iterator(end()); }
384 rend() _GLIBCXX_NOEXCEPT
385 {
return reverse_iterator(begin()); }
389 const_reverse_iterator
390 rend() const _GLIBCXX_NOEXCEPT
391 {
return const_reverse_iterator(begin()); }
393#if __cplusplus >= 201103L
397 cbegin() const noexcept
398 {
return const_iterator(_Base::begin(),
this); }
403 cend() const noexcept
404 {
return const_iterator(_Base::end(),
this); }
408 const_reverse_iterator
409 crbegin() const noexcept
410 {
return const_reverse_iterator(end()); }
414 const_reverse_iterator
415 crend() const noexcept
416 {
return const_reverse_iterator(begin()); }
421 using _Base::max_size;
423#if __cplusplus >= 201103L
426 resize(size_type __sz)
428 if (std::__is_constant_evaluated())
429 return _Base::resize(__sz);
431 bool __realloc = this->_M_requires_reallocation(__sz);
432 if (__sz < this->
size())
433 this->_M_invalidate_after_nth(__sz);
436 this->_M_invalidate_all();
437 this->_M_update_guaranteed_capacity();
442 resize(size_type __sz,
const _Tp& __c)
444 if (std::__is_constant_evaluated())
445 return _Base::resize(__sz, __c);
447 bool __realloc = this->_M_requires_reallocation(__sz);
448 if (__sz < this->
size())
449 this->_M_invalidate_after_nth(__sz);
450 _Base::resize(__sz, __c);
452 this->_M_invalidate_all();
453 this->_M_update_guaranteed_capacity();
457 resize(size_type __sz, _Tp __c = _Tp())
459 bool __realloc = this->_M_requires_reallocation(__sz);
460 if (__sz < this->
size())
461 this->_M_invalidate_after_nth(__sz);
462 _Base::resize(__sz, __c);
464 this->_M_invalidate_all();
465 this->_M_update_guaranteed_capacity();
469#if __cplusplus >= 201103L
474 if (std::__is_constant_evaluated())
475 return _Base::shrink_to_fit();
477 if (_Base::_M_shrink_to_fit())
479 this->_M_guaranteed_capacity = _Base::capacity();
480 this->_M_invalidate_all();
488 capacity() const _GLIBCXX_NOEXCEPT
490 if (std::__is_constant_evaluated())
491 return _Base::capacity();
493#ifdef _GLIBCXX_DEBUG_PEDANTIC
494 return this->_M_guaranteed_capacity;
496 return _Base::capacity();
504 reserve(size_type __n)
506 if (std::__is_constant_evaluated())
507 return _Base::reserve(__n);
509 bool __realloc = this->_M_requires_reallocation(__n);
511 if (__n > this->_M_guaranteed_capacity)
512 this->_M_guaranteed_capacity = __n;
514 this->_M_invalidate_all();
521 operator[](size_type __n) _GLIBCXX_NOEXCEPT
523 __glibcxx_check_subscript(__n);
524 return _Base::operator[](__n);
530 operator[](size_type __n)
const _GLIBCXX_NOEXCEPT
532 __glibcxx_check_subscript(__n);
533 return _Base::operator[](__n);
541 front() _GLIBCXX_NOEXCEPT
543 __glibcxx_check_nonempty();
544 return _Base::front();
550 front() const _GLIBCXX_NOEXCEPT
552 __glibcxx_check_nonempty();
553 return _Base::front();
559 back() _GLIBCXX_NOEXCEPT
561 __glibcxx_check_nonempty();
562 return _Base::back();
568 back() const _GLIBCXX_NOEXCEPT
570 __glibcxx_check_nonempty();
571 return _Base::back();
581 push_back(
const _Tp& __x)
583 if (std::__is_constant_evaluated())
584 return _Base::push_back(__x);
586 bool __realloc = this->_M_requires_reallocation(this->
size() + 1);
587 _Base::push_back(__x);
589 this->_M_invalidate_all();
590 this->_M_update_guaranteed_capacity();
593#if __cplusplus >= 201103L
594 template<
typename _Up = _Tp>
596 typename __gnu_cxx::__enable_if<!std::__are_same<_Up, bool>::__value,
601 template<
typename... _Args>
603#if __cplusplus > 201402L
608 emplace_back(_Args&&... __args)
610 if (std::__is_constant_evaluated())
611 return _Base::emplace_back(std::forward<_Args>(__args)...);
613 bool __realloc = this->_M_requires_reallocation(this->
size() + 1);
614 _Base::emplace_back(std::forward<_Args>(__args)...);
616 this->_M_invalidate_all();
617 this->_M_update_guaranteed_capacity();
618#if __cplusplus > 201402L
626 pop_back() _GLIBCXX_NOEXCEPT
628 if (!std::__is_constant_evaluated())
630 __glibcxx_check_nonempty();
631 this->_M_invalidate_if(_Equal(--_Base::end()));
636#if __cplusplus >= 201103L
637 template<
typename... _Args>
640 emplace(const_iterator __position, _Args&&... __args)
642 if (std::__is_constant_evaluated())
643 return iterator(_Base::emplace(__position.base(),
644 std::forward<_Args>(__args)...),
648 bool __realloc = this->_M_requires_reallocation(this->
size() + 1);
649 difference_type __offset = __position.base() - _Base::cbegin();
650 _Base_iterator __res = _Base::emplace(__position.base(),
651 std::forward<_Args>(__args)...);
653 this->_M_invalidate_all();
655 this->_M_invalidate_after_nth(__offset);
656 this->_M_update_guaranteed_capacity();
657 return { __res,
this };
663#if __cplusplus >= 201103L
664 insert(const_iterator __position,
const _Tp& __x)
666 insert(iterator __position,
const _Tp& __x)
669 if (std::__is_constant_evaluated())
670 return iterator(_Base::insert(__position.base(), __x),
this);
673 bool __realloc = this->_M_requires_reallocation(this->
size() + 1);
674 difference_type __offset = __position.base() - _Base::begin();
675 _Base_iterator __res = _Base::insert(__position.base(), __x);
677 this->_M_invalidate_all();
679 this->_M_invalidate_after_nth(__offset);
680 this->_M_update_guaranteed_capacity();
681 return iterator(__res,
this);
684#if __cplusplus >= 201103L
685 template<
typename _Up = _Tp>
687 typename __gnu_cxx::__enable_if<!std::__are_same<_Up, bool>::__value,
689 insert(const_iterator __position, _Tp&& __x)
690 {
return emplace(__position,
std::move(__x)); }
694 insert(const_iterator __position, initializer_list<value_type> __l)
695 {
return this->insert(__position, __l.begin(), __l.end()); }
698#if __cplusplus >= 201103L
701 insert(const_iterator __position, size_type __n,
const _Tp& __x)
703 if (std::__is_constant_evaluated())
704 return iterator(_Base::insert(__position.base(), __n, __x),
this);
707 bool __realloc = this->_M_requires_reallocation(this->
size() + __n);
708 difference_type __offset = __position.base() - _Base::cbegin();
709 _Base_iterator __res = _Base::insert(__position.base(), __n, __x);
711 this->_M_invalidate_all();
713 this->_M_invalidate_after_nth(__offset);
714 this->_M_update_guaranteed_capacity();
715 return { __res,
this };
719 insert(iterator __position, size_type __n,
const _Tp& __x)
722 bool __realloc = this->_M_requires_reallocation(this->
size() + __n);
723 difference_type __offset = __position.base() - _Base::begin();
724 _Base::insert(__position.base(), __n, __x);
726 this->_M_invalidate_all();
728 this->_M_invalidate_after_nth(__offset);
729 this->_M_update_guaranteed_capacity();
733#if __cplusplus >= 201103L
734 template<
class _InputIterator,
735 typename = std::_RequireInputIter<_InputIterator>>
738 insert(const_iterator __position,
739 _InputIterator __first, _InputIterator __last)
741 if (std::__is_constant_evaluated())
742 return iterator(_Base::insert(__position.base(),
743 __gnu_debug::__unsafe(__first),
744 __gnu_debug::__unsafe(__last)),
this);
752 _Base_iterator __old_begin = _M_base().begin();
753 difference_type __offset = __position.base() - _Base::cbegin();
754 _Base_iterator __res;
755 if (__dist.
second >= __gnu_debug::__dp_sign)
756 __res = _Base::insert(__position.base(),
757 __gnu_debug::__unsafe(__first),
758 __gnu_debug::__unsafe(__last));
760 __res = _Base::insert(__position.base(), __first, __last);
762 if (_M_base().begin() != __old_begin)
763 this->_M_invalidate_all();
765 this->_M_invalidate_after_nth(__offset);
766 this->_M_update_guaranteed_capacity();
767 return { __res,
this };
770 template<
class _InputIterator>
772 insert(iterator __position,
773 _InputIterator __first, _InputIterator __last)
781 _Base_iterator __old_begin = _M_base().begin();
782 difference_type __offset = __position.base() - _Base::begin();
783 if (__dist.
second >= __gnu_debug::__dp_sign)
784 _Base::insert(__position.base(), __gnu_debug::__unsafe(__first),
785 __gnu_debug::__unsafe(__last));
787 _Base::insert(__position.base(), __first, __last);
789 if (_M_base().begin() != __old_begin)
790 this->_M_invalidate_all();
792 this->_M_invalidate_after_nth(__offset);
793 this->_M_update_guaranteed_capacity();
799#if __cplusplus >= 201103L
800 erase(const_iterator __position)
802 erase(iterator __position)
805 if (std::__is_constant_evaluated())
806 return iterator(_Base::erase(__position.base()),
this);
809 difference_type __offset = __position.base() - _Base::begin();
810 _Base_iterator __res = _Base::erase(__position.base());
811 this->_M_invalidate_after_nth(__offset);
812 return iterator(__res,
this);
817#if __cplusplus >= 201103L
818 erase(const_iterator __first, const_iterator __last)
820 erase(iterator __first, iterator __last)
823 if (std::__is_constant_evaluated())
824 return iterator(_Base::erase(__first.base(), __last.base()),
this);
830 if (__first.base() != __last.base())
832 difference_type __offset = __first.base() - _Base::begin();
833 _Base_iterator __res = _Base::erase(__first.base(),
835 this->_M_invalidate_after_nth(__offset);
836 return iterator(__res,
this);
839#if __cplusplus >= 201103L
840 return { _Base::begin() + (__first.base() - _Base::cbegin()),
this };
849 _GLIBCXX_NOEXCEPT_IF(
noexcept(declval<_Base&>().swap(__x)) )
851 if (!std::__is_constant_evaluated())
854 std::swap(this->_M_guaranteed_capacity, __x._M_guaranteed_capacity);
859 clear() _GLIBCXX_NOEXCEPT
862 if (!std::__is_constant_evaluated())
863 this->_M_invalidate_all();
868 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
872 _M_base() const _GLIBCXX_NOEXCEPT {
return *
this; }
874#if __glibcxx_ranges_to_container
875 template<std::__detail::__container_compatible_range<_Tp> _Rg>
877 assign_range(_Rg&& __rg)
879 auto __old_begin = _Base::begin();
880 auto __old_size = _Base::size();
881 _Base::assign_range(__rg);
882 if (!std::__is_constant_evaluated())
884 if (_Base::begin() != __old_begin)
885 this->_M_invalidate_all();
886 else if (_Base::size() < __old_size)
887 this->_M_invalidate_after_nth(_Base::size());
888 this->_M_update_guaranteed_capacity();
892 template<__detail::__container_compatible_range<_Tp> _Rg>
894 insert_range(const_iterator __pos, _Rg&& __rg)
896 auto __old_begin = _Base::begin();
897 auto __old_size = _Base::size();
898 auto __res = _Base::insert_range(__pos.base(), __rg);
899 if (!std::__is_constant_evaluated())
901 if (_Base::begin() != __old_begin)
902 this->_M_invalidate_all();
903 this->_M_update_guaranteed_capacity();
905 return iterator(__res,
this);
908 template<__detail::__container_compatible_range<_Tp> _Rg>
910 append_range(_Rg&& __rg)
912 auto __old_begin = _Base::begin();
913 auto __old_size = _Base::size();
914 _Base::append_range(__rg);
915 if (!std::__is_constant_evaluated())
917 if (_Base::begin() != __old_begin)
918 this->_M_invalidate_all();
919 this->_M_update_guaranteed_capacity();
926 _M_invalidate_after_nth(difference_type __n) _GLIBCXX_NOEXCEPT
929 this->_M_invalidate_if(_After_nth(__n, _Base::begin()));