863 using _Base::get_allocator;
871 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
874 {
return iterator(this->_M_impl._M_start); }
881 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
884 {
return const_iterator(this->_M_impl._M_start); }
891 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
894 {
return iterator(this->_M_impl._M_finish); }
901 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
903 end() const _GLIBCXX_NOEXCEPT
904 {
return const_iterator(this->_M_impl._M_finish); }
911 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
921 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
922 const_reverse_iterator
931 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
941 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
942 const_reverse_iterator
946#if __cplusplus >= 201103L
952 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
955 {
return const_iterator(this->_M_impl._M_start); }
962 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
965 {
return const_iterator(this->_M_impl._M_finish); }
972 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
973 const_reverse_iterator
982 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
983 const_reverse_iterator
990 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
993 {
return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
996 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
999 {
return _S_max_size(_M_get_Tp_allocator()); }
1001#if __cplusplus >= 201103L
1011 _GLIBCXX20_CONSTEXPR
1015 if (__new_size >
size())
1016 _M_default_append(__new_size -
size());
1017 else if (__new_size <
size())
1018 _M_erase_at_end(this->_M_impl._M_start + __new_size);
1032 _GLIBCXX20_CONSTEXPR
1034 resize(size_type __new_size,
const value_type& __x)
1036 if (__new_size >
size())
1037 _M_fill_insert(
end(), __new_size -
size(), __x);
1038 else if (__new_size <
size())
1039 _M_erase_at_end(this->_M_impl._M_start + __new_size);
1053 _GLIBCXX20_CONSTEXPR
1055 resize(size_type __new_size, value_type __x = value_type())
1057 if (__new_size >
size())
1058 _M_fill_insert(
end(), __new_size -
size(), __x);
1059 else if (__new_size <
size())
1060 _M_erase_at_end(this->_M_impl._M_start + __new_size);
1064#if __cplusplus >= 201103L
1066 _GLIBCXX20_CONSTEXPR
1069 { _M_shrink_to_fit(); }
1076 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1080 return size_type(this->_M_impl._M_end_of_storage
1081 - this->_M_impl._M_start);
1088 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1110 _GLIBCXX20_CONSTEXPR
1126 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1130 __glibcxx_requires_subscript(__n);
1131 return *(this->_M_impl._M_start + __n);
1145 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1149 __glibcxx_requires_subscript(__n);
1150 return *(this->_M_impl._M_start + __n);
1155 _GLIBCXX20_CONSTEXPR
1159 if (__n >= this->
size())
1160 __throw_out_of_range_fmt(__N(
"vector::_M_range_check: __n "
1161 "(which is %zu) >= this->size() "
1178 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1183 return (*
this)[__n];
1197 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1202 return (*
this)[__n];
1209 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1213 __glibcxx_requires_nonempty();
1221 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1225 __glibcxx_requires_nonempty();
1233 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1237 __glibcxx_requires_nonempty();
1238 return *(
end() - 1);
1245 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1249 __glibcxx_requires_nonempty();
1250 return *(
end() - 1);
1260 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1263 {
return _M_data_ptr(this->_M_impl._M_start); }
1265 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1267 data() const _GLIBCXX_NOEXCEPT
1268 {
return _M_data_ptr(this->_M_impl._M_start); }
1281 _GLIBCXX20_CONSTEXPR
1285 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
1287 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
1288 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
1290 ++this->_M_impl._M_finish;
1291 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
1294 _M_realloc_append(__x);
1297#if __cplusplus >= 201103L
1298 _GLIBCXX20_CONSTEXPR
1303 template<
typename... _Args>
1304#if __cplusplus > 201402L
1305 _GLIBCXX20_CONSTEXPR
1310 emplace_back(_Args&&... __args);
1322 _GLIBCXX20_CONSTEXPR
1326 __glibcxx_requires_nonempty();
1327 --this->_M_impl._M_finish;
1328 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
1329 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
1332#if __cplusplus >= 201103L
1345 template<
typename... _Args>
1346 _GLIBCXX20_CONSTEXPR
1348 emplace(const_iterator __position, _Args&&... __args)
1349 {
return _M_emplace_aux(__position, std::forward<_Args>(__args)...); }
1362 _GLIBCXX20_CONSTEXPR
1364 insert(const_iterator __position,
const value_type& __x);
1381#if __cplusplus >= 201103L
1393 _GLIBCXX20_CONSTEXPR
1395 insert(const_iterator __position, value_type&& __x)
1396 {
return _M_insert_rval(__position,
std::move(__x)); }
1411 _GLIBCXX20_CONSTEXPR
1415 auto __offset = __position -
cbegin();
1416 _M_range_insert(
begin() + __offset, __l.begin(), __l.end(),
1418 return begin() + __offset;
1422#if __cplusplus >= 201103L
1437 _GLIBCXX20_CONSTEXPR
1439 insert(const_iterator __position, size_type __n,
const value_type& __x)
1441 difference_type __offset = __position -
cbegin();
1442 _M_fill_insert(
begin() + __offset, __n, __x);
1443 return begin() + __offset;
1460 insert(
iterator __position, size_type __n,
const value_type& __x)
1461 { _M_fill_insert(__position, __n, __x); }
1464#if __cplusplus >= 201103L
1480 template<
typename _InputIterator,
1481 typename = std::_RequireInputIter<_InputIterator>>
1482 _GLIBCXX20_CONSTEXPR
1484 insert(const_iterator __position, _InputIterator __first,
1485 _InputIterator __last)
1487 difference_type __offset = __position -
cbegin();
1488 _M_range_insert(
begin() + __offset, __first, __last,
1490 return begin() + __offset;
1507 template<
typename _InputIterator>
1510 _InputIterator __last)
1513 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1514 _M_insert_dispatch(__position, __first, __last, _Integral());
1533 _GLIBCXX20_CONSTEXPR
1535#if __cplusplus >= 201103L
1537 {
return _M_erase(
begin() + (__position -
cbegin())); }
1540 {
return _M_erase(__position); }
1561 _GLIBCXX20_CONSTEXPR
1563#if __cplusplus >= 201103L
1564 erase(const_iterator __first, const_iterator __last)
1566 const auto __beg =
begin();
1567 const auto __cbeg =
cbegin();
1568 return _M_erase(__beg + (__first - __cbeg), __beg + (__last - __cbeg));
1572 {
return _M_erase(__first, __last); }
1586 _GLIBCXX20_CONSTEXPR
1590#if __cplusplus >= 201103L
1591 __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value
1592 || _M_get_Tp_allocator() == __x._M_get_Tp_allocator());
1594 this->_M_impl._M_swap_data(__x._M_impl);
1595 _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(),
1596 __x._M_get_Tp_allocator());
1605 _GLIBCXX20_CONSTEXPR
1608 { _M_erase_at_end(this->_M_impl._M_start); }
1615 template<
typename _ForwardIterator>
1616 _GLIBCXX20_CONSTEXPR
1619 _ForwardIterator __first, _ForwardIterator __last)
1621 pointer __result = this->_M_allocate(__n);
1624 std::__uninitialized_copy_a(__first, __last, __result,
1625 _M_get_Tp_allocator());
1630 _M_deallocate(__result, __n);
1631 __throw_exception_again;
1640#if __cplusplus < 201103L
1643 template<
typename _Integer>
1645 _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
1647 this->_M_impl._M_start = _M_allocate(_S_check_init_len(
1648 static_cast<size_type
>(__n), _M_get_Tp_allocator()));
1649 this->_M_impl._M_end_of_storage =
1650 this->_M_impl._M_start +
static_cast<size_type
>(__n);
1651 _M_fill_initialize(
static_cast<size_type
>(__n), __value);
1655 template<
typename _InputIterator>
1657 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1660 _M_range_initialize(__first, __last,
1666 template<
typename _InputIterator>
1667 _GLIBCXX20_CONSTEXPR
1669 _M_range_initialize(_InputIterator __first, _InputIterator __last,
1673 for (; __first != __last; ++__first)
1674#
if __cplusplus >= 201103L
1675 emplace_back(*__first);
1681 __throw_exception_again;
1686 template<
typename _ForwardIterator>
1687 _GLIBCXX20_CONSTEXPR
1689 _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
1693 this->_M_impl._M_start
1694 = this->_M_allocate(_S_check_init_len(__n, _M_get_Tp_allocator()));
1695 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
1696 this->_M_impl._M_finish =
1697 std::__uninitialized_copy_a(__first, __last,
1698 this->_M_impl._M_start,
1699 _M_get_Tp_allocator());
1704 _GLIBCXX20_CONSTEXPR
1706 _M_fill_initialize(size_type __n,
const value_type& __value)
1708 this->_M_impl._M_finish =
1709 std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value,
1710 _M_get_Tp_allocator());
1713#if __cplusplus >= 201103L
1715 _GLIBCXX20_CONSTEXPR
1717 _M_default_initialize(size_type __n)
1719 this->_M_impl._M_finish =
1720 std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,
1721 _M_get_Tp_allocator());
1732 template<
typename _Integer>
1733 _GLIBCXX20_CONSTEXPR
1735 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1736 { _M_fill_assign(__n, __val); }
1739 template<
typename _InputIterator>
1740 _GLIBCXX20_CONSTEXPR
1742 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1747 template<
typename _InputIterator>
1748 _GLIBCXX20_CONSTEXPR
1750 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1754 template<
typename _ForwardIterator>
1755 _GLIBCXX20_CONSTEXPR
1757 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1762 _GLIBCXX20_CONSTEXPR
1764 _M_fill_assign(size_type __n,
const value_type& __val);
1772 template<
typename _Integer>
1773 _GLIBCXX20_CONSTEXPR
1775 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
1777 { _M_fill_insert(__pos, __n, __val); }
1780 template<
typename _InputIterator>
1781 _GLIBCXX20_CONSTEXPR
1783 _M_insert_dispatch(iterator __pos, _InputIterator __first,
1784 _InputIterator __last, __false_type)
1786 _M_range_insert(__pos, __first, __last,
1791 template<
typename _InputIterator>
1792 _GLIBCXX20_CONSTEXPR
1794 _M_range_insert(iterator __pos, _InputIterator __first,
1798 template<
typename _ForwardIterator>
1799 _GLIBCXX20_CONSTEXPR
1801 _M_range_insert(iterator __pos, _ForwardIterator __first,
1806 _GLIBCXX20_CONSTEXPR
1808 _M_fill_insert(iterator __pos, size_type __n,
const value_type& __x);
1810#if __cplusplus >= 201103L
1812 _GLIBCXX20_CONSTEXPR
1814 _M_default_append(size_type __n);
1816 _GLIBCXX20_CONSTEXPR
1821#if __cplusplus < 201103L
1824 _M_insert_aux(iterator __position,
const value_type& __x);
1827 _M_realloc_insert(iterator __position,
const value_type& __x);
1830 _M_realloc_append(
const value_type& __x);
1834 struct _Temporary_value
1836 template<
typename... _Args>
1837 _GLIBCXX20_CONSTEXPR
explicit
1838 _Temporary_value(
vector* __vec, _Args&&... __args) : _M_this(__vec)
1840 _Alloc_traits::construct(_M_this->_M_impl, _M_ptr(),
1841 std::forward<_Args>(__args)...);
1844 _GLIBCXX20_CONSTEXPR
1846 { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); }
1848 _GLIBCXX20_CONSTEXPR value_type&
1849 _M_val() noexcept {
return _M_storage._M_val; }
1852 _GLIBCXX20_CONSTEXPR _Tp*
1857 constexpr _Storage() : _M_byte() { }
1858 _GLIBCXX20_CONSTEXPR ~_Storage() { }
1859 _Storage& operator=(
const _Storage&) =
delete;
1860 unsigned char _M_byte;
1865 _Storage _M_storage;
1870 template<
typename _Arg>
1871 _GLIBCXX20_CONSTEXPR
1873 _M_insert_aux(iterator __position, _Arg&& __arg);
1875 template<
typename... _Args>
1876 _GLIBCXX20_CONSTEXPR
1878 _M_realloc_insert(iterator __position, _Args&&... __args);
1880 template<
typename... _Args>
1881 _GLIBCXX20_CONSTEXPR
1883 _M_realloc_append(_Args&&... __args);
1886 _GLIBCXX20_CONSTEXPR
1888 _M_insert_rval(const_iterator __position, value_type&& __v);
1891 template<
typename... _Args>
1892 _GLIBCXX20_CONSTEXPR
1894 _M_emplace_aux(const_iterator __position, _Args&&... __args);
1897 _GLIBCXX20_CONSTEXPR
1899 _M_emplace_aux(const_iterator __position, value_type&& __v)
1900 {
return _M_insert_rval(__position,
std::move(__v)); }
1904 _GLIBCXX20_CONSTEXPR
1906 _M_check_len(size_type __n,
const char* __s)
const
1909 __throw_length_error(__N(__s));
1916 static _GLIBCXX20_CONSTEXPR size_type
1917 _S_check_init_len(size_type __n,
const allocator_type& __a)
1919 if (__n > _S_max_size(_Tp_alloc_type(__a)))
1920 __throw_length_error(
1921 __N(
"cannot create std::vector larger than max_size()"));
1925 static _GLIBCXX20_CONSTEXPR size_type
1926 _S_max_size(
const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
1931 const size_t __diffmax
1932 = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max /
sizeof(_Tp);
1934 return (
std::min)(__diffmax, __allocmax);
1941 _GLIBCXX20_CONSTEXPR
1943 _M_erase_at_end(pointer __pos) _GLIBCXX_NOEXCEPT
1945 if (size_type __n = this->_M_impl._M_finish - __pos)
1948 _M_get_Tp_allocator());
1949 this->_M_impl._M_finish = __pos;
1950 _GLIBCXX_ASAN_ANNOTATE_SHRINK(__n);
1954 _GLIBCXX20_CONSTEXPR
1956 _M_erase(iterator __position);
1958 _GLIBCXX20_CONSTEXPR
1960 _M_erase(iterator __first, iterator __last);
1962#if __cplusplus >= 201103L
1967 _GLIBCXX20_CONSTEXPR
1972 this->_M_impl._M_swap_data(__x._M_impl);
1973 __tmp._M_impl._M_swap_data(__x._M_impl);
1974 std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator());
1979 _GLIBCXX20_CONSTEXPR
1983 if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator())
1989 this->_M_assign_aux(std::make_move_iterator(__x.begin()),
1990 std::make_move_iterator(__x.end()),
1997 template<
typename _Up>
1998 _GLIBCXX20_CONSTEXPR
2000 _M_data_ptr(_Up* __ptr)
const _GLIBCXX_NOEXCEPT
2003#if __cplusplus >= 201103L
2004 template<
typename _Ptr>
2005 _GLIBCXX20_CONSTEXPR
2006 typename std::pointer_traits<_Ptr>::element_type*
2007 _M_data_ptr(_Ptr __ptr)
const
2008 {
return empty() ? nullptr : std::__to_address(__ptr); }
2010 template<
typename _Up>
2012 _M_data_ptr(_Up* __ptr) _GLIBCXX_NOEXCEPT
2015 template<
typename _Ptr>
2017 _M_data_ptr(_Ptr __ptr)
2018 {
return empty() ? (value_type*)0 : __ptr.operator->(); }
2020 template<
typename _Ptr>
2022 _M_data_ptr(_Ptr __ptr)
const
2023 {
return empty() ? (
const value_type*)0 : __ptr.operator->(); }
2027#if __cpp_deduction_guides >= 201606
2028 template<
typename _InputIterator,
typename _ValT
2029 =
typename iterator_traits<_InputIterator>::value_type,
2030 typename _Allocator = allocator<_ValT>,
2031 typename = _RequireInputIter<_InputIterator>,
2032 typename = _RequireAllocator<_Allocator>>
2033 vector(_InputIterator, _InputIterator, _Allocator = _Allocator())
2034 -> vector<_ValT, _Allocator>;
2047 template<
typename _Tp,
typename _Alloc>
2048 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2054#if __cpp_lib_three_way_comparison
2066 template<
typename _Tp,
typename _Alloc>
2067 [[nodiscard]] _GLIBCXX20_CONSTEXPR
2068 inline __detail::__synth3way_t<_Tp>
2073 __detail::__synth3way);
2087 template<
typename _Tp,
typename _Alloc>
2088 _GLIBCXX_NODISCARD
inline bool
2089 operator<(
const vector<_Tp, _Alloc>& __x,
const vector<_Tp, _Alloc>& __y)
2090 {
return std::lexicographical_compare(__x.begin(), __x.end(),
2091 __y.begin(), __y.end()); }
2094 template<
typename _Tp,
typename _Alloc>
2095 _GLIBCXX_NODISCARD
inline bool
2096 operator!=(
const vector<_Tp, _Alloc>& __x,
const vector<_Tp, _Alloc>& __y)
2097 {
return !(__x == __y); }
2100 template<
typename _Tp,
typename _Alloc>
2101 _GLIBCXX_NODISCARD
inline bool
2102 operator>(
const vector<_Tp, _Alloc>& __x,
const vector<_Tp, _Alloc>& __y)
2103 {
return __y < __x; }
2106 template<
typename _Tp,
typename _Alloc>
2107 _GLIBCXX_NODISCARD
inline bool
2108 operator<=(
const vector<_Tp, _Alloc>& __x,
const vector<_Tp, _Alloc>& __y)
2109 {
return !(__y < __x); }
2112 template<
typename _Tp,
typename _Alloc>
2113 _GLIBCXX_NODISCARD
inline bool
2114 operator>=(
const vector<_Tp, _Alloc>& __x,
const vector<_Tp, _Alloc>& __y)
2115 {
return !(__x < __y); }
2119 template<
typename _Tp,
typename _Alloc>
2120 _GLIBCXX20_CONSTEXPR
2123 _GLIBCXX_NOEXCEPT_IF(
noexcept(__x.swap(__y)))
2126_GLIBCXX_END_NAMESPACE_CONTAINER
2128#if __cplusplus >= 201703L
2129 namespace __detail::__variant
2131 template<
typename>
struct _Never_valueless_alt;
2135 template<
typename _Tp,
typename _Alloc>
2136 struct _Never_valueless_alt<_GLIBCXX_STD_C::vector<_Tp, _Alloc>>
2142_GLIBCXX_END_NAMESPACE_VERSION