57 #define _STL_VECTOR_H 1 62 #if __cplusplus >= 201103L 68 #if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR 70 __sanitizer_annotate_contiguous_container(
const void*,
const void*,
71 const void*,
const void*);
74 namespace std _GLIBCXX_VISIBILITY(default)
76 _GLIBCXX_BEGIN_NAMESPACE_VERSION
77 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
80 template<
typename _Tp,
typename _Alloc>
84 rebind<_Tp>::other _Tp_alloc_type;
85 typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer
89 :
public _Tp_alloc_type
93 pointer _M_end_of_storage;
96 : _Tp_alloc_type(), _M_start(), _M_finish(), _M_end_of_storage()
99 _Vector_impl(_Tp_alloc_type
const& __a) _GLIBCXX_NOEXCEPT
100 : _Tp_alloc_type(__a), _M_start(), _M_finish(), _M_end_of_storage()
103 #if __cplusplus >= 201103L 104 _Vector_impl(_Tp_alloc_type&& __a) noexcept
105 : _Tp_alloc_type(std::move(__a)),
106 _M_start(), _M_finish(), _M_end_of_storage()
110 void _M_swap_data(_Vector_impl& __x) _GLIBCXX_NOEXCEPT
112 std::swap(_M_start, __x._M_start);
113 std::swap(_M_finish, __x._M_finish);
114 std::swap(_M_end_of_storage, __x._M_end_of_storage);
117 #if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR 118 template<
typename = _Tp_alloc_type>
122 ::size_type size_type;
124 static void _S_shrink(_Vector_impl&, size_type) { }
125 static void _S_on_dealloc(_Vector_impl&) { }
127 typedef _Vector_impl& _Reinit;
131 _Grow(_Vector_impl&, size_type) { }
132 void _M_grew(size_type) { }
137 template<
typename _Up>
141 ::size_type size_type;
146 _S_adjust(_Vector_impl& __impl, pointer __prev, pointer __curr)
148 __sanitizer_annotate_contiguous_container(__impl._M_start,
149 __impl._M_end_of_storage, __prev, __curr);
153 _S_grow(_Vector_impl& __impl, size_type __n)
154 { _S_adjust(__impl, __impl._M_finish, __impl._M_finish + __n); }
157 _S_shrink(_Vector_impl& __impl, size_type __n)
158 { _S_adjust(__impl, __impl._M_finish + __n, __impl._M_finish); }
161 _S_on_dealloc(_Vector_impl& __impl)
164 _S_adjust(__impl, __impl._M_finish, __impl._M_end_of_storage);
170 explicit _Reinit(_Vector_impl& __impl) : _M_impl(__impl)
173 _S_on_dealloc(_M_impl);
179 if (_M_impl._M_start)
180 _S_adjust(_M_impl, _M_impl._M_end_of_storage,
184 _Vector_impl& _M_impl;
186 #if __cplusplus >= 201103L 187 _Reinit(
const _Reinit&) =
delete;
188 _Reinit& operator=(
const _Reinit&) =
delete;
195 _Grow(_Vector_impl& __impl, size_type __n)
196 : _M_impl(__impl), _M_n(__n)
197 { _S_grow(_M_impl, __n); }
199 ~_Grow() {
if (_M_n) _S_shrink(_M_impl, _M_n); }
201 void _M_grew(size_type __n) { _M_n -= __n; }
203 #if __cplusplus >= 201103L 204 _Grow(
const _Grow&) =
delete;
205 _Grow& operator=(
const _Grow&) =
delete;
208 _Vector_impl& _M_impl;
213 #define _GLIBCXX_ASAN_ANNOTATE_REINIT \ 214 typename _Base::_Vector_impl::template _Asan<>::_Reinit const \ 215 __attribute__((__unused__)) __reinit_guard(this->_M_impl) 216 #define _GLIBCXX_ASAN_ANNOTATE_GROW(n) \ 217 typename _Base::_Vector_impl::template _Asan<>::_Grow \ 218 __attribute__((__unused__)) __grow_guard(this->_M_impl, (n)) 219 #define _GLIBCXX_ASAN_ANNOTATE_GREW(n) __grow_guard._M_grew(n) 220 #define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n) \ 221 _Base::_Vector_impl::template _Asan<>::_S_shrink(this->_M_impl, n) 222 #define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC \ 223 _Base::_Vector_impl::template _Asan<>::_S_on_dealloc(this->_M_impl) 224 #else // ! (_GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR) 225 #define _GLIBCXX_ASAN_ANNOTATE_REINIT 226 #define _GLIBCXX_ASAN_ANNOTATE_GROW(n) 227 #define _GLIBCXX_ASAN_ANNOTATE_GREW(n) 228 #define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n) 229 #define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC 230 #endif // _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR 234 typedef _Alloc allocator_type;
237 _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
238 {
return *static_cast<_Tp_alloc_type*>(&this->_M_impl); }
240 const _Tp_alloc_type&
241 _M_get_Tp_allocator()
const _GLIBCXX_NOEXCEPT
242 {
return *static_cast<const _Tp_alloc_type*>(&this->_M_impl); }
245 get_allocator() const _GLIBCXX_NOEXCEPT
251 _Vector_base(
const allocator_type& __a) _GLIBCXX_NOEXCEPT
254 _Vector_base(
size_t __n)
256 { _M_create_storage(__n); }
258 _Vector_base(
size_t __n,
const allocator_type& __a)
260 { _M_create_storage(__n); }
262 #if __cplusplus >= 201103L 263 _Vector_base(_Tp_alloc_type&& __a) noexcept
264 : _M_impl(std::move(__a)) { }
266 _Vector_base(_Vector_base&& __x) noexcept
267 : _M_impl(std::move(__x._M_get_Tp_allocator()))
268 { this->_M_impl._M_swap_data(__x._M_impl); }
270 _Vector_base(_Vector_base&& __x,
const allocator_type& __a)
273 if (__x.get_allocator() == __a)
274 this->_M_impl._M_swap_data(__x._M_impl);
277 size_t __n = __x._M_impl._M_finish - __x._M_impl._M_start;
278 _M_create_storage(__n);
283 ~_Vector_base() _GLIBCXX_NOEXCEPT
285 _M_deallocate(_M_impl._M_start,
286 _M_impl._M_end_of_storage - _M_impl._M_start);
290 _Vector_impl _M_impl;
293 _M_allocate(
size_t __n)
296 return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer();
300 _M_deallocate(pointer __p,
size_t __n)
304 _Tr::deallocate(_M_impl, __p, __n);
309 _M_create_storage(
size_t __n)
311 this->_M_impl._M_start = this->_M_allocate(__n);
312 this->_M_impl._M_finish = this->_M_impl._M_start;
313 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
338 template<
typename _Tp,
typename _Alloc = std::allocator<_Tp> >
341 #ifdef _GLIBCXX_CONCEPT_CHECKS 343 typedef typename _Alloc::value_type _Alloc_value_type;
344 # if __cplusplus < 201103L 345 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
347 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
350 #if __cplusplus >= 201103L 351 static_assert(
is_same<
typename remove_cv<_Tp>::type, _Tp>::value,
352 "std::vector must have a non-const, non-volatile value_type");
353 # ifdef __STRICT_ANSI__ 355 "std::vector must have the same value_type as its allocator");
360 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
364 typedef _Tp value_type;
365 typedef typename _Base::pointer pointer;
366 typedef typename _Alloc_traits::const_pointer const_pointer;
367 typedef typename _Alloc_traits::reference reference;
368 typedef typename _Alloc_traits::const_reference const_reference;
369 typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;
370 typedef __gnu_cxx::__normal_iterator<const_pointer, vector>
374 typedef size_t size_type;
375 typedef ptrdiff_t difference_type;
376 typedef _Alloc allocator_type;
379 using _Base::_M_allocate;
380 using _Base::_M_deallocate;
381 using _Base::_M_impl;
382 using _Base::_M_get_Tp_allocator;
392 #if __cplusplus >= 201103L 405 #if __cplusplus >= 201103L 417 { _M_default_initialize(__n); }
430 { _M_fill_initialize(__n, __value); }
441 vector(size_type __n,
const value_type& __value = value_type(),
442 const allocator_type& __a = allocator_type())
444 { _M_fill_initialize(__n, __value); }
462 this->_M_impl._M_finish =
463 std::__uninitialized_copy_a(__x.
begin(), __x.
end(),
464 this->_M_impl._M_start,
465 _M_get_Tp_allocator());
468 #if __cplusplus >= 201103L 477 :
_Base(std::move(__x)) { }
483 this->_M_impl._M_finish =
484 std::__uninitialized_copy_a(__x.
begin(), __x.
end(),
485 this->_M_impl._M_start,
486 _M_get_Tp_allocator());
491 noexcept(_Alloc_traits::_S_always_equal())
494 if (__rv.get_allocator() != __m)
496 this->_M_impl._M_finish =
497 std::__uninitialized_move_a(__rv.begin(), __rv.end(),
498 this->_M_impl._M_start,
499 _M_get_Tp_allocator());
519 _M_range_initialize(__l.begin(), __l.end(),
540 #if __cplusplus >= 201103L 541 template<
typename _InputIterator,
542 typename = std::_RequireInputIter<_InputIterator>>
543 vector(_InputIterator __first, _InputIterator __last,
546 { _M_initialize_dispatch(__first, __last, __false_type()); }
548 template<
typename _InputIterator>
549 vector(_InputIterator __first, _InputIterator __last,
550 const allocator_type& __a = allocator_type())
554 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
555 _M_initialize_dispatch(__first, __last, _Integral());
567 std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
568 _M_get_Tp_allocator());
569 _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC;
584 #if __cplusplus >= 201103L 598 constexpr
bool __move_storage =
599 _Alloc_traits::_S_propagate_on_move_assign()
600 || _Alloc_traits::_S_always_equal();
619 this->_M_assign_aux(__l.begin(), __l.end(),
637 { _M_fill_assign(__n, __val); }
651 #if __cplusplus >= 201103L 652 template<
typename _InputIterator,
653 typename = std::_RequireInputIter<_InputIterator>>
655 assign(_InputIterator __first, _InputIterator __last)
656 { _M_assign_dispatch(__first, __last, __false_type()); }
658 template<
typename _InputIterator>
660 assign(_InputIterator __first, _InputIterator __last)
663 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
664 _M_assign_dispatch(__first, __last, _Integral());
668 #if __cplusplus >= 201103L 683 this->_M_assign_aux(__l.begin(), __l.end(),
689 using _Base::get_allocator;
699 {
return iterator(this->_M_impl._M_start); }
708 {
return const_iterator(this->_M_impl._M_start); }
717 {
return iterator(this->_M_impl._M_finish); }
725 end() const _GLIBCXX_NOEXCEPT
726 {
return const_iterator(this->_M_impl._M_finish); }
742 const_reverse_iterator
760 const_reverse_iterator
764 #if __cplusplus >= 201103L 772 {
return const_iterator(this->_M_impl._M_start); }
781 {
return const_iterator(this->_M_impl._M_finish); }
788 const_reverse_iterator
797 const_reverse_iterator
806 {
return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
813 #if __cplusplus >= 201103L 826 if (__new_size >
size())
827 _M_default_append(__new_size -
size());
828 else if (__new_size <
size())
829 _M_erase_at_end(this->_M_impl._M_start + __new_size);
846 if (__new_size >
size())
847 _M_fill_insert(
end(), __new_size -
size(), __x);
848 else if (__new_size <
size())
849 _M_erase_at_end(this->_M_impl._M_start + __new_size);
864 resize(size_type __new_size, value_type __x = value_type())
866 if (__new_size >
size())
867 _M_fill_insert(
end(), __new_size -
size(), __x);
868 else if (__new_size <
size())
869 _M_erase_at_end(this->_M_impl._M_start + __new_size);
873 #if __cplusplus >= 201103L 877 { _M_shrink_to_fit(); }
886 {
return size_type(this->_M_impl._M_end_of_storage
887 - this->_M_impl._M_start); }
932 __glibcxx_requires_subscript(__n);
933 return *(this->_M_impl._M_start + __n);
950 __glibcxx_requires_subscript(__n);
951 return *(this->_M_impl._M_start + __n);
959 if (__n >= this->
size())
960 __throw_out_of_range_fmt(__N(
"vector::_M_range_check: __n " 961 "(which is %zu) >= this->size() " 997 at(size_type __n)
const 1000 return (*
this)[__n];
1010 __glibcxx_requires_nonempty();
1021 __glibcxx_requires_nonempty();
1032 __glibcxx_requires_nonempty();
1033 return *(
end() - 1);
1043 __glibcxx_requires_nonempty();
1044 return *(
end() - 1);
1056 {
return _M_data_ptr(this->_M_impl._M_start); }
1059 data() const _GLIBCXX_NOEXCEPT
1060 {
return _M_data_ptr(this->_M_impl._M_start); }
1076 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
1078 _GLIBCXX_ASAN_ANNOTATE_GROW(1);
1079 _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
1081 ++this->_M_impl._M_finish;
1082 _GLIBCXX_ASAN_ANNOTATE_GREW(1);
1085 _M_realloc_insert(
end(), __x);
1088 #if __cplusplus >= 201103L 1091 { emplace_back(std::move(__x)); }
1093 template<
typename... _Args>
1094 #if __cplusplus > 201402L 1099 emplace_back(_Args&&... __args);
1114 __glibcxx_requires_nonempty();
1115 --this->_M_impl._M_finish;
1116 _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
1117 _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
1120 #if __cplusplus >= 201103L 1133 template<
typename... _Args>
1135 emplace(const_iterator __position, _Args&&... __args)
1136 {
return _M_emplace_aux(__position, std::forward<_Args>(__args)...); }
1150 insert(const_iterator __position,
const value_type& __x);
1167 #if __cplusplus >= 201103L 1181 {
return _M_insert_rval(__position, std::move(__x)); }
1199 auto __offset = __position -
cbegin();
1200 _M_range_insert(
begin() + __offset, __l.begin(), __l.end(),
1202 return begin() + __offset;
1206 #if __cplusplus >= 201103L 1224 difference_type __offset = __position -
cbegin();
1225 _M_fill_insert(
begin() + __offset, __n, __x);
1226 return begin() + __offset;
1243 insert(
iterator __position, size_type __n,
const value_type& __x)
1244 { _M_fill_insert(__position, __n, __x); }
1247 #if __cplusplus >= 201103L 1263 template<
typename _InputIterator,
1264 typename = std::_RequireInputIter<_InputIterator>>
1266 insert(const_iterator __position, _InputIterator __first,
1267 _InputIterator __last)
1269 difference_type __offset = __position -
cbegin();
1270 _M_insert_dispatch(
begin() + __offset,
1271 __first, __last, __false_type());
1272 return begin() + __offset;
1289 template<
typename _InputIterator>
1292 _InputIterator __last)
1295 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1296 _M_insert_dispatch(__position, __first, __last, _Integral());
1316 #if __cplusplus >= 201103L 1318 {
return _M_erase(
begin() + (__position -
cbegin())); }
1321 {
return _M_erase(__position); }
1343 #if __cplusplus >= 201103L 1344 erase(const_iterator __first, const_iterator __last)
1346 const auto __beg =
begin();
1347 const auto __cbeg =
cbegin();
1348 return _M_erase(__beg + (__first - __cbeg), __beg + (__last - __cbeg));
1352 {
return _M_erase(__first, __last); }
1369 #if __cplusplus >= 201103L 1370 __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value
1371 || _M_get_Tp_allocator() == __x._M_get_Tp_allocator());
1373 this->_M_impl._M_swap_data(__x._M_impl);
1374 _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(),
1375 __x._M_get_Tp_allocator());
1386 { _M_erase_at_end(this->_M_impl._M_start); }
1393 template<
typename _ForwardIterator>
1396 _ForwardIterator __first, _ForwardIterator __last)
1398 pointer __result = this->_M_allocate(__n);
1401 std::__uninitialized_copy_a(__first, __last, __result,
1402 _M_get_Tp_allocator());
1407 _M_deallocate(__result, __n);
1408 __throw_exception_again;
1419 template<
typename _Integer>
1421 _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
1423 this->_M_impl._M_start = _M_allocate(static_cast<size_type>(__n));
1424 this->_M_impl._M_end_of_storage =
1425 this->_M_impl._M_start + static_cast<size_type>(__n);
1426 _M_fill_initialize(static_cast<size_type>(__n), __value);
1430 template<
typename _InputIterator>
1432 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1435 typedef typename std::iterator_traits<_InputIterator>::
1436 iterator_category _IterCategory;
1437 _M_range_initialize(__first, __last, _IterCategory());
1441 template<
typename _InputIterator>
1443 _M_range_initialize(_InputIterator __first, _InputIterator __last,
1447 for (; __first != __last; ++__first)
1448 #
if __cplusplus >= 201103L
1449 emplace_back(*__first);
1455 __throw_exception_again;
1460 template<
typename _ForwardIterator>
1462 _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
1466 this->_M_impl._M_start = this->_M_allocate(__n);
1467 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
1468 this->_M_impl._M_finish =
1469 std::__uninitialized_copy_a(__first, __last,
1470 this->_M_impl._M_start,
1471 _M_get_Tp_allocator());
1477 _M_fill_initialize(size_type __n,
const value_type& __value)
1479 this->_M_impl._M_finish =
1480 std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value,
1481 _M_get_Tp_allocator());
1484 #if __cplusplus >= 201103L 1487 _M_default_initialize(size_type __n)
1489 this->_M_impl._M_finish =
1490 std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,
1491 _M_get_Tp_allocator());
1502 template<
typename _Integer>
1504 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1505 { _M_fill_assign(__n, __val); }
1508 template<
typename _InputIterator>
1510 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1515 template<
typename _InputIterator>
1517 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1521 template<
typename _ForwardIterator>
1523 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1529 _M_fill_assign(size_type __n,
const value_type& __val);
1537 template<
typename _Integer>
1539 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
1541 { _M_fill_insert(__pos, __n, __val); }
1544 template<
typename _InputIterator>
1546 _M_insert_dispatch(iterator __pos, _InputIterator __first,
1547 _InputIterator __last, __false_type)
1549 _M_range_insert(__pos, __first, __last,
1554 template<
typename _InputIterator>
1556 _M_range_insert(iterator __pos, _InputIterator __first,
1560 template<
typename _ForwardIterator>
1562 _M_range_insert(iterator __pos, _ForwardIterator __first,
1568 _M_fill_insert(iterator __pos, size_type __n,
const value_type& __x);
1570 #if __cplusplus >= 201103L 1573 _M_default_append(size_type __n);
1579 #if __cplusplus < 201103L 1582 _M_insert_aux(iterator __position,
const value_type& __x);
1585 _M_realloc_insert(iterator __position,
const value_type& __x);
1589 struct _Temporary_value
1591 template<
typename... _Args>
1593 _Temporary_value(
vector* __vec, _Args&&... __args) : _M_this(__vec)
1595 _Alloc_traits::construct(_M_this->_M_impl, _M_ptr(),
1596 std::forward<_Args>(__args)...);
1600 { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); }
1603 _M_val() {
return *_M_ptr(); }
1607 _M_ptr() {
return reinterpret_cast<_Tp*>(&__buf); }
1610 typename aligned_storage<
sizeof(_Tp),
alignof(_Tp)>::type __buf;
1615 template<
typename _Arg>
1617 _M_insert_aux(iterator __position, _Arg&& __arg);
1619 template<
typename... _Args>
1621 _M_realloc_insert(iterator __position, _Args&&... __args);
1625 _M_insert_rval(const_iterator __position, value_type&& __v);
1628 template<
typename... _Args>
1630 _M_emplace_aux(const_iterator __position, _Args&&... __args);
1634 _M_emplace_aux(const_iterator __position, value_type&& __v)
1635 {
return _M_insert_rval(__position, std::move(__v)); }
1640 _M_check_len(size_type __n,
const char* __s)
const 1643 __throw_length_error(__N(__s));
1654 _M_erase_at_end(pointer __pos) _GLIBCXX_NOEXCEPT
1656 if (size_type __n = this->_M_impl._M_finish - __pos)
1659 _M_get_Tp_allocator());
1660 this->_M_impl._M_finish = __pos;
1661 _GLIBCXX_ASAN_ANNOTATE_SHRINK(__n);
1666 _M_erase(iterator __position);
1669 _M_erase(iterator __first, iterator __last);
1671 #if __cplusplus >= 201103L 1680 this->_M_impl._M_swap_data(__tmp._M_impl);
1681 this->_M_impl._M_swap_data(__x._M_impl);
1682 std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator());
1690 if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator())
1696 this->
assign(std::__make_move_if_noexcept_iterator(__x.begin()),
1697 std::__make_move_if_noexcept_iterator(__x.end()));
1703 template<
typename _Up>
1705 _M_data_ptr(_Up* __ptr)
const _GLIBCXX_NOEXCEPT
1708 #if __cplusplus >= 201103L 1709 template<
typename _Ptr>
1711 _M_data_ptr(_Ptr __ptr)
const 1712 {
return empty() ? nullptr : std::__to_address(__ptr); }
1714 template<
typename _Up>
1716 _M_data_ptr(_Up* __ptr) _GLIBCXX_NOEXCEPT
1719 template<
typename _Ptr>
1721 _M_data_ptr(_Ptr __ptr)
1722 {
return empty() ? (value_type*)0 : __ptr.operator->(); }
1724 template<
typename _Ptr>
1726 _M_data_ptr(_Ptr __ptr)
const 1727 {
return empty() ? (
const value_type*)0 : __ptr.operator->(); }
1731 #if __cpp_deduction_guides >= 201606 1732 template<
typename _InputIterator,
typename _ValT
1733 =
typename iterator_traits<_InputIterator>::value_type,
1734 typename _Allocator = allocator<_ValT>,
1735 typename = _RequireInputIter<_InputIterator>,
1736 typename = _RequireAllocator<_Allocator>>
1737 vector(_InputIterator, _InputIterator, _Allocator = _Allocator())
1738 -> vector<_ValT, _Allocator>;
1751 template<
typename _Tp,
typename _Alloc>
1768 template<
typename _Tp,
typename _Alloc>
1775 template<
typename _Tp,
typename _Alloc>
1778 {
return !(__x == __y); }
1781 template<
typename _Tp,
typename _Alloc>
1784 {
return __y < __x; }
1787 template<
typename _Tp,
typename _Alloc>
1790 {
return !(__y < __x); }
1793 template<
typename _Tp,
typename _Alloc>
1796 {
return !(__x < __y); }
1799 template<
typename _Tp,
typename _Alloc>
1802 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
1805 _GLIBCXX_END_NAMESPACE_CONTAINER
1806 _GLIBCXX_END_NAMESPACE_VERSION
A standard container which offers fixed time access to individual elements in any order.
vector() noexcept(is_nothrow_default_constructible< _Alloc >::value)
Creates a vector with no elements.
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
_GLIBCXX17_CONSTEXPR iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
const_reverse_iterator rend() const noexcept
The standard allocator, as per [20.4].
static size_type max_size(const _Tp_alloc_type &__a) noexcept
The maximum supported allocation size.
const_iterator cbegin() const noexcept
reference at(size_type __n)
Provides access to the data contained in the vector.
vector(vector &&__rv, const allocator_type &__m) noexcept(_Alloc_traits::_S_always_equal())
Move constructor with alternative allocator.
const_iterator end() const noexcept
void assign(initializer_list< value_type > __l)
Assigns an initializer list to a vector.
void _Destroy(_Tp *__pointer)
iterator emplace(const_iterator __position, _Args &&... __args)
Inserts an object in vector before specified iterator.
reference front() noexcept
iterator erase(const_iterator __first, const_iterator __last)
Remove a range of elements.
reference back() noexcept
Forward iterators support a superset of input iterator operations.
iterator insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
Inserts a range into the vector.
vector & operator=(initializer_list< value_type > __l)
Vector list assignment operator.
iterator insert(const_iterator __position, initializer_list< value_type > __l)
Inserts an initializer_list into the vector.
void push_back(const value_type &__x)
Add data to the end of the vector.
const_iterator cend() const noexcept
iterator insert(const_iterator __position, const value_type &__x)
Inserts given value into vector before specified iterator.
iterator insert(const_iterator __position, value_type &&__x)
Inserts given rvalue into vector before specified iterator.
reference operator[](size_type __n) noexcept
Subscript access to the data contained in the vector.
const_iterator begin() const noexcept
void assign(_InputIterator __first, _InputIterator __last)
Assigns a range to a vector.
iterator insert(const_iterator __position, size_type __n, const value_type &__x)
Inserts a number of copies of given data into the vector.
const_reference back() const noexcept
vector & operator=(const vector &__x)
Vector assignment operator.
ISO C++ entities toplevel namespace is std.
reverse_iterator rbegin() noexcept
void swap(vector &__x) noexcept
Swaps data with another vector.
void _M_range_check(size_type __n) const
Safety check used only from at().
vector(vector &&__x) noexcept
Vector move constructor.
__detected_or_t< __get_first_arg_t< _Ptr >, __element_type, _Ptr > element_type
The type pointed to.
iterator begin() noexcept
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
vector(const vector &__x, const allocator_type &__a)
Copy constructor with alternative allocator.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
void resize(size_type __new_size, const value_type &__x)
Resizes the vector to the specified number of elements.
size_type max_size() const noexcept
const_reverse_iterator rbegin() const noexcept
vector(size_type __n, const value_type &__value, const allocator_type &__a=allocator_type())
Creates a vector with copies of an exemplar element.
const_reverse_iterator crend() const noexcept
vector(const allocator_type &__a) noexcept
Creates a vector with no elements.
iterator erase(const_iterator __position)
Remove element at given position.
size_type capacity() const noexcept
void resize(size_type __new_size)
Resizes the vector to the specified number of elements.
void pop_back() noexcept
Removes last element.
bool empty() const noexcept
Uniform interface to C++98 and C++11 allocators.
Random-access iterators support a superset of bidirectional iterator operations.
void reserve(size_type __n)
Attempt to preallocate enough memory for specified number of elements.
const_reverse_iterator crbegin() const noexcept
vector & operator=(vector &&__x) noexcept(_Alloc_traits::_S_nothrow_move())
Vector move assignment operator.
reverse_iterator rend() noexcept
const_reference at(size_type __n) const
Provides access to the data contained in the vector.
bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _Compare __comp)
Performs dictionary comparison on ranges.
pointer _M_allocate_and_copy(size_type __n, _ForwardIterator __first, _ForwardIterator __last)
bool equal(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred)
Tests a range for element-wise equality.
vector(const vector &__x)
Vector copy constructor.
vector(_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
Builds a vector from a range.
void assign(size_type __n, const value_type &__val)
Assigns a given value to a vector.
is_nothrow_default_constructible
const_reference operator[](size_type __n) const noexcept
Subscript access to the data contained in the vector.
See bits/stl_deque.h's _Deque_base for an explanation.
size_type size() const noexcept
vector(initializer_list< value_type > __l, const allocator_type &__a=allocator_type())
Builds a vector from an initializer list.
const_reference front() const noexcept
vector(size_type __n, const allocator_type &__a=allocator_type())
Creates a vector with default constructed elements.
_GLIBCXX14_CONSTEXPR const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.