62#if __cplusplus >= 201103L
66#if __cplusplus > 201703L
72namespace std _GLIBCXX_VISIBILITY(default)
74_GLIBCXX_BEGIN_NAMESPACE_VERSION
75_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
91#ifndef _GLIBCXX_DEQUE_BUF_SIZE
92#define _GLIBCXX_DEQUE_BUF_SIZE 512
95 _GLIBCXX_CONSTEXPR
inline size_t
96 __deque_buf_size(
size_t __size)
112 template<
typename _Tp,
typename _Ref,
typename _Ptr>
115#if __cplusplus < 201103L
118 typedef _Tp* _Elt_pointer;
119 typedef _Tp** _Map_pointer;
122 template<
typename _CvTp>
131 static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT
132 {
return __deque_buf_size(
sizeof(_Tp)); }
135 typedef _Tp value_type;
136 typedef _Ptr pointer;
137 typedef _Ref reference;
138 typedef size_t size_type;
139 typedef ptrdiff_t difference_type;
143 _Elt_pointer _M_first;
144 _Elt_pointer _M_last;
145 _Map_pointer _M_node;
148 : _M_cur(__x), _M_first(*__y),
149 _M_last(*__y + _S_buffer_size()), _M_node(__y) { }
152 : _M_cur(), _M_first(), _M_last(), _M_node() { }
154#if __cplusplus < 201103L
157 : _M_cur(__x._M_cur), _M_first(__x._M_first),
158 _M_last(__x._M_last), _M_node(__x._M_node) { }
161 template<
typename _Iter,
162 typename = _Require<is_same<_Self, const_iterator>,
165 : _M_cur(__x._M_cur), _M_first(__x._M_first),
166 _M_last(__x._M_last), _M_node(__x._M_node) { }
169 : _M_cur(__x._M_cur), _M_first(__x._M_first),
170 _M_last(__x._M_last), _M_node(__x._M_node) { }
176 _M_const_cast()
const _GLIBCXX_NOEXCEPT
177 {
return iterator(_M_cur, _M_node); }
180 operator*()
const _GLIBCXX_NOEXCEPT
184 operator->()
const _GLIBCXX_NOEXCEPT
188 operator++() _GLIBCXX_NOEXCEPT
191 if (_M_cur == _M_last)
200 operator++(
int) _GLIBCXX_NOEXCEPT
208 operator--() _GLIBCXX_NOEXCEPT
210 if (_M_cur == _M_first)
220 operator--(
int) _GLIBCXX_NOEXCEPT
228 operator+=(difference_type __n) _GLIBCXX_NOEXCEPT
230 const difference_type __offset = __n + (_M_cur - _M_first);
231 if (__offset >= 0 && __offset < difference_type(_S_buffer_size()))
235 const difference_type __node_offset =
236 __offset > 0 ? __offset / difference_type(_S_buffer_size())
237 : -difference_type((-__offset - 1)
238 / _S_buffer_size()) - 1;
240 _M_cur = _M_first + (__offset - __node_offset
241 * difference_type(_S_buffer_size()));
247 operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
248 {
return *
this += -__n; }
251 operator[](difference_type __n)
const _GLIBCXX_NOEXCEPT
252 {
return *(*
this + __n); }
262 _M_node = __new_node;
263 _M_first = *__new_node;
264 _M_last = _M_first + difference_type(_S_buffer_size());
268 operator==(
const _Self& __x,
const _Self& __y) _GLIBCXX_NOEXCEPT
269 {
return __x._M_cur == __y._M_cur; }
274 template<
typename _RefR,
typename _PtrR>
276 operator==(
const _Self& __x,
277 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
279 {
return __x._M_cur == __y._M_cur; }
281#if __cpp_lib_three_way_comparison
282 friend strong_ordering
283 operator<=>(
const _Self& __x,
const _Self& __y)
noexcept
285 if (
const auto __cmp = __x._M_node <=> __y._M_node; __cmp != 0)
287 return __x._M_cur <=> __y._M_cur;
291 operator!=(
const _Self& __x,
const _Self& __y) _GLIBCXX_NOEXCEPT
292 {
return !(__x == __y); }
294 template<
typename _RefR,
typename _PtrR>
296 operator!=(
const _Self& __x,
297 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
299 {
return !(__x == __y); }
302 operator<(
const _Self& __x,
const _Self& __y) _GLIBCXX_NOEXCEPT
304 return (__x._M_node == __y._M_node)
305 ? (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node);
308 template<
typename _RefR,
typename _PtrR>
310 operator<(
const _Self& __x,
311 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
314 return (__x._M_node == __y._M_node)
315 ? (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node);
319 operator>(
const _Self& __x,
const _Self& __y) _GLIBCXX_NOEXCEPT
320 {
return __y < __x; }
322 template<
typename _RefR,
typename _PtrR>
324 operator>(
const _Self& __x,
325 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
327 {
return __y < __x; }
330 operator<=(
const _Self& __x,
const _Self& __y) _GLIBCXX_NOEXCEPT
331 {
return !(__y < __x); }
333 template<
typename _RefR,
typename _PtrR>
335 operator<=(
const _Self& __x,
336 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
338 {
return !(__y < __x); }
341 operator>=(
const _Self& __x,
const _Self& __y) _GLIBCXX_NOEXCEPT
342 {
return !(__x < __y); }
344 template<
typename _RefR,
typename _PtrR>
346 operator>=(
const _Self& __x,
347 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
349 {
return !(__x < __y); }
352 friend difference_type
353 operator-(
const _Self& __x,
const _Self& __y) _GLIBCXX_NOEXCEPT
355 return difference_type(_S_buffer_size())
356 * (__x._M_node - __y._M_node - bool(__x._M_node))
357 + (__x._M_cur - __x._M_first)
358 + (__y._M_last - __y._M_cur);
365 template<
typename _RefR,
typename _PtrR>
366 friend difference_type
367 operator-(
const _Self& __x,
368 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
371 return difference_type(_S_buffer_size())
372 * (__x._M_node - __y._M_node - bool(__x._M_node))
373 + (__x._M_cur - __x._M_first)
374 + (__y._M_last - __y._M_cur);
378 operator+(
const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
386 operator-(
const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
394 operator+(difference_type __n,
const _Self& __x) _GLIBCXX_NOEXCEPT
395 {
return __x + __n; }
408 template<
typename _Tp,
typename _Alloc>
413 rebind<_Tp>::other _Tp_alloc_type;
416#if __cplusplus < 201103L
418 typedef const _Tp* _Ptr_const;
420 typedef typename _Alloc_traits::pointer _Ptr;
421 typedef typename _Alloc_traits::const_pointer _Ptr_const;
424 typedef typename _Alloc_traits::template rebind<_Ptr>::other
428 typedef _Alloc allocator_type;
431 get_allocator()
const _GLIBCXX_NOEXCEPT
432 {
return allocator_type(_M_get_Tp_allocator()); }
445 _Deque_base(
const allocator_type& __a,
size_t __num_elements)
453#if __cplusplus >= 201103L
455 : _M_impl(
std::move(__x._M_get_Tp_allocator()))
458 if (__x._M_impl._M_map)
459 this->_M_impl._M_swap_data(__x._M_impl);
463 : _M_impl(
std::move(__x._M_impl), _Tp_alloc_type(__a))
464 { __x._M_initialize_map(0); }
469 if (__x.get_allocator() == __a)
471 if (__x._M_impl._M_map)
474 this->_M_impl._M_swap_data(__x._M_impl);
486 typedef typename iterator::_Map_pointer _Map_pointer;
488 struct _Deque_impl_data
495 _Deque_impl_data() _GLIBCXX_NOEXCEPT
496 : _M_map(), _M_map_size(), _M_start(), _M_finish()
499#if __cplusplus >= 201103L
500 _Deque_impl_data(
const _Deque_impl_data&) =
default;
502 operator=(
const _Deque_impl_data&) =
default;
504 _Deque_impl_data(_Deque_impl_data&& __x) noexcept
505 : _Deque_impl_data(__x)
506 { __x = _Deque_impl_data(); }
510 _M_swap_data(_Deque_impl_data& __x) _GLIBCXX_NOEXCEPT
522 :
public _Tp_alloc_type,
public _Deque_impl_data
524 _Deque_impl() _GLIBCXX_NOEXCEPT_IF(
529 _Deque_impl(
const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
530 : _Tp_alloc_type(__a)
533#if __cplusplus >= 201103L
534 _Deque_impl(_Deque_impl&&) =
default;
536 _Deque_impl(_Tp_alloc_type&& __a) noexcept
540 _Deque_impl(_Deque_impl&& __d, _Tp_alloc_type&& __a)
547 _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
548 {
return this->_M_impl; }
550 const _Tp_alloc_type&
551 _M_get_Tp_allocator()
const _GLIBCXX_NOEXCEPT
552 {
return this->_M_impl; }
555 _M_get_map_allocator()
const _GLIBCXX_NOEXCEPT
556 {
return _Map_alloc_type(_M_get_Tp_allocator()); }
562 return _Traits::allocate(_M_impl, __deque_buf_size(
sizeof(_Tp)));
566 _M_deallocate_node(_Ptr __p) _GLIBCXX_NOEXCEPT
569 _Traits::deallocate(_M_impl, __p, __deque_buf_size(
sizeof(_Tp)));
573 _M_allocate_map(
size_t __n)
575 _Map_alloc_type __map_alloc = _M_get_map_allocator();
580 _M_deallocate_map(_Map_pointer __p,
size_t __n) _GLIBCXX_NOEXCEPT
582 _Map_alloc_type __map_alloc = _M_get_map_allocator();
587 void _M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish);
588 void _M_destroy_nodes(_Map_pointer __nstart,
589 _Map_pointer __nfinish) _GLIBCXX_NOEXCEPT;
590 enum { _S_initial_map_size = 8 };
595 template<
typename _Tp,
typename _Alloc>
596 _Deque_base<_Tp, _Alloc>::
597 ~_Deque_base() _GLIBCXX_NOEXCEPT
599 if (this->_M_impl._M_map)
601 _M_destroy_nodes(this->_M_impl._M_start._M_node,
602 this->_M_impl._M_finish._M_node + 1);
603 _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
615 template<
typename _Tp,
typename _Alloc>
620 const size_t __num_nodes = (__num_elements / __deque_buf_size(
sizeof(_Tp))
623 this->_M_impl._M_map_size =
std::max((
size_t) _S_initial_map_size,
624 size_t(__num_nodes + 2));
625 this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size);
632 _Map_pointer __nstart = (this->_M_impl._M_map
633 + (this->_M_impl._M_map_size - __num_nodes) / 2);
634 _Map_pointer __nfinish = __nstart + __num_nodes;
637 { _M_create_nodes(__nstart, __nfinish); }
640 _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
641 this->_M_impl._M_map = _Map_pointer();
642 this->_M_impl._M_map_size = 0;
643 __throw_exception_again;
646 this->_M_impl._M_start._M_set_node(__nstart);
647 this->_M_impl._M_finish._M_set_node(__nfinish - 1);
648 this->_M_impl._M_start._M_cur = _M_impl._M_start._M_first;
649 this->_M_impl._M_finish._M_cur = (this->_M_impl._M_finish._M_first
651 % __deque_buf_size(
sizeof(_Tp)));
654 template<
typename _Tp,
typename _Alloc>
662 for (__cur = __nstart; __cur < __nfinish; ++__cur)
663 *__cur = this->_M_allocate_node();
667 _M_destroy_nodes(__nstart, __cur);
668 __throw_exception_again;
672 template<
typename _Tp,
typename _Alloc>
674 _Deque_base<_Tp, _Alloc>::
675 _M_destroy_nodes(_Map_pointer __nstart,
676 _Map_pointer __nfinish) _GLIBCXX_NOEXCEPT
678 for (_Map_pointer __n = __nstart; __n < __nfinish; ++__n)
679 _M_deallocate_node(*__n);
766 template<
typename _Tp,
typename _Alloc = std::allocator<_Tp> >
769#ifdef _GLIBCXX_CONCEPT_CHECKS
771 typedef typename _Alloc::value_type _Alloc_value_type;
772# if __cplusplus < 201103L
773 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
775 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
778#if __cplusplus >= 201103L
780 "std::deque must have a non-const, non-volatile value_type");
781# if __cplusplus > 201703L || defined __STRICT_ANSI__
783 "std::deque must have the same value_type as its allocator");
788 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
790 typedef typename _Base::_Map_pointer _Map_pointer;
793 typedef _Tp value_type;
794 typedef typename _Alloc_traits::pointer pointer;
795 typedef typename _Alloc_traits::const_pointer const_pointer;
796 typedef typename _Alloc_traits::reference reference;
797 typedef typename _Alloc_traits::const_reference const_reference;
802 typedef size_t size_type;
803 typedef ptrdiff_t difference_type;
804 typedef _Alloc allocator_type;
807 static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT
808 {
return __deque_buf_size(
sizeof(_Tp)); }
812 using _Base::_M_create_nodes;
813 using _Base::_M_destroy_nodes;
814 using _Base::_M_allocate_node;
815 using _Base::_M_deallocate_node;
816 using _Base::_M_allocate_map;
817 using _Base::_M_deallocate_map;
818 using _Base::_M_get_Tp_allocator;
824 using _Base::_M_impl;
833#if __cplusplus >= 201103L
847#if __cplusplus >= 201103L
857 deque(size_type __n,
const allocator_type& __a = allocator_type())
858 :
_Base(__a, _S_check_init_len(__n, __a))
859 { _M_default_initialize(); }
869 deque(size_type __n,
const value_type& __value,
870 const allocator_type& __a = allocator_type())
871 :
_Base(__a, _S_check_init_len(__n, __a))
883 deque(size_type __n,
const value_type& __value = value_type(),
884 const allocator_type& __a = allocator_type())
885 : _Base(__a, _S_check_init_len(__n, __a))
899 { std::__uninitialized_copy_a(__x.
begin(), __x.
end(),
900 this->_M_impl._M_start,
901 _M_get_Tp_allocator()); }
903#if __cplusplus >= 201103L
917 { std::__uninitialized_copy_a(__x.
begin(), __x.
end(),
918 this->_M_impl._M_start,
919 _M_get_Tp_allocator()); }
934 if (__x.get_allocator() != __a && !__x.empty())
936 std::__uninitialized_move_a(__x.begin(), __x.end(),
937 this->_M_impl._M_start,
938 _M_get_Tp_allocator());
956 const allocator_type& __a = allocator_type())
979#if __cplusplus >= 201103L
980 template<
typename _InputIterator,
981 typename = std::_RequireInputIter<_InputIterator>>
982 deque(_InputIterator __first, _InputIterator __last,
983 const allocator_type& __a = allocator_type())
990 template<
typename _InputIterator>
991 deque(_InputIterator __first, _InputIterator __last,
992 const allocator_type& __a = allocator_type())
996 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
997 _M_initialize_dispatch(__first, __last, _Integral());
1007 { _M_destroy_data(
begin(),
end(), _M_get_Tp_allocator()); }
1021#if __cplusplus >= 201103L
1034 _M_move_assign1(
std::move(__x), __always_equal{});
1052 _M_assign_aux(__l.begin(), __l.end(),
1069 assign(size_type __n,
const value_type& __val)
1070 { _M_fill_assign(__n, __val); }
1084#if __cplusplus >= 201103L
1085 template<
typename _InputIterator,
1086 typename = std::_RequireInputIter<_InputIterator>>
1088 assign(_InputIterator __first, _InputIterator __last)
1091 template<
typename _InputIterator>
1093 assign(_InputIterator __first, _InputIterator __last)
1095 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1096 _M_assign_dispatch(__first, __last, _Integral());
1100#if __cplusplus >= 201103L
1120 {
return _Base::get_allocator(); }
1129 {
return this->_M_impl._M_start; }
1137 {
return this->_M_impl._M_start; }
1146 {
return this->_M_impl._M_finish; }
1155 {
return this->_M_impl._M_finish; }
1171 const_reverse_iterator
1189 const_reverse_iterator
1193#if __cplusplus >= 201103L
1200 {
return this->_M_impl._M_start; }
1209 {
return this->_M_impl._M_finish; }
1216 const_reverse_iterator
1225 const_reverse_iterator
1234 {
return this->_M_impl._M_finish - this->_M_impl._M_start; }
1239 {
return _S_max_size(_M_get_Tp_allocator()); }
1241#if __cplusplus >= 201103L
1254 const size_type __len =
size();
1255 if (__new_size > __len)
1256 _M_default_append(__new_size - __len);
1257 else if (__new_size < __len)
1258 _M_erase_at_end(this->_M_impl._M_start
1259 + difference_type(__new_size));
1274 resize(size_type __new_size,
const value_type& __x)
1288 resize(size_type __new_size, value_type __x = value_type())
1291 const size_type __len =
size();
1292 if (__new_size > __len)
1293 _M_fill_insert(this->_M_impl._M_finish, __new_size - __len, __x);
1294 else if (__new_size < __len)
1295 _M_erase_at_end(this->_M_impl._M_start
1296 + difference_type(__new_size));
1299#if __cplusplus >= 201103L
1303 { _M_shrink_to_fit(); }
1310 _GLIBCXX_NODISCARD
bool
1312 {
return this->_M_impl._M_finish == this->_M_impl._M_start; }
1329 __glibcxx_requires_subscript(__n);
1330 return this->_M_impl._M_start[difference_type(__n)];
1347 __glibcxx_requires_subscript(__n);
1348 return this->_M_impl._M_start[difference_type(__n)];
1356 if (__n >= this->
size())
1357 __throw_out_of_range_fmt(__N(
"deque::_M_range_check: __n "
1358 "(which is %zu)>= this->size() "
1379 return (*
this)[__n];
1397 return (*
this)[__n];
1407 __glibcxx_requires_nonempty();
1418 __glibcxx_requires_nonempty();
1429 __glibcxx_requires_nonempty();
1442 __glibcxx_requires_nonempty();
1461 if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first)
1463 _Alloc_traits::construct(this->_M_impl,
1464 this->_M_impl._M_start._M_cur - 1,
1466 --this->_M_impl._M_start._M_cur;
1472#if __cplusplus >= 201103L
1477 template<
typename... _Args>
1478#if __cplusplus > 201402L
1483 emplace_front(_Args&&... __args);
1498 if (this->_M_impl._M_finish._M_cur
1499 != this->_M_impl._M_finish._M_last - 1)
1501 _Alloc_traits::construct(this->_M_impl,
1502 this->_M_impl._M_finish._M_cur, __x);
1503 ++this->_M_impl._M_finish._M_cur;
1509#if __cplusplus >= 201103L
1514 template<
typename... _Args>
1515#if __cplusplus > 201402L
1520 emplace_back(_Args&&... __args);
1534 __glibcxx_requires_nonempty();
1535 if (this->_M_impl._M_start._M_cur
1536 != this->_M_impl._M_start._M_last - 1)
1538 _Alloc_traits::destroy(_M_get_Tp_allocator(),
1539 this->_M_impl._M_start._M_cur);
1540 ++this->_M_impl._M_start._M_cur;
1557 __glibcxx_requires_nonempty();
1558 if (this->_M_impl._M_finish._M_cur
1559 != this->_M_impl._M_finish._M_first)
1561 --this->_M_impl._M_finish._M_cur;
1562 _Alloc_traits::destroy(_M_get_Tp_allocator(),
1563 this->_M_impl._M_finish._M_cur);
1569#if __cplusplus >= 201103L
1579 template<
typename... _Args>
1581 emplace(const_iterator __position, _Args&&... __args);
1593 insert(const_iterator __position,
const value_type& __x);
1608#if __cplusplus >= 201103L
1635 auto __offset = __p -
cbegin();
1636 _M_range_insert_aux(__p._M_const_cast(), __l.begin(), __l.end(),
1638 return begin() + __offset;
1654 difference_type __offset = __position -
cbegin();
1655 _M_fill_insert(__position._M_const_cast(), __n, __x);
1656 return begin() + __offset;
1669 insert(
iterator __position, size_type __n,
const value_type& __x)
1670 { _M_fill_insert(__position, __n, __x); }
1673#if __cplusplus >= 201103L
1685 template<
typename _InputIterator,
1686 typename = std::_RequireInputIter<_InputIterator>>
1689 _InputIterator __last)
1691 difference_type __offset = __position -
cbegin();
1692 _M_range_insert_aux(__position._M_const_cast(), __first, __last,
1694 return begin() + __offset;
1707 template<
typename _InputIterator>
1710 _InputIterator __last)
1713 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1714 _M_insert_dispatch(__position, __first, __last, _Integral());
1732#if __cplusplus >= 201103L
1737 {
return _M_erase(__position._M_const_cast()); }
1756#if __cplusplus >= 201103L
1761 {
return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }
1777#if __cplusplus >= 201103L
1778 __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value
1779 || _M_get_Tp_allocator() == __x._M_get_Tp_allocator());
1781 _M_impl._M_swap_data(__x._M_impl);
1782 _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(),
1783 __x._M_get_Tp_allocator());
1794 { _M_erase_at_end(
begin()); }
1799#if __cplusplus < 201103L
1804 template<
typename _Integer>
1806 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1808 _M_initialize_map(_S_check_init_len(
static_cast<size_type
>(__n),
1809 _M_get_Tp_allocator()));
1814 template<
typename _InputIterator>
1816 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1825 _S_check_init_len(
size_t __n,
const allocator_type& __a)
1827 if (__n > _S_max_size(__a))
1828 __throw_length_error(
1829 __N(
"cannot create std::deque larger than max_size()"));
1834 _S_max_size(
const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
1836 const size_t __diffmax = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max;
1838 return (
std::min)(__diffmax, __allocmax);
1853 template<
typename _InputIterator>
1859 template<
typename _ForwardIterator>
1878#if __cplusplus >= 201103L
1881 _M_default_initialize();
1887#if __cplusplus < 201103L
1892 template<
typename _Integer>
1894 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1895 { _M_fill_assign(__n, __val); }
1898 template<
typename _InputIterator>
1900 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1906 template<
typename _InputIterator>
1908 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1912 template<
typename _ForwardIterator>
1914 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1920 _ForwardIterator __mid = __first;
1922 std::copy(__first, __mid,
begin());
1923 _M_range_insert_aux(
end(), __mid, __last,
1927 _M_erase_at_end(std::copy(__first, __last,
begin()));
1933 _M_fill_assign(size_type __n,
const value_type& __val)
1938 _M_fill_insert(
end(), __n -
size(), __val);
1942 _M_erase_at_end(
begin() + difference_type(__n));
1949#if __cplusplus < 201103L
1954 template<
typename... _Args>
1957 template<
typename... _Args>
1969#if __cplusplus < 201103L
1974 template<
typename _Integer>
1976 _M_insert_dispatch(iterator __pos,
1977 _Integer __n, _Integer __x, __true_type)
1978 { _M_fill_insert(__pos, __n, __x); }
1981 template<
typename _InputIterator>
1983 _M_insert_dispatch(iterator __pos,
1984 _InputIterator __first, _InputIterator __last,
1987 _M_range_insert_aux(__pos, __first, __last,
1993 template<
typename _InputIterator>
1995 _M_range_insert_aux(iterator __pos, _InputIterator __first,
1999 template<
typename _ForwardIterator>
2001 _M_range_insert_aux(iterator __pos, _ForwardIterator __first,
2008 _M_fill_insert(iterator __pos, size_type __n,
const value_type& __x);
2011#if __cplusplus < 201103L
2013 _M_insert_aux(iterator __pos,
const value_type& __x);
2015 template<
typename... _Args>
2017 _M_insert_aux(iterator __pos, _Args&&... __args);
2022 _M_insert_aux(iterator __pos, size_type __n,
const value_type& __x);
2025 template<
typename _ForwardIterator>
2027 _M_insert_aux(iterator __pos,
2028 _ForwardIterator __first, _ForwardIterator __last,
2035 _M_destroy_data_aux(iterator __first, iterator __last);
2039 template<
typename _Alloc1>
2041 _M_destroy_data(iterator __first, iterator __last,
const _Alloc1&)
2042 { _M_destroy_data_aux(__first, __last); }
2045 _M_destroy_data(iterator __first, iterator __last,
2048 if (!__has_trivial_destructor(value_type))
2049 _M_destroy_data_aux(__first, __last);
2054 _M_erase_at_begin(iterator __pos)
2056 _M_destroy_data(
begin(), __pos, _M_get_Tp_allocator());
2057 _M_destroy_nodes(this->_M_impl._M_start._M_node, __pos._M_node);
2058 this->_M_impl._M_start = __pos;
2064 _M_erase_at_end(iterator __pos)
2066 _M_destroy_data(__pos,
end(), _M_get_Tp_allocator());
2067 _M_destroy_nodes(__pos._M_node + 1,
2068 this->_M_impl._M_finish._M_node + 1);
2069 this->_M_impl._M_finish = __pos;
2073 _M_erase(iterator __pos);
2076 _M_erase(iterator __first, iterator __last);
2078#if __cplusplus >= 201103L
2081 _M_default_append(size_type __n);
2092 const size_type __vacancies = this->_M_impl._M_start._M_cur
2093 - this->_M_impl._M_start._M_first;
2094 if (__n > __vacancies)
2096 return this->_M_impl._M_start - difference_type(__n);
2102 const size_type __vacancies = (this->_M_impl._M_finish._M_last
2103 - this->_M_impl._M_finish._M_cur) - 1;
2104 if (__n > __vacancies)
2106 return this->_M_impl._M_finish + difference_type(__n);
2128 if (__nodes_to_add + 1 > this->_M_impl._M_map_size
2129 - (this->_M_impl._M_finish._M_node - this->_M_impl._M_map))
2136 if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node
2137 - this->_M_impl._M_map))
2145#if __cplusplus >= 201103L
2151 this->_M_impl._M_swap_data(__x._M_impl);
2153 std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator());
2162 if (_M_get_Tp_allocator() == __x._M_get_Tp_allocator())
2165 constexpr bool __move_storage =
2166 _Alloc_traits::_S_propagate_on_move_assign();
2167 _M_move_assign2(
std::move(__x), __bool_constant<__move_storage>());
2172 template<
typename... _Args>
2174 _M_replace_map(_Args&&... __args)
2177 deque __newobj(std::forward<_Args>(__args)...);
2180 _M_deallocate_node(*
begin()._M_node);
2181 _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
2182 this->_M_impl._M_map =
nullptr;
2183 this->_M_impl._M_map_size = 0;
2185 this->_M_impl._M_swap_data(__newobj._M_impl);
2193 auto __alloc = __x._M_get_Tp_allocator();
2198 _M_get_Tp_allocator() =
std::move(__alloc);
2206 if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator())
2210 _M_replace_map(
std::move(__x), __x.get_allocator());
2216 _M_assign_aux(std::make_move_iterator(__x.begin()),
2217 std::make_move_iterator(__x.end()),
2225#if __cpp_deduction_guides >= 201606
2226 template<
typename _InputIterator,
typename _ValT
2227 =
typename iterator_traits<_InputIterator>::value_type,
2228 typename _Allocator = allocator<_ValT>,
2229 typename = _RequireInputIter<_InputIterator>,
2230 typename = _RequireAllocator<_Allocator>>
2231 deque(_InputIterator, _InputIterator, _Allocator = _Allocator())
2232 -> deque<_ValT, _Allocator>;
2245 template<
typename _Tp,
typename _Alloc>
2251#if __cpp_lib_three_way_comparison
2263 template<
typename _Tp,
typename _Alloc>
2264 inline __detail::__synth3way_t<_Tp>
2265 operator<=>(
const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
2267 return std::lexicographical_compare_three_way(__x.begin(), __x.end(),
2268 __y.begin(), __y.end(),
2269 __detail::__synth3way);
2283 template<
typename _Tp,
typename _Alloc>
2286 {
return std::lexicographical_compare(__x.
begin(), __x.
end(),
2290 template<
typename _Tp,
typename _Alloc>
2293 {
return !(__x == __y); }
2296 template<
typename _Tp,
typename _Alloc>
2299 {
return __y < __x; }
2302 template<
typename _Tp,
typename _Alloc>
2305 {
return !(__y < __x); }
2308 template<
typename _Tp,
typename _Alloc>
2311 {
return !(__x < __y); }
2315 template<
typename _Tp,
typename _Alloc>
2318 _GLIBCXX_NOEXCEPT_IF(
noexcept(__x.swap(__y)))
2321#undef _GLIBCXX_DEQUE_BUF_SIZE
2323_GLIBCXX_END_NAMESPACE_CONTAINER
2325#if __cplusplus >= 201103L
2329 struct __is_bitwise_relocatable<_GLIBCXX_STD_C::deque<_Tp>>
2333_GLIBCXX_END_NAMESPACE_VERSION
#define _GLIBCXX_DEQUE_BUF_SIZE
This function controls the size of memory nodes.
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 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 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.
typename pointer_traits< _Ptr >::template rebind< _Tp > __ptr_rebind
Convenience alias for rebinding pointers.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
is_nothrow_default_constructible
__detected_or_t< typename is_empty< _Alloc >::type, __equal, _Alloc > is_always_equal
Whether all instances of the allocator type compare equal.
The standard allocator, as per C++03 [20.4.1].
void _M_set_node(_Map_pointer __new_node) noexcept
void _M_initialize_map(size_t)
Layout storage.
A standard container using fixed-size memory allocation and constant-time manipulation of elements at...
reverse_iterator rbegin() noexcept
deque(const deque &__x)
Deque copy constructor.
const_reference at(size_type __n) const
Provides access to the data contained in the deque.
deque(const deque &__x, const allocator_type &__a)
Copy constructor with alternative allocator.
deque(deque &&__x, const allocator_type &__a)
Move constructor with alternative allocator.
reverse_iterator rend() noexcept
iterator erase(const_iterator __position)
Remove element at given position.
const_reference back() const noexcept
const_reverse_iterator crend() const noexcept
void _M_pop_front_aux()
Helper functions for push_* and pop_*.
void pop_back() noexcept
Removes last element.
size_type size() const noexcept
void _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front)
Memory-handling helpers for the major map.
const_iterator cbegin() const noexcept
void resize(size_type __new_size)
Resizes the deque to the specified number of elements.
const_reverse_iterator rend() const noexcept
iterator _M_reserve_elements_at_front(size_type __n)
Memory-handling helpers for the previous internal insert functions.
iterator emplace(const_iterator __position, _Args &&... __args)
Inserts an object in deque before specified iterator.
void pop_front() noexcept
Removes first element.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
void swap(deque &__x) noexcept
Swaps data with another deque.
reference operator[](size_type __n) noexcept
Subscript access to the data contained in the deque.
reference at(size_type __n)
Provides access to the data contained in the deque.
deque(size_type __n, const allocator_type &__a=allocator_type())
Creates a deque with default constructed elements.
bool empty() const noexcept
const_reference operator[](size_type __n) const noexcept
Subscript access to the data contained in the deque.
size_type max_size() const noexcept
void push_front(const value_type &__x)
Add data to the front of the deque.
void resize(size_type __new_size, const value_type &__x)
Resizes the deque to the specified number of elements.
const_reference front() const noexcept
void assign(size_type __n, const value_type &__val)
Assigns a given value to a deque.
deque & operator=(initializer_list< value_type > __l)
Assigns an initializer list to a deque.
void _M_fill_initialize(const value_type &__value)
Fills the deque with copies of value.
iterator insert(const_iterator __position, const value_type &__x)
Inserts given value into deque before specified iterator.
void _M_new_elements_at_back(size_type __new_elements)
Memory-handling helpers for the previous internal insert functions.
iterator insert(const_iterator __p, initializer_list< value_type > __l)
Inserts an initializer list into the deque.
deque(size_type __n, const value_type &__value, const allocator_type &__a=allocator_type())
Creates a deque with copies of an exemplar element.
const_reverse_iterator crbegin() const noexcept
void _M_reserve_map_at_back(size_type __nodes_to_add=1)
Memory-handling helpers for the major map.
reference back() noexcept
void _M_new_elements_at_front(size_type __new_elements)
Memory-handling helpers for the previous internal insert functions.
deque()=default
Creates a deque with no elements.
void _M_push_back_aux(_Args &&... __args)
Helper functions for push_* and pop_*.
deque & operator=(deque &&__x) noexcept(_Alloc_traits::_S_always_equal())
Deque move assignment operator.
void push_back(const value_type &__x)
Add data to the end of the deque.
deque(const allocator_type &__a)
Creates a deque with no elements.
void _M_reserve_map_at_front(size_type __nodes_to_add=1)
Memory-handling helpers for the major map.
void _M_push_front_aux(_Args &&... __args)
Helper functions for push_* and pop_*.
void _M_range_check(size_type __n) const
Safety check used only from at().
void assign(initializer_list< value_type > __l)
Assigns an initializer list to a deque.
deque(initializer_list< value_type > __l, const allocator_type &__a=allocator_type())
Builds a deque from an initializer list.
void shrink_to_fit() noexcept
void assign(_InputIterator __first, _InputIterator __last)
Assigns a range to a deque.
deque(_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
Builds a deque from a range.
const_iterator begin() const noexcept
deque & operator=(const deque &__x)
Deque assignment operator.
const_iterator end() const noexcept
iterator insert(const_iterator __position, size_type __n, const value_type &__x)
Inserts a number of copies of given data into the deque.
iterator insert(const_iterator __position, value_type &&__x)
Inserts given rvalue into deque before specified iterator.
void _M_pop_back_aux()
Helper functions for push_* and pop_*.
void _M_range_initialize(_InputIterator __first, _InputIterator __last, std::input_iterator_tag)
Fills the deque with whatever is in [first,last).
reference front() noexcept
iterator _M_reserve_elements_at_back(size_type __n)
Memory-handling helpers for the previous internal insert functions.
const_iterator cend() const noexcept
iterator insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
Inserts a range into the deque.
const_reverse_iterator rbegin() const noexcept
iterator begin() noexcept
iterator erase(const_iterator __first, const_iterator __last)
Remove a range of elements.
deque(deque &&)=default
Deque move constructor.
Forward iterators support a superset of input iterator operations.
Random-access iterators support a superset of bidirectional iterator operations.
Uniform interface to C++98 and C++11 allocators.
static constexpr pointer allocate(_Alloc &__a, size_type __n)
Allocate memory.
static constexpr void deallocate(_Alloc &__a, pointer __p, size_type __n)
Deallocate memory.
static constexpr size_type max_size(const _Tp_alloc_type &__a) noexcept
The maximum supported allocation size.