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>
70 _M_default_initialize()
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());
86 std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur),
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));
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
165 emplace_back(_Args&&... __args)
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
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>
211#if __cplusplus >= 201103L
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>
240 const difference_type __index = __position -
begin();
241 if (
static_cast<size_type
>(__index) < (
size() >> 1))
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
259 _M_erase(iterator __first, iterator __last)
261 if (__first == __last)
263 else if (__first ==
begin() && __last ==
end())
270 const difference_type __n = __last - __first;
271 const difference_type __elems_before = __first -
begin();
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>
292 _M_assign_aux(_InputIterator __first, _InputIterator __last,
295 iterator __cur =
begin();
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>
308 _M_fill_insert(iterator __pos, size_type __n,
const value_type& __x)
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>
351 _M_default_append(size_type __n)
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>
377 const difference_type __front_capacity
378 = (this->_M_impl._M_start._M_cur - this->_M_impl._M_start._M_first);
379 if (__front_capacity == 0)
382 const difference_type __back_capacity
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());
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());
474 _M_get_Tp_allocator());
475 __throw_exception_again;
480 template<
typename _Tp,
typename _Alloc>
481#if __cplusplus >= 201103L
482 template<
typename... _Args>
492 if (
size() == max_size())
493 __throw_length_error(
494 __N(
"cannot create std::deque larger than max_size()"));
496 _M_reserve_map_at_back();
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>
531 if (
size() == max_size())
532 __throw_length_error(
533 __N(
"cannot create std::deque larger than max_size()"));
535 _M_reserve_map_at_front();
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>
591 _InputIterator __first, _InputIterator __last,
595 template <
typename _Tp,
typename _Alloc>
596 template <
typename _ForwardIterator>
599 _M_range_insert_aux(iterator __pos,
600 _ForwardIterator __first, _ForwardIterator __last,
604 if (__builtin_expect(__n == 0, 0))
607 if (__pos._M_cur == this->_M_impl._M_start._M_cur)
609 iterator __new_start = _M_reserve_elements_at_front(__n);
612 std::__uninitialized_copy_a(__first, __last, __new_start,
613 _M_get_Tp_allocator());
614 this->_M_impl._M_start = __new_start;
618 _M_destroy_nodes(__new_start._M_node,
619 this->_M_impl._M_start._M_node);
620 __throw_exception_again;
623 else if (__pos._M_cur == this->_M_impl._M_finish._M_cur)
625 iterator __new_finish = _M_reserve_elements_at_back(__n);
628 std::__uninitialized_copy_a(__first, __last,
629 this->_M_impl._M_finish,
630 _M_get_Tp_allocator());
631 this->_M_impl._M_finish = __new_finish;
635 _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
636 __new_finish._M_node + 1);
637 __throw_exception_again;
641 _M_insert_aux(__pos, __first, __last, __n);
644 template<
typename _Tp,
typename _Alloc>
645#if __cplusplus >= 201103L
646 template<
typename... _Args>
647 typename deque<_Tp, _Alloc>::iterator
649 _M_emplace_aux(iterator __pos, _Args&&... __args)
653 typename deque<_Tp, _Alloc>::iterator
655 _M_insert_aux(iterator __pos,
const value_type& __x)
657 value_type __x_copy = __x;
659 difference_type __index = __pos - this->_M_impl._M_start;
660 if (
static_cast<size_type
>(__index) <
size() / 2)
662 push_front(_GLIBCXX_MOVE(front()));
663 iterator __front1 = this->_M_impl._M_start;
665 iterator __front2 = __front1;
667 __pos = this->_M_impl._M_start + __index;
668 iterator __pos1 = __pos;
670 _GLIBCXX_MOVE3(__front2, __pos1, __front1);
674 push_back(_GLIBCXX_MOVE(back()));
675 iterator __back1 = this->_M_impl._M_finish;
677 iterator __back2 = __back1;
679 __pos = this->_M_impl._M_start + __index;
680 _GLIBCXX_MOVE_BACKWARD3(__pos, __back2, __back1);
682 *__pos = _GLIBCXX_MOVE(__x_copy);
686 template <
typename _Tp,
typename _Alloc>
689 _M_insert_aux(iterator __pos, size_type __n,
const value_type& __x)
691 const difference_type __elems_before = __pos - this->_M_impl._M_start;
692 const size_type __length = this->
size();
693 value_type __x_copy = __x;
694 if (__elems_before < difference_type(__length / 2))
696 iterator __new_start = _M_reserve_elements_at_front(__n);
697 iterator __old_start = this->_M_impl._M_start;
698 __pos = this->_M_impl._M_start + __elems_before;
701 if (__elems_before >= difference_type(__n))
703 iterator __start_n = (this->_M_impl._M_start
704 + difference_type(__n));
705 std::__uninitialized_move_a(this->_M_impl._M_start,
706 __start_n, __new_start,
707 _M_get_Tp_allocator());
708 this->_M_impl._M_start = __new_start;
709 _GLIBCXX_MOVE3(__start_n, __pos, __old_start);
710 std::fill(__pos - difference_type(__n), __pos, __x_copy);
714 std::__uninitialized_move_fill(this->_M_impl._M_start,
716 this->_M_impl._M_start,
718 _M_get_Tp_allocator());
719 this->_M_impl._M_start = __new_start;
720 std::fill(__old_start, __pos, __x_copy);
725 _M_destroy_nodes(__new_start._M_node,
726 this->_M_impl._M_start._M_node);
727 __throw_exception_again;
732 iterator __new_finish = _M_reserve_elements_at_back(__n);
733 iterator __old_finish = this->_M_impl._M_finish;
734 const difference_type __elems_after =
735 difference_type(__length) - __elems_before;
736 __pos = this->_M_impl._M_finish - __elems_after;
739 if (__elems_after > difference_type(__n))
741 iterator __finish_n = (this->_M_impl._M_finish
742 - difference_type(__n));
743 std::__uninitialized_move_a(__finish_n,
744 this->_M_impl._M_finish,
745 this->_M_impl._M_finish,
746 _M_get_Tp_allocator());
747 this->_M_impl._M_finish = __new_finish;
748 _GLIBCXX_MOVE_BACKWARD3(__pos, __finish_n, __old_finish);
749 std::fill(__pos, __pos + difference_type(__n), __x_copy);
753 std::__uninitialized_fill_move(this->_M_impl._M_finish,
754 __pos + difference_type(__n),
756 this->_M_impl._M_finish,
757 _M_get_Tp_allocator());
758 this->_M_impl._M_finish = __new_finish;
759 std::fill(__pos, __old_finish, __x_copy);
764 _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
765 __new_finish._M_node + 1);
766 __throw_exception_again;
771 template <
typename _Tp,
typename _Alloc>
772 template <
typename _ForwardIterator>
775 _M_insert_aux(iterator __pos,
776 _ForwardIterator __first, _ForwardIterator __last,
779 const difference_type __elemsbefore = __pos - this->_M_impl._M_start;
780 const size_type __length =
size();
781 if (
static_cast<size_type
>(__elemsbefore) < __length / 2)
783 iterator __new_start = _M_reserve_elements_at_front(__n);
784 iterator __old_start = this->_M_impl._M_start;
785 __pos = this->_M_impl._M_start + __elemsbefore;
788 if (__elemsbefore >= difference_type(__n))
790 iterator __start_n = (this->_M_impl._M_start
791 + difference_type(__n));
792 std::__uninitialized_move_a(this->_M_impl._M_start,
793 __start_n, __new_start,
794 _M_get_Tp_allocator());
795 this->_M_impl._M_start = __new_start;
796 _GLIBCXX_MOVE3(__start_n, __pos, __old_start);
797 std::copy(__first, __last, __pos - difference_type(__n));
801 _ForwardIterator __mid = __first;
802 std::advance(__mid, difference_type(__n) - __elemsbefore);
803 std::__uninitialized_move_copy(this->_M_impl._M_start,
804 __pos, __first, __mid,
806 _M_get_Tp_allocator());
807 this->_M_impl._M_start = __new_start;
808 std::copy(__mid, __last, __old_start);
813 _M_destroy_nodes(__new_start._M_node,
814 this->_M_impl._M_start._M_node);
815 __throw_exception_again;
820 iterator __new_finish = _M_reserve_elements_at_back(__n);
821 iterator __old_finish = this->_M_impl._M_finish;
822 const difference_type __elemsafter =
823 difference_type(__length) - __elemsbefore;
824 __pos = this->_M_impl._M_finish - __elemsafter;
827 if (__elemsafter > difference_type(__n))
829 iterator __finish_n = (this->_M_impl._M_finish
830 - difference_type(__n));
831 std::__uninitialized_move_a(__finish_n,
832 this->_M_impl._M_finish,
833 this->_M_impl._M_finish,
834 _M_get_Tp_allocator());
835 this->_M_impl._M_finish = __new_finish;
836 _GLIBCXX_MOVE_BACKWARD3(__pos, __finish_n, __old_finish);
837 std::copy(__first, __last, __pos);
841 _ForwardIterator __mid = __first;
843 std::__uninitialized_copy_move(__mid, __last, __pos,
844 this->_M_impl._M_finish,
845 this->_M_impl._M_finish,
846 _M_get_Tp_allocator());
847 this->_M_impl._M_finish = __new_finish;
848 std::copy(__first, __mid, __pos);
853 _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
854 __new_finish._M_node + 1);
855 __throw_exception_again;
860 template<
typename _Tp,
typename _Alloc>
863 _M_destroy_data_aux(iterator __first, iterator __last)
865 for (_Map_pointer __node = __first._M_node + 1;
866 __node < __last._M_node; ++__node)
868 _M_get_Tp_allocator());
870 if (__first._M_node != __last._M_node)
873 _M_get_Tp_allocator());
875 _M_get_Tp_allocator());
879 _M_get_Tp_allocator());
882 template <
typename _Tp,
typename _Alloc>
887 if (this->max_size() - this->
size() < __new_elems)
888 __throw_length_error(__N(
"deque::_M_new_elements_at_front"));
890 const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1)
892 _M_reserve_map_at_front(__new_nodes);
896 for (__i = 1; __i <= __new_nodes; ++__i)
897 *(this->_M_impl._M_start._M_node - __i) = this->_M_allocate_node();
901 for (size_type __j = 1; __j < __i; ++__j)
902 _M_deallocate_node(*(this->_M_impl._M_start._M_node - __j));
903 __throw_exception_again;
907 template <
typename _Tp,
typename _Alloc>
912 if (this->max_size() - this->
size() < __new_elems)
913 __throw_length_error(__N(
"deque::_M_new_elements_at_back"));
915 const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1)
917 _M_reserve_map_at_back(__new_nodes);
921 for (__i = 1; __i <= __new_nodes; ++__i)
922 *(this->_M_impl._M_finish._M_node + __i) = this->_M_allocate_node();
926 for (size_type __j = 1; __j < __i; ++__j)
927 _M_deallocate_node(*(this->_M_impl._M_finish._M_node + __j));
928 __throw_exception_again;
932 template <
typename _Tp,
typename _Alloc>
937 const size_type __old_num_nodes
938 = this->_M_impl._M_finish._M_node - this->_M_impl._M_start._M_node + 1;
939 const size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;
941 _Map_pointer __new_nstart;
942 if (this->_M_impl._M_map_size > 2 * __new_num_nodes)
944 __new_nstart = this->_M_impl._M_map + (this->_M_impl._M_map_size
945 - __new_num_nodes) / 2
946 + (__add_at_front ? __nodes_to_add : 0);
947 if (__new_nstart < this->_M_impl._M_start._M_node)
948 std::copy(this->_M_impl._M_start._M_node,
949 this->_M_impl._M_finish._M_node + 1,
952 std::copy_backward(this->_M_impl._M_start._M_node,
953 this->_M_impl._M_finish._M_node + 1,
954 __new_nstart + __old_num_nodes);
958 size_type __new_map_size = this->_M_impl._M_map_size
959 +
std::max(this->_M_impl._M_map_size,
962 _Map_pointer __new_map = this->_M_allocate_map(__new_map_size);
963 __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
964 + (__add_at_front ? __nodes_to_add : 0);
965 std::copy(this->_M_impl._M_start._M_node,
966 this->_M_impl._M_finish._M_node + 1,
968 _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
970 this->_M_impl._M_map = __new_map;
971 this->_M_impl._M_map_size = __new_map_size;
974 this->_M_impl._M_start._M_set_node(__new_nstart);
975 this->_M_impl._M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
978_GLIBCXX_END_NAMESPACE_CONTAINER
982 template<
typename _Tp,
typename _VTp>
984 __fill_a1(
const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __first,
985 const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __last,
988 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter;
989 if (__first._M_node != __last._M_node)
991 std::__fill_a1(__first._M_cur, __first._M_last, __value);
993 for (
typename _Iter::_Map_pointer __node = __first._M_node + 1;
994 __node < __last._M_node; ++__node)
995 std::__fill_a1(*__node, *__node + _Iter::_S_buffer_size(), __value);
997 std::__fill_a1(__last._M_first, __last._M_cur, __value);
1000 std::__fill_a1(__first._M_cur, __last._M_cur, __value);
1003 template<
bool _IsMove,
1004 typename _Tp,
typename _Ref,
typename _Ptr,
typename _OI>
1006 __copy_move_dit(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
1007 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
1010 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter;
1011 if (__first._M_node != __last._M_node)
1014 = std::__copy_move_a1<_IsMove>(__first._M_cur, __first._M_last,
1017 for (
typename _Iter::_Map_pointer __node = __first._M_node + 1;
1018 __node != __last._M_node; ++__node)
1020 = std::__copy_move_a1<_IsMove>(*__node,
1021 *__node + _Iter::_S_buffer_size(),
1024 return std::__copy_move_a1<_IsMove>(__last._M_first, __last._M_cur,
1028 return std::__copy_move_a1<_IsMove>(__first._M_cur, __last._M_cur,
1032 template<
bool _IsMove,
1033 typename _Tp,
typename _Ref,
typename _Ptr,
typename _OI>
1035 __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
1036 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
1038 {
return __copy_move_dit<_IsMove>(__first, __last, __result); }
1040 template<
bool _IsMove,
1041 typename _ITp,
typename _IRef,
typename _IPtr,
typename _OTp>
1042 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
1043 __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
1044 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last,
1045 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result)
1046 {
return __copy_move_dit<_IsMove>(__first, __last, __result); }
1048 template<
bool _IsMove,
typename _II,
typename _Tp>
1049 typename __gnu_cxx::__enable_if<
1050 __is_random_access_iter<_II>::__value,
1051 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
1052 __copy_move_a1(_II __first, _II __last,
1053 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result)
1055 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter;
1056 typedef typename _Iter::difference_type difference_type;
1058 difference_type __len = __last - __first;
1061 const difference_type __clen
1062 =
std::min(__len, __result._M_last - __result._M_cur);
1063 std::__copy_move_a1<_IsMove>(__first, __first + __clen,
1074 template<
bool _IsMove,
typename _CharT>
1075 typename __gnu_cxx::__enable_if<
1076 __is_char<_CharT>::__value,
1077 _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type
1079 istreambuf_iterator<_CharT, char_traits<_CharT> > __first,
1080 istreambuf_iterator<_CharT, char_traits<_CharT> > __last,
1081 _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> __result)
1083 if (__first == __last)
1088 const std::ptrdiff_t __len = __result._M_last - __result._M_cur;
1089 const std::ptrdiff_t __nb
1090 = std::__copy_n_a(__first, __len, __result._M_cur,
false)
1101 template<
typename _CharT,
typename _Size>
1102 typename __gnu_cxx::__enable_if<
1103 __is_char<_CharT>::__value,
1104 _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type
1106 istreambuf_iterator<_CharT, char_traits<_CharT> > __it, _Size __size,
1107 _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> __result,
1117 std::__copy_n_a(__it, __len, __result._M_cur, __strict);
1121 while (__size != 0);
1125 template<
bool _IsMove,
1126 typename _Tp,
typename _Ref,
typename _Ptr,
typename _OI>
1128 __copy_move_backward_dit(
1129 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
1130 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
1133 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter;
1134 if (__first._M_node != __last._M_node)
1136 __result = std::__copy_move_backward_a1<_IsMove>(
1137 __last._M_first, __last._M_cur, __result);
1139 for (
typename _Iter::_Map_pointer __node = __last._M_node - 1;
1140 __node != __first._M_node; --__node)
1141 __result = std::__copy_move_backward_a1<_IsMove>(
1142 *__node, *__node + _Iter::_S_buffer_size(), __result);
1144 return std::__copy_move_backward_a1<_IsMove>(
1145 __first._M_cur, __first._M_last, __result);
1148 return std::__copy_move_backward_a1<_IsMove>(
1149 __first._M_cur, __last._M_cur, __result);
1152 template<
bool _IsMove,
1153 typename _Tp,
typename _Ref,
typename _Ptr,
typename _OI>
1155 __copy_move_backward_a1(
1156 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
1157 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
1159 {
return __copy_move_backward_dit<_IsMove>(__first, __last, __result); }
1161 template<
bool _IsMove,
1162 typename _ITp,
typename _IRef,
typename _IPtr,
typename _OTp>
1163 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
1164 __copy_move_backward_a1(
1165 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
1166 _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last,
1167 _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result)
1168 {
return __copy_move_backward_dit<_IsMove>(__first, __last, __result); }
1170 template<
bool _IsMove,
typename _II,
typename _Tp>
1171 typename __gnu_cxx::__enable_if<
1172 __is_random_access_iter<_II>::__value,
1173 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
1174 __copy_move_backward_a1(_II __first, _II __last,
1175 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result)
1177 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter;
1178 typedef typename _Iter::difference_type difference_type;
1180 difference_type __len = __last - __first;
1183 difference_type __rlen = __result._M_cur - __result._M_first;
1184 _Tp* __rend = __result._M_cur;
1187 __rlen = _Iter::_S_buffer_size();
1188 __rend = *(__result._M_node - 1) + __rlen;
1191 const difference_type __clen =
std::min(__len, __rlen);
1192 std::__copy_move_backward_a1<_IsMove>(__last - __clen, __last, __rend);
1202 template<
typename _Tp,
typename _Ref,
typename _Ptr,
typename _II>
1205 const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>& __first1,
1206 const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>& __last1,
1209 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter;
1210 if (__first1._M_node != __last1._M_node)
1212 if (!std::__equal_aux1(__first1._M_cur, __first1._M_last, __first2))
1215 __first2 += __first1._M_last - __first1._M_cur;
1216 for (
typename _Iter::_Map_pointer __node = __first1._M_node + 1;
1217 __node != __last1._M_node;
1218 __first2 += _Iter::_S_buffer_size(), ++__node)
1219 if (!std::__equal_aux1(*__node, *__node + _Iter::_S_buffer_size(),
1223 return std::__equal_aux1(__last1._M_first, __last1._M_cur, __first2);
1226 return std::__equal_aux1(__first1._M_cur, __last1._M_cur, __first2);
1229 template<
typename _Tp,
typename _Ref,
typename _Ptr,
typename _II>
1230 typename __gnu_cxx::__enable_if<
1231 __is_random_access_iter<_II>::__value,
bool>::__type
1232 __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first1,
1233 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last1,
1235 {
return std::__equal_dit(__first1, __last1, __first2); }
1237 template<
typename _Tp1,
typename _Ref1,
typename _Ptr1,
1238 typename _Tp2,
typename _Ref2,
typename _Ptr2>
1240 __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1,
1241 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1,
1242 _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2)
1243 {
return std::__equal_dit(__first1, __last1, __first2); }
1245 template<
typename _II,
typename _Tp,
typename _Ref,
typename _Ptr>
1246 typename __gnu_cxx::__enable_if<
1247 __is_random_access_iter<_II>::__value,
bool>::__type
1248 __equal_aux1(_II __first1, _II __last1,
1249 _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first2)
1251 typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter;
1252 typedef typename _Iter::difference_type difference_type;
1254 difference_type __len = __last1 - __first1;
1257 const difference_type __clen
1258 =
std::min(__len, __first2._M_last - __first2._M_cur);
1259 if (!std::__equal_aux1(__first1, __first1 + __clen, __first2._M_cur))
1270 template<
typename _Tp1,
typename _Ref,
typename _Ptr,
typename _Tp2>
1273 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref, _Ptr> __first1,
1274 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref, _Ptr> __last1,
1275 const _Tp2* __first2,
const _Tp2* __last2)
1277 const bool __simple =
1278 (__is_memcmp_ordered_with<_Tp1, _Tp2>::__value
1279 && __is_pointer<_Ptr>::__value
1280#if __cplusplus > 201703L && __cpp_lib_concepts
1284 && !is_volatile_v<_Tp1>
1285 && !is_volatile_v<_Tp2>
1288 typedef std::__lexicographical_compare<__simple> _Lc;
1290 while (__first1._M_node != __last1._M_node)
1292 const ptrdiff_t __len1 = __first1._M_last - __first1._M_cur;
1293 const ptrdiff_t __len2 = __last2 - __first2;
1294 const ptrdiff_t __len =
std::min(__len1, __len2);
1296 if (
int __ret = _Lc::__3way(__first1._M_cur, __first1._M_last,
1297 __first2, __first2 + __len))
1303 return _Lc::__3way(__first1._M_cur, __last1._M_cur,
1307 template<
typename _Tp1,
typename _Ref1,
typename _Ptr1,
1310 __lexicographical_compare_aux1(
1311 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1,
1312 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1,
1313 _Tp2* __first2, _Tp2* __last2)
1314 {
return std::__lex_cmp_dit(__first1, __last1, __first2, __last2) < 0; }
1316 template<
typename _Tp1,
1317 typename _Tp2,
typename _Ref2,
typename _Ptr2>
1319 __lexicographical_compare_aux1(_Tp1* __first1, _Tp1* __last1,
1320 _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2,
1321 _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __last2)
1322 {
return std::__lex_cmp_dit(__first2, __last2, __first1, __last1) > 0; }
1324 template<
typename _Tp1,
typename _Ref1,
typename _Ptr1,
1325 typename _Tp2,
typename _Ref2,
typename _Ptr2>
1327 __lexicographical_compare_aux1(
1328 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1,
1329 _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1,
1330 _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2,
1331 _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __last2)
1333 const bool __simple =
1334 (__is_memcmp_ordered_with<_Tp1, _Tp2>::__value
1335 && __is_pointer<_Ptr1>::__value
1336 && __is_pointer<_Ptr2>::__value
1337#if __cplusplus > 201703L && __cpp_lib_concepts
1341 && !is_volatile_v<_Tp1>
1342 && !is_volatile_v<_Tp2>
1345 typedef std::__lexicographical_compare<__simple> _Lc;
1347 while (__first1 != __last1)
1349 const ptrdiff_t __len2 = __first2._M_node == __last2._M_node
1350 ? __last2._M_cur - __first2._M_cur
1351 : __first2._M_last - __first2._M_cur;
1354 const ptrdiff_t __len1 = __first1._M_node == __last1._M_node
1355 ? __last1._M_cur - __first1._M_cur
1356 : __first1._M_last - __first1._M_cur;
1357 const ptrdiff_t __len =
std::min(__len1, __len2);
1358 if (
int __ret = _Lc::__3way(__first1._M_cur, __first1._M_cur + __len,
1359 __first2._M_cur, __first2._M_cur + __len))
1366 return __last2 != __first2;
1369_GLIBCXX_END_NAMESPACE_VERSION
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 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 void _Destroy(_ForwardIterator __first, _ForwardIterator __last)
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.
void _M_fill_initialize(const value_type &__value)
Fills the deque with copies of value.
void _M_new_elements_at_back(size_type __new_elements)
Memory-handling helpers for the previous internal insert functions.
void _M_new_elements_at_front(size_type __new_elements)
Memory-handling helpers for the previous internal insert functions.
void _M_push_back_aux(_Args &&... __args)
Helper functions for push_* and pop_*.
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.