119 vector<_Tp, _Allocator>, _Allocator, __gnu_debug::_Safe_sequence>,
120 public _GLIBCXX_STD_C::vector<_Tp, _Allocator>,
122 vector<_Tp, _Allocator>,
123 _GLIBCXX_STD_C::vector<_Tp, _Allocator> >
125 typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator>
_Base;
134 template<
typename _ItT,
typename _SeqT,
typename _CatT>
135 friend class ::__gnu_debug::_Safe_iterator;
142 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
148 typedef typename _Base::reference reference;
149 typedef typename _Base::const_reference const_reference;
156 typedef typename _Base::size_type size_type;
157 typedef typename _Base::difference_type difference_type;
159 typedef _Tp value_type;
160 typedef _Allocator allocator_type;
161 typedef typename _Base::pointer pointer;
162 typedef typename _Base::const_pointer const_pointer;
168#if __cplusplus < 201103L
169 vector() _GLIBCXX_NOEXCEPT
176 vector(
const _Allocator& __a) _GLIBCXX_NOEXCEPT
179#if __cplusplus >= 201103L
181 vector(size_type __n,
const _Allocator& __a = _Allocator())
184 vector(size_type __n,
const __type_identity_t<_Tp>& __value,
185 const _Allocator& __a = _Allocator())
186 :
_Base(__n, __value, __a) { }
189 vector(size_type __n,
const _Tp& __value = _Tp(),
190 const _Allocator& __a = _Allocator())
191 :
_Base(__n, __value, __a) { }
194#if __cplusplus >= 201103L
195 template<
class _InputIterator,
196 typename = std::_RequireInputIter<_InputIterator>>
198 template<
class _InputIterator>
200 vector(_InputIterator __first, _InputIterator __last,
201 const _Allocator& __a = _Allocator())
203 __glibcxx_check_valid_constructor_range(__first, __last)),
206#if __cplusplus < 201103L
210 ~vector() _GLIBCXX_NOEXCEPT { }
215 vector(
const vector& __x,
const __type_identity_t<allocator_type>& __a)
216 :
_Base(__x, __a) { }
218 vector(
vector&& __x,
const __type_identity_t<allocator_type>& __a)
221 _Base,
const allocator_type&>::value )
227 const allocator_type& __a = allocator_type())
228 :
_Base(__l, __a) { }
235 :
_Base(__x._M_ref) { }
237#if __cplusplus >= 201103L
239 operator=(
const vector&) =
default;
242 operator=(
vector&&) =
default;
247 _Base::operator=(__l);
248 this->_M_invalidate_all();
249 this->_M_update_guaranteed_capacity();
254#if __cplusplus >= 201103L
255 template<
typename _InputIterator,
256 typename = std::_RequireInputIter<_InputIterator>>
258 template<
typename _InputIterator>
261 assign(_InputIterator __first, _InputIterator __last)
264 __glibcxx_check_valid_range2(__first, __last, __dist);
266 if (__dist.
second >= __gnu_debug::__dp_sign)
267 _Base::assign(__gnu_debug::__unsafe(__first),
268 __gnu_debug::__unsafe(__last));
270 _Base::assign(__first, __last);
272 this->_M_invalidate_all();
273 this->_M_update_guaranteed_capacity();
277 assign(size_type __n,
const _Tp& __u)
279 _Base::assign(__n, __u);
280 this->_M_invalidate_all();
281 this->_M_update_guaranteed_capacity();
284#if __cplusplus >= 201103L
286 assign(initializer_list<value_type> __l)
289 this->_M_invalidate_all();
290 this->_M_update_guaranteed_capacity();
294 using _Base::get_allocator;
299 begin() _GLIBCXX_NOEXCEPT
300 {
return iterator(_Base::begin(),
this); }
304 begin() const _GLIBCXX_NOEXCEPT
305 {
return const_iterator(_Base::begin(),
this); }
309 end() _GLIBCXX_NOEXCEPT
310 {
return iterator(_Base::end(),
this); }
314 end() const _GLIBCXX_NOEXCEPT
315 {
return const_iterator(_Base::end(),
this); }
319 rbegin() _GLIBCXX_NOEXCEPT
320 {
return reverse_iterator(end()); }
323 const_reverse_iterator
324 rbegin() const _GLIBCXX_NOEXCEPT
325 {
return const_reverse_iterator(end()); }
329 rend() _GLIBCXX_NOEXCEPT
330 {
return reverse_iterator(begin()); }
333 const_reverse_iterator
334 rend() const _GLIBCXX_NOEXCEPT
335 {
return const_reverse_iterator(begin()); }
337#if __cplusplus >= 201103L
340 cbegin() const noexcept
341 {
return const_iterator(_Base::begin(),
this); }
345 cend() const noexcept
346 {
return const_iterator(_Base::end(),
this); }
349 const_reverse_iterator
350 crbegin() const noexcept
351 {
return const_reverse_iterator(end()); }
354 const_reverse_iterator
355 crend() const noexcept
356 {
return const_reverse_iterator(begin()); }
361 using _Base::max_size;
363#if __cplusplus >= 201103L
365 resize(size_type __sz)
367 bool __realloc = this->_M_requires_reallocation(__sz);
368 if (__sz < this->
size())
369 this->_M_invalidate_after_nth(__sz);
372 this->_M_invalidate_all();
373 this->_M_update_guaranteed_capacity();
377 resize(size_type __sz,
const _Tp& __c)
379 bool __realloc = this->_M_requires_reallocation(__sz);
380 if (__sz < this->
size())
381 this->_M_invalidate_after_nth(__sz);
382 _Base::resize(__sz, __c);
384 this->_M_invalidate_all();
385 this->_M_update_guaranteed_capacity();
389 resize(size_type __sz, _Tp __c = _Tp())
391 bool __realloc = this->_M_requires_reallocation(__sz);
392 if (__sz < this->
size())
393 this->_M_invalidate_after_nth(__sz);
394 _Base::resize(__sz, __c);
396 this->_M_invalidate_all();
397 this->_M_update_guaranteed_capacity();
401#if __cplusplus >= 201103L
405 if (_Base::_M_shrink_to_fit())
407 this->_M_guaranteed_capacity = _Base::capacity();
408 this->_M_invalidate_all();
415 capacity() const _GLIBCXX_NOEXCEPT
417#ifdef _GLIBCXX_DEBUG_PEDANTIC
418 return this->_M_guaranteed_capacity;
420 return _Base::capacity();
427 reserve(size_type __n)
429 bool __realloc = this->_M_requires_reallocation(__n);
431 if (__n > this->_M_guaranteed_capacity)
432 this->_M_guaranteed_capacity = __n;
434 this->_M_invalidate_all();
440 operator[](size_type __n) _GLIBCXX_NOEXCEPT
442 __glibcxx_check_subscript(__n);
443 return _Base::operator[](__n);
448 operator[](size_type __n)
const _GLIBCXX_NOEXCEPT
450 __glibcxx_check_subscript(__n);
451 return _Base::operator[](__n);
458 front() _GLIBCXX_NOEXCEPT
460 __glibcxx_check_nonempty();
461 return _Base::front();
466 front() const _GLIBCXX_NOEXCEPT
468 __glibcxx_check_nonempty();
469 return _Base::front();
474 back() _GLIBCXX_NOEXCEPT
476 __glibcxx_check_nonempty();
477 return _Base::back();
482 back() const _GLIBCXX_NOEXCEPT
484 __glibcxx_check_nonempty();
485 return _Base::back();
494 push_back(
const _Tp& __x)
496 bool __realloc = this->_M_requires_reallocation(this->
size() + 1);
497 _Base::push_back(__x);
499 this->_M_invalidate_all();
500 this->_M_update_guaranteed_capacity();
503#if __cplusplus >= 201103L
504 template<
typename _Up = _Tp>
505 typename __gnu_cxx::__enable_if<!std::__are_same<_Up, bool>::__value,
510 template<
typename... _Args>
511#if __cplusplus > 201402L
516 emplace_back(_Args&&... __args)
518 bool __realloc = this->_M_requires_reallocation(this->
size() + 1);
519 _Base::emplace_back(std::forward<_Args>(__args)...);
521 this->_M_invalidate_all();
522 this->_M_update_guaranteed_capacity();
523#if __cplusplus > 201402L
530 pop_back() _GLIBCXX_NOEXCEPT
532 __glibcxx_check_nonempty();
533 this->_M_invalidate_if(_Equal(--_Base::end()));
537#if __cplusplus >= 201103L
538 template<
typename... _Args>
540 emplace(const_iterator __position, _Args&&... __args)
543 bool __realloc = this->_M_requires_reallocation(this->
size() + 1);
544 difference_type __offset = __position.base() - _Base::cbegin();
545 _Base_iterator __res = _Base::emplace(__position.base(),
546 std::forward<_Args>(__args)...);
548 this->_M_invalidate_all();
550 this->_M_invalidate_after_nth(__offset);
551 this->_M_update_guaranteed_capacity();
552 return { __res,
this };
557#if __cplusplus >= 201103L
558 insert(const_iterator __position,
const _Tp& __x)
560 insert(iterator __position,
const _Tp& __x)
564 bool __realloc = this->_M_requires_reallocation(this->
size() + 1);
565 difference_type __offset = __position.base() - _Base::begin();
566 _Base_iterator __res = _Base::insert(__position.base(), __x);
568 this->_M_invalidate_all();
570 this->_M_invalidate_after_nth(__offset);
571 this->_M_update_guaranteed_capacity();
572 return iterator(__res,
this);
575#if __cplusplus >= 201103L
576 template<
typename _Up = _Tp>
577 typename __gnu_cxx::__enable_if<!std::__are_same<_Up, bool>::__value,
579 insert(const_iterator __position, _Tp&& __x)
580 {
return emplace(__position,
std::move(__x)); }
583 insert(const_iterator __position, initializer_list<value_type> __l)
584 {
return this->insert(__position, __l.begin(), __l.end()); }
587#if __cplusplus >= 201103L
589 insert(const_iterator __position, size_type __n,
const _Tp& __x)
592 bool __realloc = this->_M_requires_reallocation(this->
size() + __n);
593 difference_type __offset = __position.base() - _Base::cbegin();
594 _Base_iterator __res = _Base::insert(__position.base(), __n, __x);
596 this->_M_invalidate_all();
598 this->_M_invalidate_after_nth(__offset);
599 this->_M_update_guaranteed_capacity();
600 return { __res,
this };
604 insert(iterator __position, size_type __n,
const _Tp& __x)
607 bool __realloc = this->_M_requires_reallocation(this->
size() + __n);
608 difference_type __offset = __position.base() - _Base::begin();
609 _Base::insert(__position.base(), __n, __x);
611 this->_M_invalidate_all();
613 this->_M_invalidate_after_nth(__offset);
614 this->_M_update_guaranteed_capacity();
618#if __cplusplus >= 201103L
619 template<
class _InputIterator,
620 typename = std::_RequireInputIter<_InputIterator>>
622 insert(const_iterator __position,
623 _InputIterator __first, _InputIterator __last)
631 _Base_iterator __old_begin = _M_base().begin();
632 difference_type __offset = __position.base() - _Base::cbegin();
633 _Base_iterator __res;
634 if (__dist.
second >= __gnu_debug::__dp_sign)
635 __res = _Base::insert(__position.base(),
636 __gnu_debug::__unsafe(__first),
637 __gnu_debug::__unsafe(__last));
639 __res = _Base::insert(__position.base(), __first, __last);
641 if (_M_base().begin() != __old_begin)
642 this->_M_invalidate_all();
644 this->_M_invalidate_after_nth(__offset);
645 this->_M_update_guaranteed_capacity();
646 return { __res,
this };
649 template<
class _InputIterator>
651 insert(iterator __position,
652 _InputIterator __first, _InputIterator __last)
660 _Base_iterator __old_begin = _M_base().begin();
661 difference_type __offset = __position.base() - _Base::begin();
662 if (__dist.
second >= __gnu_debug::__dp_sign)
663 _Base::insert(__position.base(), __gnu_debug::__unsafe(__first),
664 __gnu_debug::__unsafe(__last));
666 _Base::insert(__position.base(), __first, __last);
668 if (_M_base().begin() != __old_begin)
669 this->_M_invalidate_all();
671 this->_M_invalidate_after_nth(__offset);
672 this->_M_update_guaranteed_capacity();
677#if __cplusplus >= 201103L
678 erase(const_iterator __position)
680 erase(iterator __position)
684 difference_type __offset = __position.base() - _Base::begin();
685 _Base_iterator __res = _Base::erase(__position.base());
686 this->_M_invalidate_after_nth(__offset);
687 return iterator(__res,
this);
691#if __cplusplus >= 201103L
692 erase(const_iterator __first, const_iterator __last)
694 erase(iterator __first, iterator __last)
701 if (__first.base() != __last.base())
703 difference_type __offset = __first.base() - _Base::begin();
704 _Base_iterator __res = _Base::erase(__first.base(),
706 this->_M_invalidate_after_nth(__offset);
707 return iterator(__res,
this);
710#if __cplusplus >= 201103L
711 return { _Base::begin() + (__first.base() - _Base::cbegin()),
this };
719 _GLIBCXX_NOEXCEPT_IF(
noexcept(declval<_Base&>().swap(__x)) )
723 std::swap(this->_M_guaranteed_capacity, __x._M_guaranteed_capacity);
727 clear() _GLIBCXX_NOEXCEPT
730 this->_M_invalidate_all();
734 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
737 _M_base() const _GLIBCXX_NOEXCEPT {
return *
this; }
741 _M_invalidate_after_nth(difference_type __n) _GLIBCXX_NOEXCEPT
744 this->_M_invalidate_if(_After_nth(__n, _Base::begin()));