57#define _STL_VECTOR_H 1
62#if __cplusplus >= 201103L
65#if __cplusplus >= 202002L
67#define __cpp_lib_constexpr_vector 201907L
72#if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR
74__sanitizer_annotate_contiguous_container(
const void*,
const void*,
75 const void*,
const void*);
78namespace std _GLIBCXX_VISIBILITY(default)
80_GLIBCXX_BEGIN_NAMESPACE_VERSION
81_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
84 template<
typename _Tp,
typename _Alloc>
88 rebind<_Tp>::other _Tp_alloc_type;
89 typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer
92 struct _Vector_impl_data
96 pointer _M_end_of_storage;
100 : _M_start(), _M_finish(), _M_end_of_storage()
103#if __cplusplus >= 201103L
105 _Vector_impl_data(_Vector_impl_data&& __x) noexcept
106 : _M_start(__x._M_start), _M_finish(__x._M_finish),
107 _M_end_of_storage(__x._M_end_of_storage)
108 { __x._M_start = __x._M_finish = __x._M_end_of_storage = pointer(); }
115 _M_start = __x._M_start;
116 _M_finish = __x._M_finish;
117 _M_end_of_storage = __x._M_end_of_storage;
126 _Vector_impl_data
__tmp;
127 __tmp._M_copy_data(*
this);
129 __x._M_copy_data(
__tmp);
134 :
public _Tp_alloc_type,
public _Vector_impl_data
144 : _Tp_alloc_type(__a)
147#if __cplusplus >= 201103L
151 _Vector_impl(_Vector_impl&& __x) noexcept
156 _Vector_impl(_Tp_alloc_type&& __a) noexcept
161 _Vector_impl(_Tp_alloc_type&& __a, _Vector_impl&&
__rv) noexcept
166#if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR
167 template<
typename = _Tp_alloc_type>
171 ::size_type size_type;
188 template<
typename _Up>
192 ::size_type size_type;
199#if __cpp_lib_is_constant_evaluated
208 _S_grow(_Vector_impl& __impl, size_type __n)
209 {
_S_adjust(__impl, __impl._M_finish, __impl._M_finish + __n); }
212 _S_shrink(_Vector_impl& __impl, size_type __n)
213 {
_S_adjust(__impl, __impl._M_finish + __n, __impl._M_finish); }
219 _S_adjust(__impl, __impl._M_finish, __impl._M_end_of_storage);
226 _Reinit(_Vector_impl& __impl) : _M_impl(__impl)
236 if (_M_impl._M_start)
237 _S_adjust(_M_impl, _M_impl._M_end_of_storage,
241 _Vector_impl& _M_impl;
243#if __cplusplus >= 201103L
253 _Grow(_Vector_impl& __impl, size_type __n)
254 : _M_impl(__impl), _M_n(__n)
261 void _M_grew(size_type __n) { _M_n -= __n; }
263#if __cplusplus >= 201103L
268 _Vector_impl& _M_impl;
273#define _GLIBCXX_ASAN_ANNOTATE_REINIT \
274 typename _Base::_Vector_impl::template _Asan<>::_Reinit const \
275 __attribute__((__unused__)) __reinit_guard(this->_M_impl)
276#define _GLIBCXX_ASAN_ANNOTATE_GROW(n) \
277 typename _Base::_Vector_impl::template _Asan<>::_Grow \
278 __attribute__((__unused__)) __grow_guard(this->_M_impl, (n))
279#define _GLIBCXX_ASAN_ANNOTATE_GREW(n) __grow_guard._M_grew(n)
280#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n) \
281 _Base::_Vector_impl::template _Asan<>::_S_shrink(this->_M_impl, n)
282#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC \
283 _Base::_Vector_impl::template _Asan<>::_S_on_dealloc(this->_M_impl)
285#define _GLIBCXX_ASAN_ANNOTATE_REINIT
286#define _GLIBCXX_ASAN_ANNOTATE_GROW(n)
287#define _GLIBCXX_ASAN_ANNOTATE_GREW(n)
288#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n)
289#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC
294 typedef _Alloc allocator_type;
299 {
return this->_M_impl; }
302 const _Tp_alloc_type&
304 {
return this->_M_impl; }
309 {
return allocator_type(_M_get_Tp_allocator()); }
311#if __cplusplus >= 201103L
318 _Vector_base(
const allocator_type& __a) _GLIBCXX_NOEXCEPT
322#if !_GLIBCXX_INLINE_VERSION
324 _Vector_base(
size_t __n)
326 { _M_create_storage(__n); }
330 _Vector_base(
size_t __n,
const allocator_type& __a)
332 { _M_create_storage(__n); }
334#if __cplusplus >= 201103L
335 _Vector_base(_Vector_base&&) =
default;
338# if !_GLIBCXX_INLINE_VERSION
340 _Vector_base(_Tp_alloc_type&& __a) noexcept
344 _Vector_base(_Vector_base&& __x,
const allocator_type& __a)
347 if (__x.get_allocator() == __a)
348 this->_M_impl._M_swap_data(__x._M_impl);
351 size_t __n = __x._M_impl._M_finish - __x._M_impl._M_start;
352 _M_create_storage(__n);
358 _Vector_base(
const allocator_type& __a, _Vector_base&& __x)
359 : _M_impl(_Tp_alloc_type(__a),
std::
move(__x._M_impl))
364 ~_Vector_base() _GLIBCXX_NOEXCEPT
366 _M_deallocate(_M_impl._M_start,
367 _M_impl._M_end_of_storage - _M_impl._M_start);
371 _Vector_impl _M_impl;
375 _M_allocate(
size_t __n)
378 return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer();
383 _M_deallocate(pointer __p,
size_t __n)
387 _Tr::deallocate(_M_impl, __p, __n);
393 _M_create_storage(
size_t __n)
395 this->_M_impl._M_start = this->_M_allocate(__n);
396 this->_M_impl._M_finish = this->_M_impl._M_start;
397 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
424 template<
typename _Tp,
typename _Alloc = std::allocator<_Tp> >
427#ifdef _GLIBCXX_CONCEPT_CHECKS
430# if __cplusplus < 201103L
431 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
436#if __cplusplus >= 201103L
438 "std::vector must have a non-const, non-volatile value_type");
439# if __cplusplus > 201703L || defined __STRICT_ANSI__
441 "std::vector must have the same value_type as its allocator");
446 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
450 typedef _Tp value_type;
451 typedef typename _Base::pointer pointer;
452 typedef typename _Alloc_traits::const_pointer const_pointer;
453 typedef typename _Alloc_traits::reference reference;
454 typedef typename _Alloc_traits::const_reference const_reference;
455 typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;
456 typedef __gnu_cxx::__normal_iterator<const_pointer, vector>
460 typedef size_t size_type;
461 typedef ptrdiff_t difference_type;
462 typedef _Alloc allocator_type;
465#if __cplusplus >= 201103L
466 static constexpr bool
475 static constexpr bool
479 static constexpr bool
489 _S_do_relocate(pointer __first, pointer __last, pointer __result,
496 _S_do_relocate(pointer, pointer, pointer __result,
501 _S_relocate(pointer __first, pointer __last, pointer __result,
502 _Tp_alloc_type&
__alloc)
noexcept
504#if __cpp_if_constexpr
508 using __do_it = __bool_constant<_S_use_relocate()>;
509 return _S_do_relocate(__first, __last, __result,
__alloc,
__do_it{});
515 using _Base::_M_allocate;
516 using _Base::_M_deallocate;
517 using _Base::_M_impl;
518 using _Base::_M_get_Tp_allocator;
527#if __cplusplus >= 201103L
542#if __cplusplus >= 201103L
553 vector(size_type __n,
const allocator_type& __a = allocator_type())
554 :
_Base(_S_check_init_len(__n, __a), __a)
555 { _M_default_initialize(__n); }
566 vector(size_type __n,
const value_type& __value,
567 const allocator_type& __a = allocator_type())
568 :
_Base(_S_check_init_len(__n, __a), __a)
569 { _M_fill_initialize(__n, __value); }
580 vector(size_type __n,
const value_type& __value = value_type(),
581 const allocator_type& __a = allocator_type())
582 : _Base(_S_check_init_len(__n, __a), __a)
583 { _M_fill_initialize(__n, __value); }
602 this->_M_impl._M_finish =
604 this->_M_impl._M_start,
605 _M_get_Tp_allocator());
608#if __cplusplus >= 201103L
624 this->_M_impl._M_finish =
626 this->_M_impl._M_start,
627 _M_get_Tp_allocator());
640 if (__rv.get_allocator() == __m)
641 this->_M_impl._M_swap_data(__rv._M_impl);
642 else if (!__rv.empty())
644 this->_M_create_storage(__rv.size());
645 this->_M_impl._M_finish =
647 this->_M_impl._M_start,
648 _M_get_Tp_allocator());
676 const allocator_type& __a = allocator_type())
679 _M_range_initialize(
__l.begin(),
__l.end(),
700#if __cplusplus >= 201103L
705 const allocator_type& __a = allocator_type())
708 _M_range_initialize(__first, __last,
712 template<
typename _InputIterator>
714 const allocator_type& __a = allocator_type())
718 typedef typename std::__is_integer<_InputIterator>::__type
_Integral;
719 _M_initialize_dispatch(__first, __last,
_Integral());
733 _M_get_Tp_allocator());
734 _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC;
750#if __cplusplus >= 201103L
766 _Alloc_traits::_S_propagate_on_move_assign()
767 || _Alloc_traits::_S_always_equal();
787 this->_M_assign_aux(
__l.begin(),
__l.end(),
805 assign(size_type __n,
const value_type& __val)
806 { _M_fill_assign(__n, __val); }
820#if __cplusplus >= 201103L
826 { _M_assign_dispatch(__first, __last, __false_type()); }
828 template<
typename _InputIterator>
833 typedef typename std::__is_integer<_InputIterator>::__type
_Integral;
834 _M_assign_dispatch(__first, __last,
_Integral());
838#if __cplusplus >= 201103L
854 this->_M_assign_aux(
__l.begin(),
__l.end(),
860 using _Base::get_allocator;
871 {
return iterator(this->_M_impl._M_start); }
881 {
return const_iterator(this->_M_impl._M_start); }
891 {
return iterator(this->_M_impl._M_finish); }
901 {
return const_iterator(this->_M_impl._M_finish); }
919 const_reverse_iterator
939 const_reverse_iterator
943#if __cplusplus >= 201103L
952 {
return const_iterator(this->_M_impl._M_start); }
962 {
return const_iterator(this->_M_impl._M_finish); }
970 const_reverse_iterator
980 const_reverse_iterator
990 {
return size_type(this->_M_impl._M_finish -
this->_M_impl._M_start); }
996 {
return _S_max_size(_M_get_Tp_allocator()); }
998#if __cplusplus >= 201103L
1015 _M_erase_at_end(this->_M_impl._M_start +
__new_size);
1036 _M_erase_at_end(this->_M_impl._M_start +
__new_size);
1057 _M_erase_at_end(this->_M_impl._M_start +
__new_size);
1061#if __cplusplus >= 201103L
1063 _GLIBCXX20_CONSTEXPR
1066 { _M_shrink_to_fit(); }
1076 {
return size_type(this->_M_impl._M_end_of_storage
1077 -
this->_M_impl._M_start); }
1125 __glibcxx_requires_subscript(__n);
1126 return *(this->_M_impl._M_start + __n);
1144 __glibcxx_requires_subscript(__n);
1145 return *(this->_M_impl._M_start + __n);
1154 if (__n >= this->
size())
1155 __throw_out_of_range_fmt(__N(
"vector::_M_range_check: __n "
1156 "(which is %zu) >= this->size() "
1178 return (*
this)[__n];
1197 return (*
this)[__n];
1208 __glibcxx_requires_nonempty();
1220 __glibcxx_requires_nonempty();
1232 __glibcxx_requires_nonempty();
1233 return *(
end() - 1);
1244 __glibcxx_requires_nonempty();
1245 return *(
end() - 1);
1258 {
return _M_data_ptr(this->_M_impl._M_start); }
1263 {
return _M_data_ptr(this->_M_impl._M_start); }
1276 _GLIBCXX20_CONSTEXPR
1280 if (this->_M_impl._M_finish !=
this->_M_impl._M_end_of_storage)
1282 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
1283 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
1285 ++this->_M_impl._M_finish;
1286 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
1289 _M_realloc_insert(
end(), __x);
1292#if __cplusplus >= 201103L
1298 template<
typename... _Args>
1299#if __cplusplus > 201402L
1300 _GLIBCXX20_CONSTEXPR
1305 emplace_back(_Args&&... __args);
1317 _GLIBCXX20_CONSTEXPR
1321 __glibcxx_requires_nonempty();
1322 --this->_M_impl._M_finish;
1323 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
1324 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
1327#if __cplusplus >= 201103L
1340 template<
typename...
_Args>
1376#if __cplusplus >= 201103L
1411 _M_range_insert(
begin() + __offset,
__l.begin(),
__l.end(),
1413 return begin() + __offset;
1417#if __cplusplus >= 201103L
1437 _M_fill_insert(
begin() + __offset, __n, __x);
1438 return begin() + __offset;
1459#if __cplusplus >= 201103L
1475 template<
typename _InputIterator,
1477 _GLIBCXX20_CONSTEXPR
1483 _M_insert_dispatch(
begin() + __offset,
1484 __first, __last, __false_type());
1485 return begin() + __offset;
1502 template<
typename _InputIterator>
1508 typedef typename std::__is_integer<_InputIterator>::__type
_Integral;
1528 _GLIBCXX20_CONSTEXPR
1530#if __cplusplus >= 201103L
1556 _GLIBCXX20_CONSTEXPR
1558#if __cplusplus >= 201103L
1559 erase(const_iterator __first, const_iterator __last)
1567 {
return _M_erase(__first, __last); }
1581 _GLIBCXX20_CONSTEXPR
1585#if __cplusplus >= 201103L
1586 __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value
1587 || _M_get_Tp_allocator() == __x._M_get_Tp_allocator());
1589 this->_M_impl._M_swap_data(__x._M_impl);
1590 _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(),
1591 __x._M_get_Tp_allocator());
1603 { _M_erase_at_end(this->_M_impl._M_start); }
1610 template<
typename _ForwardIterator>
1616 pointer __result = this->_M_allocate(__n);
1620 _M_get_Tp_allocator());
1625 _M_deallocate(__result, __n);
1626 __throw_exception_again;
1635#if __cplusplus < 201103L
1638 template<
typename _Integer>
1642 this->_M_impl._M_start = _M_allocate(_S_check_init_len(
1643 static_cast<size_type
>(__n), _M_get_Tp_allocator()));
1644 this->_M_impl._M_end_of_storage =
1645 this->_M_impl._M_start +
static_cast<size_type
>(__n);
1646 _M_fill_initialize(
static_cast<size_type
>(__n), __value);
1650 template<
typename _InputIterator>
1652 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1655 _M_range_initialize(__first, __last,
1661 template<
typename _InputIterator>
1662 _GLIBCXX20_CONSTEXPR
1664 _M_range_initialize(_InputIterator __first, _InputIterator __last,
1668 for (; __first != __last; ++__first)
1669#
if __cplusplus >= 201103L
1670 emplace_back(*__first);
1676 __throw_exception_again;
1681 template<
typename _ForwardIterator>
1682 _GLIBCXX20_CONSTEXPR
1684 _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
1688 this->_M_impl._M_start
1689 = this->_M_allocate(_S_check_init_len(__n, _M_get_Tp_allocator()));
1690 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
1691 this->_M_impl._M_finish =
1693 this->_M_impl._M_start,
1694 _M_get_Tp_allocator());
1699 _GLIBCXX20_CONSTEXPR
1701 _M_fill_initialize(size_type __n,
const value_type& __value)
1703 this->_M_impl._M_finish =
1705 _M_get_Tp_allocator());
1708#if __cplusplus >= 201103L
1710 _GLIBCXX20_CONSTEXPR
1712 _M_default_initialize(size_type __n)
1714 this->_M_impl._M_finish =
1716 _M_get_Tp_allocator());
1727 template<
typename _Integer>
1728 _GLIBCXX20_CONSTEXPR
1730 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1731 { _M_fill_assign(__n, __val); }
1734 template<
typename _InputIterator>
1735 _GLIBCXX20_CONSTEXPR
1737 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1742 template<
typename _InputIterator>
1743 _GLIBCXX20_CONSTEXPR
1745 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1749 template<
typename _ForwardIterator>
1750 _GLIBCXX20_CONSTEXPR
1752 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1757 _GLIBCXX20_CONSTEXPR
1759 _M_fill_assign(size_type __n,
const value_type& __val);
1767 template<
typename _Integer>
1768 _GLIBCXX20_CONSTEXPR
1770 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
1772 { _M_fill_insert(__pos, __n, __val); }
1775 template<
typename _InputIterator>
1776 _GLIBCXX20_CONSTEXPR
1778 _M_insert_dispatch(iterator __pos, _InputIterator __first,
1779 _InputIterator __last, __false_type)
1781 _M_range_insert(__pos, __first, __last,
1786 template<
typename _InputIterator>
1787 _GLIBCXX20_CONSTEXPR
1789 _M_range_insert(iterator __pos, _InputIterator __first,
1793 template<
typename _ForwardIterator>
1794 _GLIBCXX20_CONSTEXPR
1796 _M_range_insert(iterator __pos, _ForwardIterator __first,
1801 _GLIBCXX20_CONSTEXPR
1803 _M_fill_insert(iterator __pos, size_type __n,
const value_type& __x);
1805#if __cplusplus >= 201103L
1807 _GLIBCXX20_CONSTEXPR
1809 _M_default_append(size_type __n);
1811 _GLIBCXX20_CONSTEXPR
1816#if __cplusplus < 201103L
1819 _M_insert_aux(iterator __position,
const value_type& __x);
1822 _M_realloc_insert(iterator __position,
const value_type& __x);
1826 struct _Temporary_value
1828 template<
typename... _Args>
1829 _GLIBCXX20_CONSTEXPR
explicit
1830 _Temporary_value(
vector* __vec, _Args&&... __args) : _M_this(__vec)
1832 _Alloc_traits::construct(_M_this->_M_impl, _M_ptr(),
1836 _GLIBCXX20_CONSTEXPR
1838 { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); }
1840 _GLIBCXX20_CONSTEXPR value_type&
1841 _M_val() noexcept {
return _M_storage._M_val; }
1844 _GLIBCXX20_CONSTEXPR _Tp*
1849 constexpr _Storage() : _M_byte() { }
1850 _GLIBCXX20_CONSTEXPR ~_Storage() { }
1851 _Storage& operator=(
const _Storage&) =
delete;
1852 unsigned char _M_byte;
1857 _Storage _M_storage;
1862 template<
typename _Arg>
1863 _GLIBCXX20_CONSTEXPR
1865 _M_insert_aux(iterator __position, _Arg&& __arg);
1867 template<
typename... _Args>
1868 _GLIBCXX20_CONSTEXPR
1870 _M_realloc_insert(iterator __position, _Args&&... __args);
1873 _GLIBCXX20_CONSTEXPR
1875 _M_insert_rval(const_iterator __position, value_type&& __v);
1878 template<
typename... _Args>
1879 _GLIBCXX20_CONSTEXPR
1881 _M_emplace_aux(const_iterator __position, _Args&&... __args);
1884 _GLIBCXX20_CONSTEXPR
1886 _M_emplace_aux(const_iterator __position, value_type&& __v)
1887 {
return _M_insert_rval(__position,
std::move(__v)); }
1891 _GLIBCXX20_CONSTEXPR
1893 _M_check_len(size_type __n,
const char* __s)
const
1896 __throw_length_error(__N(__s));
1903 static _GLIBCXX20_CONSTEXPR size_type
1904 _S_check_init_len(size_type __n,
const allocator_type& __a)
1906 if (__n > _S_max_size(_Tp_alloc_type(__a)))
1907 __throw_length_error(
1908 __N(
"cannot create std::vector larger than max_size()"));
1912 static _GLIBCXX20_CONSTEXPR size_type
1913 _S_max_size(
const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
1918 const size_t __diffmax
1919 = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max /
sizeof(_Tp);
1921 return (
std::min)(__diffmax, __allocmax);
1928 _GLIBCXX20_CONSTEXPR
1930 _M_erase_at_end(pointer __pos) _GLIBCXX_NOEXCEPT
1932 if (size_type __n = this->_M_impl._M_finish - __pos)
1935 _M_get_Tp_allocator());
1936 this->_M_impl._M_finish = __pos;
1937 _GLIBCXX_ASAN_ANNOTATE_SHRINK(__n);
1941 _GLIBCXX20_CONSTEXPR
1943 _M_erase(iterator __position);
1945 _GLIBCXX20_CONSTEXPR
1947 _M_erase(iterator __first, iterator __last);
1949#if __cplusplus >= 201103L
1954 _GLIBCXX20_CONSTEXPR
1959 this->_M_impl._M_swap_data(__x._M_impl);
1960 __tmp._M_impl._M_swap_data(__x._M_impl);
1966 _GLIBCXX20_CONSTEXPR
1970 if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator())
1976 this->_M_assign_aux(std::make_move_iterator(__x.begin()),
1977 std::make_move_iterator(__x.end()),
1984 template<
typename _Up>
1985 _GLIBCXX20_CONSTEXPR
1987 _M_data_ptr(_Up* __ptr)
const _GLIBCXX_NOEXCEPT
1990#if __cplusplus >= 201103L
1991 template<
typename _Ptr>
1992 _GLIBCXX20_CONSTEXPR
1994 _M_data_ptr(_Ptr __ptr)
const
1995 {
return empty() ? nullptr : std::__to_address(__ptr); }
1997 template<
typename _Up>
1999 _M_data_ptr(_Up* __ptr) _GLIBCXX_NOEXCEPT
2002 template<
typename _Ptr>
2004 _M_data_ptr(_Ptr __ptr)
2005 {
return empty() ? (value_type*)0 : __ptr.operator->(); }
2007 template<
typename _Ptr>
2009 _M_data_ptr(_Ptr __ptr)
const
2010 {
return empty() ? (
const value_type*)0 : __ptr.operator->(); }
2014#if __cpp_deduction_guides >= 201606
2015 template<
typename _InputIterator,
typename _ValT
2016 =
typename iterator_traits<_InputIterator>::value_type,
2017 typename _Allocator = allocator<_ValT>,
2018 typename = _RequireInputIter<_InputIterator>,
2019 typename = _RequireAllocator<_Allocator>>
2020 vector(_InputIterator, _InputIterator, _Allocator = _Allocator())
2021 -> vector<_ValT, _Allocator>;
2034 template<
typename _Tp,
typename _Alloc>
2035 _GLIBCXX20_CONSTEXPR
2038 {
return (__x.size() == __y.size()
2039 && std::equal(__x.begin(), __x.end(), __y.begin())); }
2041#if __cpp_lib_three_way_comparison
2053 template<
typename _Tp,
typename _Alloc>
2054 _GLIBCXX20_CONSTEXPR
2055 inline __detail::__synth3way_t<_Tp>
2056 operator<=>(
const vector<_Tp, _Alloc>& __x,
const vector<_Tp, _Alloc>& __y)
2059 __y.begin(), __y.end(),
2060 __detail::__synth3way);
2074 template<
typename _Tp,
typename _Alloc>
2077 {
return std::lexicographical_compare(__x.begin(), __x.end(),
2078 __y.begin(), __y.end()); }
2081 template<
typename _Tp,
typename _Alloc>
2084 {
return !(__x == __y); }
2087 template<
typename _Tp,
typename _Alloc>
2090 {
return __y < __x; }
2093 template<
typename _Tp,
typename _Alloc>
2096 {
return !(__y < __x); }
2099 template<
typename _Tp,
typename _Alloc>
2102 {
return !(__x < __y); }
2106 template<
typename _Tp,
typename _Alloc>
2107 _GLIBCXX20_CONSTEXPR
2113_GLIBCXX_END_NAMESPACE_CONTAINER
2115#if __cplusplus >= 201703L
2116 namespace __detail::__variant
2118 template<
typename>
struct _Never_valueless_alt;
2122 template<
typename _Tp,
typename _Alloc>
2123 struct _Never_valueless_alt<_GLIBCXX_STD_C::vector<_Tp, _Alloc>>
2129_GLIBCXX_END_NAMESPACE_VERSION
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
constexpr bool is_constant_evaluated() noexcept
Returns true only when called during constant evaluation.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
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 void _Destroy(_ForwardIterator __first, _ForwardIterator __last)
is_nothrow_default_constructible
is_nothrow_move_assignable
typename __detected_or_t< is_empty< _Alloc >, __equal, _Alloc >::type is_always_equal
Whether all instances of the allocator type compare equal.
The standard allocator, as per C++03 [20.4.1].
Forward iterators support a superset of input iterator operations.
Random-access iterators support a superset of bidirectional iterator operations.
See bits/stl_deque.h's _Deque_base for an explanation.
A standard container which offers fixed time access to individual elements in any order.
constexpr iterator insert(const_iterator __position, const value_type &__x)
Inserts given value into vector before specified iterator.
constexpr void push_back(const value_type &__x)
Add data to the end of the vector.
constexpr void resize(size_type __new_size, const value_type &__x)
Resizes the vector to the specified number of elements.
constexpr vector & operator=(initializer_list< value_type > __l)
Vector list assignment operator.
constexpr reverse_iterator rbegin() noexcept
constexpr iterator end() noexcept
constexpr vector(const vector &__x)
Vector copy constructor.
vector()=default
Creates a vector with no elements.
constexpr iterator emplace(const_iterator __position, _Args &&... __args)
Inserts an object in vector before specified iterator.
constexpr iterator insert(const_iterator __position, value_type &&__x)
Inserts given rvalue into vector before specified iterator.
constexpr const_reverse_iterator rend() const noexcept
constexpr iterator begin() noexcept
constexpr size_type capacity() const noexcept
constexpr iterator insert(const_iterator __position, initializer_list< value_type > __l)
Inserts an initializer_list into the vector.
constexpr ~vector() noexcept
constexpr const_iterator begin() const noexcept
constexpr void assign(_InputIterator __first, _InputIterator __last)
Assigns a range to a vector.
constexpr void assign(size_type __n, const value_type &__val)
Assigns a given value to a vector.
constexpr iterator erase(const_iterator __first, const_iterator __last)
Remove a range of elements.
constexpr void swap(vector &__x) noexcept
Swaps data with another vector.
constexpr vector(vector &&__rv, const __type_identity_t< allocator_type > &__m) noexcept(noexcept(vector(std::declval< vector && >(), std::declval< const allocator_type & >(), std::declval< typename _Alloc_traits::is_always_equal >())))
Move constructor with alternative allocator.
constexpr _Tp * data() noexcept
constexpr vector(size_type __n, const allocator_type &__a=allocator_type())
Creates a vector with default constructed elements.
constexpr const_reference front() const noexcept
constexpr vector & operator=(const vector &__x)
Vector assignment operator.
constexpr void pop_back() noexcept
Removes last element.
constexpr vector & operator=(vector &&__x) noexcept(_Alloc_traits::_S_nothrow_move())
Vector move assignment operator.
constexpr const_reference back() const noexcept
constexpr void reserve(size_type __n)
Attempt to preallocate enough memory for specified number of elements.
constexpr reference at(size_type __n)
Provides access to the data contained in the vector.
constexpr void resize(size_type __new_size)
Resizes the vector to the specified number of elements.
constexpr void _M_range_check(size_type __n) const
Safety check used only from at().
constexpr reference front() noexcept
constexpr iterator insert(const_iterator __position, size_type __n, const value_type &__x)
Inserts a number of copies of given data into the vector.
constexpr const_reference operator[](size_type __n) const noexcept
Subscript access to the data contained in the vector.
constexpr vector(const allocator_type &__a) noexcept
Creates a vector with no elements.
constexpr iterator erase(const_iterator __position)
Remove element at given position.
constexpr pointer _M_allocate_and_copy(size_type __n, _ForwardIterator __first, _ForwardIterator __last)
constexpr bool empty() const noexcept
constexpr reverse_iterator rend() noexcept
constexpr const_reverse_iterator rbegin() const noexcept
constexpr const_reverse_iterator crbegin() const noexcept
constexpr const_reference at(size_type __n) const
Provides access to the data contained in the vector.
constexpr const_iterator cbegin() const noexcept
constexpr vector(_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
Builds a vector from a range.
constexpr vector(initializer_list< value_type > __l, const allocator_type &__a=allocator_type())
Builds a vector from an initializer list.
constexpr const_iterator end() const noexcept
vector(vector &&) noexcept=default
Vector move constructor.
constexpr iterator insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
Inserts a range into the vector.
constexpr void clear() noexcept
constexpr void assign(initializer_list< value_type > __l)
Assigns an initializer list to a vector.
constexpr allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
constexpr size_type size() const noexcept
constexpr vector(size_type __n, const value_type &__value, const allocator_type &__a=allocator_type())
Creates a vector with copies of an exemplar element.
constexpr reference back() noexcept
constexpr const_reverse_iterator crend() const noexcept
constexpr const_iterator cend() const noexcept
constexpr reference operator[](size_type __n) noexcept
Subscript access to the data contained in the vector.
constexpr void shrink_to_fit()
constexpr size_type max_size() const noexcept
Uniform interface to C++98 and C++11 allocators.
static constexpr size_type max_size(const _Tp_alloc_type &__a) noexcept
The maximum supported allocation size.