61namespace std _GLIBCXX_VISIBILITY(default)
63_GLIBCXX_BEGIN_NAMESPACE_VERSION
64_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
66#if __cplusplus >= 201103L
67 template <
typename _Tp,
typename _Alloc>
75 for (__cur = this->_M_impl._M_start._M_node;
76 __cur < this->_M_impl._M_finish._M_node;
78 std::__uninitialized_default_a(*__cur, *__cur + _S_buffer_size(),
79 _M_get_Tp_allocator());
80 std::__uninitialized_default_a(this->_M_impl._M_finish._M_first,
81 this->_M_impl._M_finish._M_cur,
82 _M_get_Tp_allocator());
87 _M_get_Tp_allocator());
88 __throw_exception_again;
93 template <
typename _Tp,
typename _Alloc>
100#if __cplusplus >= 201103L
101 if (_Alloc_traits::_S_propagate_on_copy_assign())
103 if (!_Alloc_traits::_S_always_equal()
104 && _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
109 std::__alloc_on_copy(_M_get_Tp_allocator(),
110 __x._M_get_Tp_allocator());
113 std::__alloc_on_copy(_M_get_Tp_allocator(),
114 __x._M_get_Tp_allocator());
117 const size_type __len =
size();
118 if (__len >= __x.
size())
119 _M_erase_at_end(std::copy(__x.
begin(), __x.
end(),
120 this->_M_impl._M_start));
123 const_iterator __mid = __x.
begin() + difference_type(__len);
124 std::copy(__x.
begin(), __mid, this->_M_impl._M_start);
125 _M_range_insert_aux(this->_M_impl._M_finish, __mid, __x.
end(),
132#if __cplusplus >= 201103L
133 template<
typename _Tp,
typename _Alloc>
134 template<
typename... _Args>
135#if __cplusplus > 201402L
136 typename deque<_Tp, _Alloc>::reference
143 if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first)
145 _Alloc_traits::construct(this->_M_impl,
146 this->_M_impl._M_start._M_cur - 1,
148 --this->_M_impl._M_start._M_cur;
152#if __cplusplus > 201402L
157 template<
typename _Tp,
typename _Alloc>
158 template<
typename... _Args>
159#if __cplusplus > 201402L
160 typename deque<_Tp, _Alloc>::reference
167 if (this->_M_impl._M_finish._M_cur
168 != this->_M_impl._M_finish._M_last - 1)
170 _Alloc_traits::construct(this->_M_impl,
171 this->_M_impl._M_finish._M_cur,
173 ++this->_M_impl._M_finish._M_cur;
177#if __cplusplus > 201402L
183#if __cplusplus >= 201103L
184 template<
typename _Tp,
typename _Alloc>
185 template<
typename... _Args>
186 typename deque<_Tp, _Alloc>::iterator
188 emplace(const_iterator __position, _Args&&... __args)
190 if (__position._M_cur == this->_M_impl._M_start._M_cur)
193 return this->_M_impl._M_start;
195 else if (__position._M_cur == this->_M_impl._M_finish._M_cur)
198 iterator __tmp = this->_M_impl._M_finish;
203 return _M_emplace_aux(__position._M_const_cast(),
208 template <
typename _Tp,
typename _Alloc>
209 typename deque<_Tp, _Alloc>::iterator
211#if __cplusplus >= 201103L
212 insert(const_iterator __position,
const value_type& __x)
214 insert(iterator __position,
const value_type& __x)
217 if (__position._M_cur == this->_M_impl._M_start._M_cur)
220 return this->_M_impl._M_start;
222 else if (__position._M_cur == this->_M_impl._M_finish._M_cur)
225 iterator __tmp = this->_M_impl._M_finish;
230 return _M_insert_aux(__position._M_const_cast(), __x);
233 template <
typename _Tp,
typename _Alloc>
234 typename deque<_Tp, _Alloc>::iterator
243 if (__position !=
begin())
244 _GLIBCXX_MOVE_BACKWARD3(
begin(), __position, __next);
250 _GLIBCXX_MOVE3(__next,
end(), __position);
253 return begin() + __index;
256 template <
typename _Tp,
typename _Alloc>
257 typename deque<_Tp, _Alloc>::iterator
261 if (__first == __last)
263 else if (__first ==
begin() && __last ==
end())
272 if (
static_cast<size_type>(__elems_before) <= (
size() - __n) / 2)
274 if (__first !=
begin())
275 _GLIBCXX_MOVE_BACKWARD3(
begin(), __first, __last);
276 _M_erase_at_begin(
begin() + __n);
281 _GLIBCXX_MOVE3(__last,
end(), __first);
282 _M_erase_at_end(
end() - __n);
284 return begin() + __elems_before;
288 template <
typename _Tp,
class _Alloc>
289 template <
typename _InputIterator>
293 std::input_iterator_tag)
296 for (; __first != __last && __cur !=
end(); ++__cur, (void)++__first)
298 if (__first == __last)
299 _M_erase_at_end(__cur);
301 _M_range_insert_aux(
end(), __first, __last,
305 template <
typename _Tp,
typename _Alloc>
310 if (__pos._M_cur == this->_M_impl._M_start._M_cur)
312 iterator __new_start = _M_reserve_elements_at_front(__n);
315 std::__uninitialized_fill_a(__new_start, this->_M_impl._M_start,
316 __x, _M_get_Tp_allocator());
317 this->_M_impl._M_start = __new_start;
321 _M_destroy_nodes(__new_start._M_node,
322 this->_M_impl._M_start._M_node);
323 __throw_exception_again;
326 else if (__pos._M_cur == this->_M_impl._M_finish._M_cur)
328 iterator __new_finish = _M_reserve_elements_at_back(__n);
331 std::__uninitialized_fill_a(this->_M_impl._M_finish,
333 _M_get_Tp_allocator());
334 this->_M_impl._M_finish = __new_finish;
338 _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
339 __new_finish._M_node + 1);
340 __throw_exception_again;
344 _M_insert_aux(__pos, __n, __x);
347#if __cplusplus >= 201103L
348 template <
typename _Tp,
typename _Alloc>
355 iterator __new_finish = _M_reserve_elements_at_back(__n);
358 std::__uninitialized_default_a(this->_M_impl._M_finish,
360 _M_get_Tp_allocator());
361 this->_M_impl._M_finish = __new_finish;
365 _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
366 __new_finish._M_node + 1);
367 __throw_exception_again;
372 template <
typename _Tp,
typename _Alloc>
378 = (this->_M_impl._M_start._M_cur - this->_M_impl._M_start._M_first);
379 if (__front_capacity == 0)
383 = (this->_M_impl._M_finish._M_last - this->_M_impl._M_finish._M_cur);
384 if (__front_capacity + __back_capacity < _S_buffer_size())
387 return std::__shrink_to_fit_aux<deque>::_S_do_it(*
this);
391 template <
typename _Tp,
typename _Alloc>
399 for (__cur = this->_M_impl._M_start._M_node;
400 __cur < this->_M_impl._M_finish._M_node;
402 std::__uninitialized_fill_a(*__cur, *__cur + _S_buffer_size(),
403 __value, _M_get_Tp_allocator());
404 std::__uninitialized_fill_a(this->_M_impl._M_finish._M_first,
405 this->_M_impl._M_finish._M_cur,
406 __value, _M_get_Tp_allocator());
410 std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur),
411 _M_get_Tp_allocator());
412 __throw_exception_again;
416 template <
typename _Tp,
typename _Alloc>
417 template <
typename _InputIterator>
423 this->_M_initialize_map(0);
426 for (; __first != __last; ++__first)
427#
if __cplusplus >= 201103L
428 emplace_back(*__first);
436 __throw_exception_again;
440 template <
typename _Tp,
typename _Alloc>
441 template <
typename _ForwardIterator>
448 this->_M_initialize_map(_S_check_init_len(__n, _M_get_Tp_allocator()));
450 _Map_pointer __cur_node;
453 for (__cur_node = this->_M_impl._M_start._M_node;
454 __cur_node < this->_M_impl._M_finish._M_node;
457 if (__n < _S_buffer_size())
458 __builtin_unreachable();
460 _ForwardIterator __mid = __first;
462 std::__uninitialized_copy_a(__first, __mid, *__cur_node,
463 _M_get_Tp_allocator());
466 std::__uninitialized_copy_a(__first, __last,
467 this->_M_impl._M_finish._M_first,
468 _M_get_Tp_allocator());
473 iterator(*__cur_node, __cur_node),
474 _M_get_Tp_allocator());
475 __throw_exception_again;
480 template<
typename _Tp,
typename _Alloc>
481#if __cplusplus >= 201103L
482 template<
typename... _Args>
493 __throw_length_error(
494 __N(
"cannot create std::deque larger than max_size()"));
497 *(this->_M_impl._M_finish._M_node + 1) = this->_M_allocate_node();
500#if __cplusplus >= 201103L
501 _Alloc_traits::construct(this->_M_impl,
502 this->_M_impl._M_finish._M_cur,
505 this->_M_impl.construct(this->_M_impl._M_finish._M_cur, __t);
507 this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node
509 this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_first;
513 _M_deallocate_node(*(this->_M_impl._M_finish._M_node + 1));
514 __throw_exception_again;
519 template<
typename _Tp,
typename _Alloc>
520#if __cplusplus >= 201103L
521 template<
typename... _Args>
532 __throw_length_error(
533 __N(
"cannot create std::deque larger than max_size()"));
536 *(this->_M_impl._M_start._M_node - 1) = this->_M_allocate_node();
539 this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node
541 this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_last - 1;
542#if __cplusplus >= 201103L
543 _Alloc_traits::construct(this->_M_impl,
544 this->_M_impl._M_start._M_cur,
547 this->_M_impl.construct(this->_M_impl._M_start._M_cur, __t);
552 ++this->_M_impl._M_start;
553 _M_deallocate_node(*(this->_M_impl._M_start._M_node - 1));
554 __throw_exception_again;
559 template <
typename _Tp,
typename _Alloc>
563 _M_deallocate_node(this->_M_impl._M_finish._M_first);
564 this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node - 1);
565 this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_last - 1;
566 _Alloc_traits::destroy(_M_get_Tp_allocator(),
567 this->_M_impl._M_finish._M_cur);
575 template <
typename _Tp,
typename _Alloc>
579 _Alloc_traits::destroy(_M_get_Tp_allocator(),
580 this->_M_impl._M_start._M_cur);
581 _M_deallocate_node(this->_M_impl._M_start._M_first);
582 this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node + 1);
583 this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_first;
586 template <
typename _Tp,
typename _Alloc>
587 template <
typename _InputIterator,
typename _Sentinel>
593 iterator __new_start = _M_reserve_elements_at_front(__n);
596 std::__uninitialized_copy_a(_GLIBCXX_MOVE(__first), __last,
597 __new_start, _M_get_Tp_allocator());
598 this->_M_impl._M_start = __new_start;
602 _M_destroy_nodes(__new_start._M_node,
603 this->_M_impl._M_start._M_node);
604 __throw_exception_again;
608 template <
typename _Tp,
typename _Alloc>
609 template <
typename _InputIterator,
typename _Sentinel>
615 iterator __new_finish = _M_reserve_elements_at_back(__n);
618 std::__uninitialized_copy_a(_GLIBCXX_MOVE(__first), __last,
619 this->_M_impl._M_finish,
620 _M_get_Tp_allocator());
621 this->_M_impl._M_finish = __new_finish;
625 _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
626 __new_finish._M_node + 1);
627 __throw_exception_again;
631 template <
typename _Tp,
typename _Alloc>
632 template <
typename _InputIterator>
636 _InputIterator __first, _InputIterator __last,
637 std::input_iterator_tag)
640 template <
typename _Tp,
typename _Alloc>
641 template <
typename _ForwardIterator>
645 _ForwardIterator __first, _ForwardIterator __last,
646 std::forward_iterator_tag)
649 if (__builtin_expect(__n == 0, 0))
652 if (__pos._M_cur == this->_M_impl._M_start._M_cur)
653 _M_range_prepend(__first, __last, __n);
654 else if (__pos._M_cur == this->_M_impl._M_finish._M_cur)
655 _M_range_append(__first, __last, __n);
657 _M_insert_aux(__pos, __first, __last, __n);
660 template<
typename _Tp,
typename _Alloc>
661#if __cplusplus >= 201103L
662 template<
typename... _Args>
663 typename deque<_Tp, _Alloc>::iterator
672 typename deque<_Tp, _Alloc>::iterator
681 push_front(_GLIBCXX_MOVE(front()));
682 iterator __front1 = this->_M_impl._M_start;
686 __pos = this->_M_impl._M_start + __index;
689 _GLIBCXX_MOVE3(__front2, __pos1, __front1);
693 push_back(_GLIBCXX_MOVE(back()));
694 iterator __back1 = this->_M_impl._M_finish;
698 __pos = this->_M_impl._M_start + __index;
699 _GLIBCXX_MOVE_BACKWARD3(__pos, __back2, __back1);
701#if __cplusplus >= 201103L
709 template <
typename _Tp,
typename _Alloc>
719 iterator __new_start = _M_reserve_elements_at_front(__n);
720 iterator __old_start = this->_M_impl._M_start;
721 __pos = this->_M_impl._M_start + __elems_before;
726 iterator __start_n = (this->_M_impl._M_start
728 std::__uninitialized_move_a(this->_M_impl._M_start,
729 __start_n, __new_start,
730 _M_get_Tp_allocator());
731 this->_M_impl._M_start = __new_start;
732 _GLIBCXX_MOVE3(__start_n, __pos, __old_start);
737 std::__uninitialized_move_fill(this->_M_impl._M_start,
739 this->_M_impl._M_start,
741 _M_get_Tp_allocator());
742 this->_M_impl._M_start = __new_start;
743 std::fill(__old_start, __pos, __x_copy);
748 _M_destroy_nodes(__new_start._M_node,
749 this->_M_impl._M_start._M_node);
750 __throw_exception_again;
755 iterator __new_finish = _M_reserve_elements_at_back(__n);
756 iterator __old_finish = this->_M_impl._M_finish;
759 __pos = this->_M_impl._M_finish - __elems_after;
764 iterator __finish_n = (this->_M_impl._M_finish
766 std::__uninitialized_move_a(__finish_n,
767 this->_M_impl._M_finish,
768 this->_M_impl._M_finish,
769 _M_get_Tp_allocator());
770 this->_M_impl._M_finish = __new_finish;
771 _GLIBCXX_MOVE_BACKWARD3(__pos, __finish_n, __old_finish);
776 std::__uninitialized_fill_move(this->_M_impl._M_finish,
779 this->_M_impl._M_finish,
780 _M_get_Tp_allocator());
781 this->_M_impl._M_finish = __new_finish;
782 std::fill(__pos, __old_finish, __x_copy);
787 _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
788 __new_finish._M_node + 1);
789 __throw_exception_again;
794 template <
typename _Tp,
typename _Alloc>
795 template <
typename _ForwardIterator>
799 _ForwardIterator __first, _ForwardIterator __last,
804 if (
static_cast<size_type>(__elemsbefore) < __length / 2)
806 iterator __new_start = _M_reserve_elements_at_front(__n);
807 iterator __old_start = this->_M_impl._M_start;
808 __pos = this->_M_impl._M_start + __elemsbefore;
813 iterator __start_n = (this->_M_impl._M_start
815 std::__uninitialized_move_a(this->_M_impl._M_start,
816 __start_n, __new_start,
817 _M_get_Tp_allocator());
818 this->_M_impl._M_start = __new_start;
819 _GLIBCXX_MOVE3(__start_n, __pos, __old_start);
824 _ForwardIterator __mid = __first;
826 std::__uninitialized_move_copy(this->_M_impl._M_start,
827 __pos, __first, __mid,
829 _M_get_Tp_allocator());
830 this->_M_impl._M_start = __new_start;
831 std::copy(__mid, __last, __old_start);
836 _M_destroy_nodes(__new_start._M_node,
837 this->_M_impl._M_start._M_node);
838 __throw_exception_again;
843 iterator __new_finish = _M_reserve_elements_at_back(__n);
844 iterator __old_finish = this->_M_impl._M_finish;
847 __pos = this->_M_impl._M_finish - __elemsafter;
852 iterator __finish_n = (this->_M_impl._M_finish
854 std::__uninitialized_move_a(__finish_n,
855 this->_M_impl._M_finish,
856 this->_M_impl._M_finish,
857 _M_get_Tp_allocator());
858 this->_M_impl._M_finish = __new_finish;
859 _GLIBCXX_MOVE_BACKWARD3(__pos, __finish_n, __old_finish);
860 std::copy(__first, __last, __pos);
864 _ForwardIterator __mid = __first;
866 std::__uninitialized_copy_move(__mid, __last, __pos,
867 this->_M_impl._M_finish,
868 this->_M_impl._M_finish,
869 _M_get_Tp_allocator());
870 this->_M_impl._M_finish = __new_finish;
871 std::copy(__first, __mid, __pos);
876 _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
877 __new_finish._M_node + 1);
878 __throw_exception_again;
883#if __glibcxx_containers_ranges
884 template<ranges::forward_range _Rg>
885 auto __advance_dist(_Rg& __rg)
889 ranges::iterator_t<_Rg> __last;
890 ranges::range_difference_t<_Rg> __size;
892 if constexpr (ranges::common_range<_Rg>)
893 return _Res{ranges::end(__rg), ranges::distance(__rg)};
894 else if constexpr (ranges::sized_range<_Rg>)
896 auto const __n = ranges::distance(__rg);
897 auto __it = ranges::begin(__rg);
898 if constexpr (ranges::random_access_range<_Rg>)
901 ranges::advance(__it, ranges::end(__rg));
902 return _Res{__it, __n};
906 auto __it = ranges::begin(__rg);
907 auto const __last = ranges::end(__rg);
908 ranges::range_difference_t<_Rg> __n(0);
909 for (; __it != __last; ++__it)
911 return _Res{__it, __n};
915 template<
typename _Tp,
typename _Alloc>
916 template<__detail::__container_compatible_range<_Tp> _Rg>
924 const auto __ins_idx =
size();
926 return begin() + __ins_idx;
935 const auto __ins_idx = __pos -
cbegin();
936 if constexpr (ranges::forward_range<_Rg>)
938 auto [__last, __n] = __advance_dist(__rg);
939 if (__n != 0) [[likely]]
940 _M_insert_aux(__pos._M_const_cast(),
941 ranges::begin(__rg), __last,
946 auto __first = ranges::begin(__rg);
947 const auto __last = ranges::end(__rg);
948 for (
auto __it = __pos._M_const_cast(); __first != __last;
949 (
void)++__first, ++__it)
950 __it = _M_emplace_aux(__it, *__first);
952 return begin() + __ins_idx;
955 template<
typename _Tp,
typename _Alloc>
956 template<__detail::__container_compatible_range<_Tp> _Rg>
963 else if constexpr (ranges::forward_range<_Rg> || ranges::sized_range<_Rg>)
965 const size_type __n(ranges::distance(__rg));
966 if (__n != 0) [[likely]]
967 _M_range_prepend(ranges::begin(__rg), ranges::end(__rg), __n);
971 struct _Guard_elts_front
979 __self._M_erase_at_begin(__self.begin() + __n);
983 _Guard_elts_front __guard{*
this};
984 auto __first = ranges::begin(__rg);
985 const auto __last = ranges::end(__rg);
986 for (; __first != __last; (void)++__first, ++__guard.__n)
987 emplace_front(*__first);
989 for (
auto __fins =
begin(), __lins =
begin() + __guard.__n;
990 __fins != __lins && __fins != --__lins; ++__fins)
991 std::iter_swap(__fins, __lins);
997 template<
typename _Tp,
typename _Alloc>
998 template<__detail::__container_compatible_range<_Tp> _Rg>
1003 if constexpr (ranges::forward_range<_Rg> || ranges::sized_range<_Rg>)
1005 const size_type __n(ranges::distance(__rg));
1006 if (__n != 0) [[likely]]
1007 _M_range_append(ranges::begin(__rg), ranges::end(__rg), __n);
1011 struct _Guard_elts_back
1014 size_type __n = __self.size();
1018 if (__n < __self.size())
1019 __self._M_erase_at_end(__self.begin() + __n);
1023 _Guard_elts_back __guard{*
this};
1024 auto __first = ranges::begin(__rg);
1025 const auto __last = ranges::end(__rg);
1026 for (; __first != __last; (void)++__first)
1027 emplace_back(*__first);
1029 __guard.__n =
size();
1034 template<
typename _Tp,
typename _Alloc>
1039 for (_Map_pointer __node = __first._M_node + 1;
1040 __node < __last._M_node; ++__node)
1042 _M_get_Tp_allocator());
1044 if (__first._M_node != __last._M_node)
1047 _M_get_Tp_allocator());
1049 _M_get_Tp_allocator());
1053 _M_get_Tp_allocator());
1056 template <
typename _Tp,
typename _Alloc>
1062 __throw_length_error(__N(
"deque::_M_new_elements_at_front"));
1064 const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1)
1065 / _S_buffer_size());
1070 for (__i = 1; __i <= __new_nodes; ++__i)
1071 *(this->_M_impl._M_start._M_node - __i) = this->_M_allocate_node();
1075 for (size_type __j = 1; __j < __i; ++__j)
1076 _M_deallocate_node(*(this->_M_impl._M_start._M_node - __j));
1077 __throw_exception_again;
1081 template <
typename _Tp,
typename _Alloc>
1087 __throw_length_error(__N(
"deque::_M_new_elements_at_back"));
1089 const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1)
1090 / _S_buffer_size());
1095 for (__i = 1; __i <= __new_nodes; ++__i)
1096 *(this->_M_impl._M_finish._M_node + __i) = this->_M_allocate_node();
1100 for (size_type __j = 1; __j < __i; ++__j)
1101 _M_deallocate_node(*(this->_M_impl._M_finish._M_node + __j));
1102 __throw_exception_again;
1106 template <
typename _Tp,
typename _Alloc>
1111 const size_type __old_num_nodes
1112 = this->_M_impl._M_finish._M_node - this->_M_impl._M_start._M_node + 1;
1113 const size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;
1115 _Map_pointer __new_nstart;
1116 if (this->_M_impl._M_map_size > 2 * __new_num_nodes)
1118 __new_nstart = this->_M_impl._M_map + (this->_M_impl._M_map_size
1119 - __new_num_nodes) / 2
1120 + (__add_at_front ? __nodes_to_add : 0);
1121 if (__new_nstart < this->_M_impl._M_start._M_node)
1122 std::copy(this->_M_impl._M_start._M_node,
1123 this->_M_impl._M_finish._M_node + 1,
1126 std::copy_backward(this->_M_impl._M_start._M_node,
1127 this->_M_impl._M_finish._M_node + 1,
1128 __new_nstart + __old_num_nodes);
1132 size_type __new_map_size = this->_M_impl._M_map_size
1133 +
std::max(this->_M_impl._M_map_size,
1134 __nodes_to_add) + 2;
1136 const size_t __bufsz = __deque_buf_size(
sizeof(_Tp));
1137 if (__new_map_size > ((
max_size() + __bufsz - 1) / __bufsz) * 2)
1138 __builtin_unreachable();
1140 _Map_pointer __new_map = this->_M_allocate_map(__new_map_size);
1141 __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
1142 + (__add_at_front ? __nodes_to_add : 0);
1143 std::copy(this->_M_impl._M_start._M_node,
1144 this->_M_impl._M_finish._M_node + 1,
1146 _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
1148 this->_M_impl._M_map = __new_map;
1149 this->_M_impl._M_map_size = __new_map_size;
1152 this->_M_impl._M_start._M_set_node(__new_nstart);
1153 this->_M_impl._M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
1156_GLIBCXX_END_NAMESPACE_CONTAINER
1160 template<
typename _Tp,
typename _VTp>
1162 __fill_a1(
const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __first,
1163 const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __last,
1164 const _VTp& __value)
1166 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter;
1167 if (__first._M_node != __last._M_node)
1169 std::__fill_a1(__first._M_cur, __first._M_last, __value);
1171 for (
typename _Iter::_Map_pointer __node = __first._M_node + 1;
1172 __node < __last._M_node; ++__node)
1173 std::__fill_a1(*__node, *__node + _Iter::_S_buffer_size(), __value);
1175 std::__fill_a1(__last._M_first, __last._M_cur, __value);
1178 std::__fill_a1(__first._M_cur, __last._M_cur, __value);
1181 template<
bool _IsMove,
1182 typename _Tp,
typename _Ref,
typename _Ptr,
typename _OI>
1184 __copy_move_dit(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
1185 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
1188 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter;
1189 if (__first._M_node != __last._M_node)
1192 = std::__copy_move_a1<_IsMove>(__first._M_cur, __first._M_last,
1195 for (
typename _Iter::_Map_pointer __node = __first._M_node + 1;
1196 __node != __last._M_node; ++__node)
1198 = std::__copy_move_a1<_IsMove>(*__node,
1199 *__node + _Iter::_S_buffer_size(),
1202 return std::__copy_move_a1<_IsMove>(__last._M_first, __last._M_cur,
1206 return std::__copy_move_a1<_IsMove>(__first._M_cur, __last._M_cur,
1210 template<
bool _IsMove,
1211 typename _Tp,
typename _Ref,
typename _Ptr,
typename _OI>
1213 __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
1214 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
1216 {
return __copy_move_dit<_IsMove>(__first, __last, __result); }
1218 template<
bool _IsMove,
1219 typename _ITp,
typename _IRef,
typename _IPtr,
typename _OTp>
1220 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
1221 __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
1222 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last,
1223 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result)
1224 {
return __copy_move_dit<_IsMove>(__first, __last, __result); }
1226 template<
bool _IsMove,
typename _II,
typename _Tp>
1227 typename __gnu_cxx::__enable_if<
1228 __is_random_access_iter<_II>::__value,
1229 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
1230 __copy_move_a1(_II __first, _II __last,
1231 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result)
1233 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter;
1240 =
std::min(__len, __result._M_last - __result._M_cur);
1241 std::__copy_move_a1<_IsMove>(__first, __first + __clen,
1252 template<
bool _IsMove,
typename _CharT>
1253 typename __gnu_cxx::__enable_if<
1254 __is_char<_CharT>::__value,
1255 _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type
1259 _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> __result)
1261 if (__first == __last)
1266 const std::ptrdiff_t __len = __result._M_last - __result._M_cur;
1267 const std::ptrdiff_t __nb
1268 = std::__copy_n_a(__first, __len, __result._M_cur,
false)
1279 template<
typename _CharT,
typename _Size>
1280 typename __gnu_cxx::__enable_if<
1281 __is_char<_CharT>::__value,
1282 _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type
1285 _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> __result,
1295 std::__copy_n_a(__it, __len, __result._M_cur, __strict);
1299 while (__size != 0);
1303 template<
bool _IsMove,
1304 typename _Tp,
typename _Ref,
typename _Ptr,
typename _OI>
1306 __copy_move_backward_dit(
1307 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
1308 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
1311 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter;
1312 if (__first._M_node != __last._M_node)
1314 __result = std::__copy_move_backward_a1<_IsMove>(
1315 __last._M_first, __last._M_cur, __result);
1317 for (
typename _Iter::_Map_pointer __node = __last._M_node - 1;
1318 __node != __first._M_node; --__node)
1319 __result = std::__copy_move_backward_a1<_IsMove>(
1320 *__node, *__node + _Iter::_S_buffer_size(), __result);
1322 return std::__copy_move_backward_a1<_IsMove>(
1323 __first._M_cur, __first._M_last, __result);
1326 return std::__copy_move_backward_a1<_IsMove>(
1327 __first._M_cur, __last._M_cur, __result);
1330 template<
bool _IsMove,
1331 typename _Tp,
typename _Ref,
typename _Ptr,
typename _OI>
1333 __copy_move_backward_a1(
1334 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
1335 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
1337 {
return __copy_move_backward_dit<_IsMove>(__first, __last, __result); }
1339 template<
bool _IsMove,
1340 typename _ITp,
typename _IRef,
typename _IPtr,
typename _OTp>
1341 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
1342 __copy_move_backward_a1(
1343 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
1344 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last,
1345 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result)
1346 {
return __copy_move_backward_dit<_IsMove>(__first, __last, __result); }
1348 template<
bool _IsMove,
typename _II,
typename _Tp>
1349 typename __gnu_cxx::__enable_if<
1350 __is_random_access_iter<_II>::__value,
1351 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
1352 __copy_move_backward_a1(_II __first, _II __last,
1353 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result)
1355 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter;
1362 _Tp* __rend = __result._M_cur;
1365 __rlen = _Iter::_S_buffer_size();
1366 __rend = *(__result._M_node - 1) + __rlen;
1370 std::__copy_move_backward_a1<_IsMove>(__last - __clen, __last, __rend);
1380 template<
typename _Tp,
typename _Ref,
typename _Ptr,
typename _II>
1383 const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>& __first1,
1384 const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>& __last1,
1387 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter;
1388 if (__first1._M_node != __last1._M_node)
1390 if (!std::__equal_aux1(__first1._M_cur, __first1._M_last, __first2))
1393 __first2 += __first1._M_last - __first1._M_cur;
1394 for (
typename _Iter::_Map_pointer __node = __first1._M_node + 1;
1395 __node != __last1._M_node;
1396 __first2 += _Iter::_S_buffer_size(), ++__node)
1397 if (!std::__equal_aux1(*__node, *__node + _Iter::_S_buffer_size(),
1401 return std::__equal_aux1(__last1._M_first, __last1._M_cur, __first2);
1404 return std::__equal_aux1(__first1._M_cur, __last1._M_cur, __first2);
1407 template<
typename _Tp,
typename _Ref,
typename _Ptr,
typename _II>
1408 typename __gnu_cxx::__enable_if<
1409 __is_random_access_iter<_II>::__value,
bool>::__type
1410 __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first1,
1411 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last1,
1413 {
return std::__equal_dit(__first1, __last1, __first2); }
1415 template<
typename _Tp1,
typename _Ref1,
typename _Ptr1,
1416 typename _Tp2,
typename _Ref2,
typename _Ptr2>
1418 __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1,
1419 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1,
1420 _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2)
1421 {
return std::__equal_dit(__first1, __last1, __first2); }
1423 template<
typename _II,
typename _Tp,
typename _Ref,
typename _Ptr>
1424 typename __gnu_cxx::__enable_if<
1425 __is_random_access_iter<_II>::__value,
bool>::__type
1426 __equal_aux1(_II __first1, _II __last1,
1427 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first2)
1429 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter;
1436 =
std::min(__len, __first2._M_last - __first2._M_cur);
1437 if (!std::__equal_aux1(__first1, __first1 + __clen, __first2._M_cur))
1448 template<
typename _Tp1,
typename _Ref,
typename _Ptr,
typename _Tp2>
1451 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref, _Ptr> __first1,
1452 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref, _Ptr> __last1,
1453 const _Tp2* __first2,
const _Tp2* __last2)
1455#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer)
1456 const bool __simple =
1457 (__is_memcmp_ordered_with<_Tp1, _Tp2>::__value
1458 && __is_pointer(_Ptr)
1459#if __cplusplus > 201703L && __cpp_lib_concepts
1463 && !is_volatile_v<_Tp1> && !is_volatile_v<_Tp2>
1466 typedef std::__lexicographical_compare<__simple> _Lc;
1468 typedef std::__lexicographical_compare<false> _Lc;
1471 while (__first1._M_node != __last1._M_node)
1473 const ptrdiff_t __len1 = __first1._M_last - __first1._M_cur;
1474 const ptrdiff_t __len2 = __last2 - __first2;
1475 const ptrdiff_t __len =
std::min(__len1, __len2);
1477 if (
int __ret = _Lc::__3way(__first1._M_cur, __first1._M_last,
1478 __first2, __first2 + __len))
1484 return _Lc::__3way(__first1._M_cur, __last1._M_cur,
1488 template<
typename _Tp1,
typename _Ref1,
typename _Ptr1,
1491 __lexicographical_compare_aux1(
1492 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1,
1493 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1,
1494 _Tp2* __first2, _Tp2* __last2)
1495 {
return std::__lex_cmp_dit(__first1, __last1, __first2, __last2) < 0; }
1497 template<
typename _Tp1,
1498 typename _Tp2,
typename _Ref2,
typename _Ptr2>
1500 __lexicographical_compare_aux1(_Tp1* __first1, _Tp1* __last1,
1501 _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2,
1502 _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __last2)
1503 {
return std::__lex_cmp_dit(__first2, __last2, __first1, __last1) > 0; }
1505 template<
typename _Tp1,
typename _Ref1,
typename _Ptr1,
1506 typename _Tp2,
typename _Ref2,
typename _Ptr2>
1508 __lexicographical_compare_aux1(
1509 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1,
1510 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1,
1511 _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2,
1512 _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __last2)
1514#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer)
1515 const bool __simple =
1516 (__is_memcmp_ordered_with<_Tp1, _Tp2>::__value
1517 && __is_pointer(_Ptr1) && __is_pointer(_Ptr2)
1518#if __cplusplus > 201703L && __cpp_lib_concepts
1522 && !is_volatile_v<_Tp1> && !is_volatile_v<_Tp2>
1525 typedef std::__lexicographical_compare<__simple> _Lc;
1527 typedef std::__lexicographical_compare<false> _Lc;
1530 while (__first1 != __last1)
1532 const ptrdiff_t __len2 = __first2._M_node == __last2._M_node
1533 ? __last2._M_cur - __first2._M_cur
1534 : __first2._M_last - __first2._M_cur;
1537 const ptrdiff_t __len1 = __first1._M_node == __last1._M_node
1538 ? __last1._M_cur - __first1._M_cur
1539 : __first1._M_last - __first1._M_cur;
1540 const ptrdiff_t __len =
std::min(__len1, __len2);
1541 if (
int __ret = _Lc::__3way(__first1._M_cur, __first1._M_cur + __len,
1542 __first2._M_cur, __first2._M_cur + __len))
1549 return __last2 != __first2;
1552_GLIBCXX_END_NAMESPACE_VERSION
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
_Tp * end(valarray< _Tp > &__va) noexcept
Return an iterator pointing to one past the last element of the valarray.
_Tp * begin(valarray< _Tp > &__va) noexcept
Return an iterator pointing to the first element of the valarray.
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 &)
constexpr insert_iterator< _Container > inserter(_Container &__x, std::__detail::__range_iter_t< _Container > __i)
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr auto cend(const _Container &__cont) noexcept(noexcept(std::end(__cont))) -> decltype(std::end(__cont))
Return an iterator pointing to one past the last element of the const container.
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
Return whether a container is empty.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
constexpr auto cbegin(const _Container &__cont) noexcept(noexcept(std::begin(__cont))) -> decltype(std::begin(__cont))
Return an iterator pointing to the first element of the const container.
constexpr void _Destroy(_ForwardIterator __first, _ForwardIterator __last)
Provides input iterator semantics for streambufs.
Basis for explicit traits specializations.
A standard container using fixed-size memory allocation and constant-time manipulation of elements at...
void _M_pop_front_aux()
Helper functions for push_* and pop_*.
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.
iterator emplace(const_iterator __position, _Args &&... __args)
Inserts an object in deque before specified iterator.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
size_type max_size() const noexcept
void push_front(const value_type &__x)
Add data to the front of the 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.
void _M_reserve_map_at_back(size_type __nodes_to_add=1)
Memory-handling helpers for the major map.
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_*.
void push_back(const value_type &__x)
Add data to the end of the deque.
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_*.
deque & operator=(const deque &__x)
Deque assignment operator.
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).
iterator begin() noexcept
Forward iterators support a superset of input iterator operations.
Random-access iterators support a superset of bidirectional iterator operations.