60#ifndef _STL_ITERATOR_H
61#define _STL_ITERATOR_H 1
69#if __cplusplus >= 201103L
73#if __cplusplus >= 202002L
81namespace std _GLIBCXX_VISIBILITY(default)
83_GLIBCXX_BEGIN_NAMESPACE_VERSION
95 template<
typename _Cat,
typename _Limit,
typename _Otherwise = _Cat>
96 using __clamp_iter_cat
97 = __conditional_t<derived_from<_Cat, _Limit>, _Limit, _Otherwise>;
99 template<
typename _Tp,
typename _Up>
100 concept __different_from
101 = !same_as<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>;
106#pragma GCC diagnostic push
107#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
128 template<
typename _Iterator>
130 :
public iterator<typename iterator_traits<_Iterator>::iterator_category,
131 typename iterator_traits<_Iterator>::value_type,
132 typename iterator_traits<_Iterator>::difference_type,
133 typename iterator_traits<_Iterator>::pointer,
134 typename iterator_traits<_Iterator>::reference>
136 template<
typename _Iter>
139#if __glibcxx_concepts
142 template<
typename _Iter>
153 typedef _Iterator iterator_type;
154 typedef typename __traits_type::pointer pointer;
155#if ! __glibcxx_concepts
157 typedef typename __traits_type::reference
reference;
199 : current(__x.current)
202#if __cplusplus >= 201103L
210 template<
typename _Iter>
211#if __glibcxx_concepts
217 : current(__x.current)
220#if __cplusplus >= 201103L
221 template<
typename _Iter>
222#if __glibcxx_concepts
231 current = __x.current;
259 _Iterator
__tmp = current;
271#if __cplusplus > 201703L && __cpp_concepts >= 201907L
273 ||
requires(
const _Iterator __i) { __i.operator->(); }
278 _Iterator
__tmp = current;
280 return _S_to_pointer(
__tmp);
387 {
return *(*
this + __n); }
389#if __cplusplus > 201703L && __glibcxx_concepts
396 auto __tmp = __i.base();
397 return ranges::iter_move(--
__tmp);
400 template<indirectly_swappable<_Iterator> _Iter2>
401 friend constexpr void
402 iter_swap(
const reverse_iterator& __x,
403 const reverse_iterator<_Iter2>& __y)
404 noexcept(is_nothrow_copy_constructible_v<_Iterator>
405 && is_nothrow_copy_constructible_v<_Iter2>
409 auto __xtmp = __x.base();
410 auto __ytmp = __y.base();
411 ranges::iter_swap(--__xtmp, --__ytmp);
416 template<
typename _Tp>
417 static _GLIBCXX17_CONSTEXPR _Tp*
418 _S_to_pointer(_Tp* __p)
421 template<
typename _Tp>
422 static _GLIBCXX17_CONSTEXPR pointer
423 _S_to_pointer(_Tp __t)
424 {
return __t.operator->(); }
437#if __cplusplus <= 201703L || ! defined __glibcxx_concepts
438 template<
typename _Iterator>
440 inline _GLIBCXX17_CONSTEXPR
bool
441 operator==(
const reverse_iterator<_Iterator>& __x,
442 const reverse_iterator<_Iterator>& __y)
443 {
return __x.base() == __y.base(); }
445 template<
typename _Iterator>
447 inline _GLIBCXX17_CONSTEXPR
bool
448 operator<(
const reverse_iterator<_Iterator>& __x,
449 const reverse_iterator<_Iterator>& __y)
450 {
return __y.base() < __x.base(); }
452 template<
typename _Iterator>
454 inline _GLIBCXX17_CONSTEXPR
bool
455 operator!=(
const reverse_iterator<_Iterator>& __x,
456 const reverse_iterator<_Iterator>& __y)
457 {
return !(__x == __y); }
459 template<
typename _Iterator>
461 inline _GLIBCXX17_CONSTEXPR
bool
462 operator>(
const reverse_iterator<_Iterator>& __x,
463 const reverse_iterator<_Iterator>& __y)
464 {
return __y < __x; }
466 template<
typename _Iterator>
468 inline _GLIBCXX17_CONSTEXPR
bool
469 operator<=(
const reverse_iterator<_Iterator>& __x,
470 const reverse_iterator<_Iterator>& __y)
471 {
return !(__y < __x); }
473 template<
typename _Iterator>
475 inline _GLIBCXX17_CONSTEXPR
bool
476 operator>=(
const reverse_iterator<_Iterator>& __x,
477 const reverse_iterator<_Iterator>& __y)
478 {
return !(__x < __y); }
483 template<
typename _IteratorL,
typename _IteratorR>
485 inline _GLIBCXX17_CONSTEXPR
bool
486 operator==(
const reverse_iterator<_IteratorL>& __x,
487 const reverse_iterator<_IteratorR>& __y)
488 {
return __x.base() == __y.base(); }
490 template<
typename _IteratorL,
typename _IteratorR>
492 inline _GLIBCXX17_CONSTEXPR
bool
493 operator<(
const reverse_iterator<_IteratorL>& __x,
494 const reverse_iterator<_IteratorR>& __y)
495 {
return __x.base() > __y.base(); }
497 template<
typename _IteratorL,
typename _IteratorR>
499 inline _GLIBCXX17_CONSTEXPR
bool
500 operator!=(
const reverse_iterator<_IteratorL>& __x,
501 const reverse_iterator<_IteratorR>& __y)
502 {
return __x.base() != __y.base(); }
504 template<
typename _IteratorL,
typename _IteratorR>
506 inline _GLIBCXX17_CONSTEXPR
bool
507 operator>(
const reverse_iterator<_IteratorL>& __x,
508 const reverse_iterator<_IteratorR>& __y)
509 {
return __x.base() < __y.base(); }
511 template<
typename _IteratorL,
typename _IteratorR>
512 inline _GLIBCXX17_CONSTEXPR
bool
513 operator<=(
const reverse_iterator<_IteratorL>& __x,
514 const reverse_iterator<_IteratorR>& __y)
515 {
return __x.base() >= __y.base(); }
517 template<
typename _IteratorL,
typename _IteratorR>
519 inline _GLIBCXX17_CONSTEXPR
bool
520 operator>=(
const reverse_iterator<_IteratorL>& __x,
521 const reverse_iterator<_IteratorR>& __y)
522 {
return __x.base() <= __y.base(); }
524 template<
typename _IteratorL,
typename _IteratorR>
530 {
return __x.base() == __y.base(); }
532 template<
typename _IteratorL,
typename _IteratorR>
535 operator!=(
const reverse_iterator<_IteratorL>& __x,
536 const reverse_iterator<_IteratorR>& __y)
537 requires requires { { __x.base() != __y.base() } -> convertible_to<bool>; }
538 {
return __x.base() != __y.base(); }
540 template<
typename _IteratorL,
typename _IteratorR>
543 operator<(
const reverse_iterator<_IteratorL>& __x,
544 const reverse_iterator<_IteratorR>& __y)
545 requires requires { { __x.base() > __y.base() } -> convertible_to<bool>; }
546 {
return __x.base() > __y.base(); }
548 template<
typename _IteratorL,
typename _IteratorR>
551 operator>(
const reverse_iterator<_IteratorL>& __x,
552 const reverse_iterator<_IteratorR>& __y)
553 requires requires { { __x.base() < __y.base() } -> convertible_to<bool>; }
554 {
return __x.base() < __y.base(); }
556 template<
typename _IteratorL,
typename _IteratorR>
559 operator<=(
const reverse_iterator<_IteratorL>& __x,
560 const reverse_iterator<_IteratorR>& __y)
561 requires requires { { __x.base() >= __y.base() } -> convertible_to<bool>; }
562 {
return __x.base() >= __y.base(); }
564 template<
typename _IteratorL,
typename _IteratorR>
567 operator>=(
const reverse_iterator<_IteratorL>& __x,
568 const reverse_iterator<_IteratorR>& __y)
569 requires requires { { __x.base() <= __y.base() } -> convertible_to<bool>; }
570 {
return __x.base() <= __y.base(); }
572 template<
typename _IteratorL,
573 three_way_comparable_with<_IteratorL> _IteratorR>
575 constexpr compare_three_way_result_t<_IteratorL, _IteratorR>
576 operator<=>(
const reverse_iterator<_IteratorL>& __x,
577 const reverse_iterator<_IteratorR>& __y)
578 {
return __y.base() <=> __x.base(); }
583 template<
typename _Iterator>
586 operator==(
const reverse_iterator<_Iterator>& __x,
587 const reverse_iterator<_Iterator>& __y)
588 requires requires { { __x.base() == __y.base() } -> convertible_to<bool>; }
589 {
return __x.base() == __y.base(); }
591 template<three_way_comparable _Iterator>
593 constexpr compare_three_way_result_t<_Iterator, _Iterator>
594 operator<=>(
const reverse_iterator<_Iterator>& __x,
595 const reverse_iterator<_Iterator>& __y)
596 {
return __y.base() <=> __x.base(); }
600#if __cplusplus < 201103L
601 template<
typename _Iterator>
602 inline typename reverse_iterator<_Iterator>::difference_type
603 operator-(
const reverse_iterator<_Iterator>& __x,
604 const reverse_iterator<_Iterator>& __y)
605 {
return __y.base() - __x.base(); }
607 template<
typename _IteratorL,
typename _IteratorR>
608 inline typename reverse_iterator<_IteratorL>::difference_type
609 operator-(
const reverse_iterator<_IteratorL>& __x,
610 const reverse_iterator<_IteratorR>& __y)
611 {
return __y.base() - __x.base(); }
615 template<
typename _IteratorL,
typename _IteratorR>
617 inline _GLIBCXX17_CONSTEXPR
auto
618 operator-(
const reverse_iterator<_IteratorL>& __x,
619 const reverse_iterator<_IteratorR>& __y)
620 ->
decltype(__y.base() - __x.base())
621 {
return __y.base() - __x.base(); }
624 template<
typename _Iterator>
626 inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
627 operator+(
typename reverse_iterator<_Iterator>::difference_type __n,
628 const reverse_iterator<_Iterator>& __x)
629 {
return reverse_iterator<_Iterator>(__x.base() - __n); }
631#if __cplusplus >= 201103L
633 template<
typename _Iterator>
634 inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
635 __make_reverse_iterator(_Iterator __i)
636 {
return reverse_iterator<_Iterator>(__i); }
638# ifdef __glibcxx_make_reverse_iterator
642 template<
typename _Iterator>
644 inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
648# if __cplusplus > 201703L && defined __glibcxx_concepts
649 template<
typename _Iterator1,
typename _Iterator2>
650 requires (!sized_sentinel_for<_Iterator1, _Iterator2>)
651 inline constexpr bool
652 disable_sized_sentinel_for<reverse_iterator<_Iterator1>,
653 reverse_iterator<_Iterator2>> =
true;
657 template<
typename _Iterator>
660 __niter_base(reverse_iterator<_Iterator> __it)
661 ->
decltype(__make_reverse_iterator(__niter_base(__it.base())))
662 {
return __make_reverse_iterator(__niter_base(__it.base())); }
664 template<
typename _Iterator>
665 struct __is_move_iterator<reverse_iterator<_Iterator> >
666 : __is_move_iterator<_Iterator>
669 template<
typename _Iterator>
672 __miter_base(reverse_iterator<_Iterator> __it)
673 ->
decltype(__make_reverse_iterator(__miter_base(__it.base())))
674 {
return __make_reverse_iterator(__miter_base(__it.base())); }
688 template<
typename _Container>
690 :
public iterator<output_iterator_tag, void, void, void, void>
693 _Container* container;
698#if __cplusplus > 201703L
718#if __cplusplus < 201103L
720 operator=(
typename _Container::const_reference __value)
722 container->push_back(__value);
728 operator=(
const typename _Container::value_type& __value)
730 container->push_back(__value);
736 operator=(
typename _Container::value_type&& __value)
738 container->push_back(
std::move(__value));
744 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
773 template<
typename _Container>
774 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
775 inline back_insert_iterator<_Container>
789 template<
typename _Container>
791 :
public iterator<output_iterator_tag, void, void, void, void>
794 _Container* container;
799#if __cplusplus > 201703L
819#if __cplusplus < 201103L
821 operator=(
typename _Container::const_reference __value)
823 container->push_front(__value);
829 operator=(
const typename _Container::value_type& __value)
831 container->push_front(__value);
837 operator=(
typename _Container::value_type&& __value)
839 container->push_front(
std::move(__value));
845 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
874 template<
typename _Container>
875 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
876 inline front_insert_iterator<_Container>
894 template<
typename _Container>
896 :
public iterator<output_iterator_tag, void, void, void, void>
898#if __cplusplus > 201703L && defined __glibcxx_concepts
899 using _Iter = std::__detail::__range_iter_t<_Container>;
901 typedef typename _Container::iterator _Iter;
904 _Container* container;
911#if __cplusplus > 201703L && defined __glibcxx_concepts
946#if __cplusplus < 201103L
948 operator=(
typename _Container::const_reference __value)
950 iter = container->insert(iter, __value);
957 operator=(
const typename _Container::value_type& __value)
959 iter = container->insert(iter, __value);
966 operator=(
typename _Container::value_type&& __value)
968 iter = container->insert(iter,
std::move(__value));
975 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
993#pragma GCC diagnostic pop
1007#if __cplusplus > 201703L && defined __glibcxx_concepts
1008 template<
typename _Container>
1010 constexpr insert_iterator<_Container>
1011 inserter(_Container& __x, std::__detail::__range_iter_t<_Container> __i)
1014 template<
typename _Container>
1016 inline insert_iterator<_Container>
1017 inserter(_Container& __x,
typename _Container::iterator __i)
1018 {
return insert_iterator<_Container>(__x, __i); }
1023_GLIBCXX_END_NAMESPACE_VERSION
1026namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
1028_GLIBCXX_BEGIN_NAMESPACE_VERSION
1037 template<
typename _Iterator,
typename _Container>
1038 class __normal_iterator
1041 _Iterator _M_current;
1045#if __cplusplus >= 201103L
1046 template<
typename _Iter>
1047 using __convertible_from
1052 typedef _Iterator iterator_type;
1053 typedef typename __traits_type::iterator_category iterator_category;
1054 typedef typename __traits_type::value_type value_type;
1055 typedef typename __traits_type::difference_type difference_type;
1056 typedef typename __traits_type::reference reference;
1057 typedef typename __traits_type::pointer pointer;
1059#if __cplusplus > 201703L && __glibcxx_concepts
1060 using iterator_concept = std::__detail::__iter_concept<_Iterator>;
1063 _GLIBCXX_CONSTEXPR __normal_iterator() _GLIBCXX_NOEXCEPT
1064 : _M_current(_Iterator()) { }
1066 explicit _GLIBCXX20_CONSTEXPR
1067 __normal_iterator(
const _Iterator& __i) _GLIBCXX_NOEXCEPT
1068 : _M_current(__i) { }
1071#if __cplusplus >= 201103L
1072 template<
typename _Iter,
typename = __convertible_from<_Iter>>
1073 _GLIBCXX20_CONSTEXPR
1074 __normal_iterator(
const __normal_iterator<_Iter, _Container>& __i)
1079 template<
typename _Iter>
1080 __normal_iterator(
const __normal_iterator<_Iter,
1081 typename __enable_if<
1082 (std::__are_same<_Iter, typename _Container::pointer>::__value),
1083 _Container>::__type>& __i)
1085 : _M_current(__i.base()) { }
1088 _GLIBCXX20_CONSTEXPR
1090 operator*() const _GLIBCXX_NOEXCEPT
1091 {
return *_M_current; }
1093 _GLIBCXX20_CONSTEXPR
1095 operator->() const _GLIBCXX_NOEXCEPT
1096 {
return _M_current; }
1098 _GLIBCXX20_CONSTEXPR
1100 operator++() _GLIBCXX_NOEXCEPT
1106 _GLIBCXX20_CONSTEXPR
1108 operator++(
int) _GLIBCXX_NOEXCEPT
1109 {
return __normal_iterator(_M_current++); }
1112 _GLIBCXX20_CONSTEXPR
1114 operator--() _GLIBCXX_NOEXCEPT
1120 _GLIBCXX20_CONSTEXPR
1122 operator--(
int) _GLIBCXX_NOEXCEPT
1123 {
return __normal_iterator(_M_current--); }
1126 _GLIBCXX20_CONSTEXPR
1128 operator[](difference_type __n)
const _GLIBCXX_NOEXCEPT
1129 {
return _M_current[__n]; }
1131 _GLIBCXX20_CONSTEXPR
1133 operator+=(difference_type __n) _GLIBCXX_NOEXCEPT
1134 { _M_current += __n;
return *
this; }
1136 _GLIBCXX20_CONSTEXPR
1138 operator+(difference_type __n)
const _GLIBCXX_NOEXCEPT
1139 {
return __normal_iterator(_M_current + __n); }
1141 _GLIBCXX20_CONSTEXPR
1143 operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
1144 { _M_current -= __n;
return *
this; }
1146 _GLIBCXX20_CONSTEXPR
1148 operator-(difference_type __n)
const _GLIBCXX_NOEXCEPT
1149 {
return __normal_iterator(_M_current - __n); }
1151 _GLIBCXX20_CONSTEXPR
1153 base() const _GLIBCXX_NOEXCEPT
1154 {
return _M_current; }
1165#if __cpp_lib_three_way_comparison
1166 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1169 operator==(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1170 const __normal_iterator<_IteratorR, _Container>& __rhs)
1171 noexcept(
noexcept(__lhs.base() == __rhs.base()))
1175 {
return __lhs.base() == __rhs.base(); }
1177 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1179 constexpr std::__detail::__synth3way_t<_IteratorR, _IteratorL>
1180 operator<=>(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1181 const __normal_iterator<_IteratorR, _Container>& __rhs)
1182 noexcept(
noexcept(std::__detail::__synth3way(__lhs.base(), __rhs.base())))
1183 {
return std::__detail::__synth3way(__lhs.base(), __rhs.base()); }
1185 template<
typename _Iterator,
typename _Container>
1188 operator==(
const __normal_iterator<_Iterator, _Container>& __lhs,
1189 const __normal_iterator<_Iterator, _Container>& __rhs)
1190 noexcept(
noexcept(__lhs.base() == __rhs.base()))
1194 {
return __lhs.base() == __rhs.base(); }
1196 template<
typename _Iterator,
typename _Container>
1198 constexpr std::__detail::__synth3way_t<_Iterator>
1199 operator<=>(
const __normal_iterator<_Iterator, _Container>& __lhs,
1200 const __normal_iterator<_Iterator, _Container>& __rhs)
1201 noexcept(
noexcept(std::__detail::__synth3way(__lhs.base(), __rhs.base())))
1202 {
return std::__detail::__synth3way(__lhs.base(), __rhs.base()); }
1205 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1206 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1208 operator==(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1209 const __normal_iterator<_IteratorR, _Container>& __rhs)
1211 {
return __lhs.base() == __rhs.base(); }
1213 template<
typename _Iterator,
typename _Container>
1214 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1216 operator==(
const __normal_iterator<_Iterator, _Container>& __lhs,
1217 const __normal_iterator<_Iterator, _Container>& __rhs)
1219 {
return __lhs.base() == __rhs.base(); }
1221 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1222 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1224 operator!=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1225 const __normal_iterator<_IteratorR, _Container>& __rhs)
1227 {
return __lhs.base() != __rhs.base(); }
1229 template<
typename _Iterator,
typename _Container>
1230 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1232 operator!=(
const __normal_iterator<_Iterator, _Container>& __lhs,
1233 const __normal_iterator<_Iterator, _Container>& __rhs)
1235 {
return __lhs.base() != __rhs.base(); }
1238 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1241 operator<(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1242 const __normal_iterator<_IteratorR, _Container>& __rhs)
1244 {
return __lhs.base() < __rhs.base(); }
1246 template<
typename _Iterator,
typename _Container>
1247 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1249 operator<(
const __normal_iterator<_Iterator, _Container>& __lhs,
1250 const __normal_iterator<_Iterator, _Container>& __rhs)
1252 {
return __lhs.base() < __rhs.base(); }
1254 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1257 operator>(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1258 const __normal_iterator<_IteratorR, _Container>& __rhs)
1260 {
return __lhs.base() > __rhs.base(); }
1262 template<
typename _Iterator,
typename _Container>
1263 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1265 operator>(
const __normal_iterator<_Iterator, _Container>& __lhs,
1266 const __normal_iterator<_Iterator, _Container>& __rhs)
1268 {
return __lhs.base() > __rhs.base(); }
1270 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1273 operator<=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1274 const __normal_iterator<_IteratorR, _Container>& __rhs)
1276 {
return __lhs.base() <= __rhs.base(); }
1278 template<
typename _Iterator,
typename _Container>
1279 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1281 operator<=(
const __normal_iterator<_Iterator, _Container>& __lhs,
1282 const __normal_iterator<_Iterator, _Container>& __rhs)
1284 {
return __lhs.base() <= __rhs.base(); }
1286 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1289 operator>=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1290 const __normal_iterator<_IteratorR, _Container>& __rhs)
1292 {
return __lhs.base() >= __rhs.base(); }
1294 template<
typename _Iterator,
typename _Container>
1295 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1297 operator>=(
const __normal_iterator<_Iterator, _Container>& __lhs,
1298 const __normal_iterator<_Iterator, _Container>& __rhs)
1300 {
return __lhs.base() >= __rhs.base(); }
1307 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1308#if __cplusplus >= 201103L
1310 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1312 operator-(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1313 const __normal_iterator<_IteratorR, _Container>& __rhs)
noexcept
1314 ->
decltype(__lhs.base() - __rhs.base())
1316 inline typename __normal_iterator<_IteratorL, _Container>::difference_type
1317 operator-(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1318 const __normal_iterator<_IteratorR, _Container>& __rhs)
1320 {
return __lhs.base() - __rhs.base(); }
1322 template<
typename _Iterator,
typename _Container>
1323 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1324 inline typename __normal_iterator<_Iterator, _Container>::difference_type
1325 operator-(
const __normal_iterator<_Iterator, _Container>& __lhs,
1326 const __normal_iterator<_Iterator, _Container>& __rhs)
1328 {
return __lhs.base() - __rhs.base(); }
1330 template<
typename _Iterator,
typename _Container>
1331 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1332 inline __normal_iterator<_Iterator, _Container>
1333 operator+(
typename __normal_iterator<_Iterator, _Container>::difference_type
1334 __n,
const __normal_iterator<_Iterator, _Container>& __i)
1336 {
return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
1338_GLIBCXX_END_NAMESPACE_VERSION
1341namespace std _GLIBCXX_VISIBILITY(default)
1343_GLIBCXX_BEGIN_NAMESPACE_VERSION
1345 template<
typename _Iterator,
typename _Container>
1346 _GLIBCXX20_CONSTEXPR
1348 __niter_base(__gnu_cxx::__normal_iterator<_Iterator, _Container> __it)
1350 {
return __it.base(); }
1352#if __cplusplus >= 201103L
1354#if __cplusplus <= 201703L
1357 template<
typename _Iterator,
typename _Container>
1359 __to_address(
const __gnu_cxx::__normal_iterator<_Iterator,
1360 _Container>& __it)
noexcept
1361 ->
decltype(std::__to_address(__it.base()))
1362 {
return std::__to_address(__it.base()); }
1370#if __cplusplus > 201703L && __glibcxx_concepts
1371 template<semiregular _Sent>
1377 noexcept(is_nothrow_default_constructible_v<_Sent>)
1381 move_sentinel(_Sent __s)
1382 noexcept(is_nothrow_move_constructible_v<_Sent>)
1385 template<
typename _S2>
requires convertible_to<const _S2&, _Sent>
1387 move_sentinel(
const move_sentinel<_S2>& __s)
1388 noexcept(is_nothrow_constructible_v<_Sent, const _S2&>)
1389 : _M_last(__s.base())
1392 template<
typename _S2>
requires assignable_from<_Sent&, const _S2&>
1393 constexpr move_sentinel&
1394 operator=(
const move_sentinel<_S2>& __s)
1395 noexcept(is_nothrow_assignable_v<_Sent, const _S2&>)
1397 _M_last = __s.base();
1404 noexcept(is_nothrow_copy_constructible_v<_Sent>)
1414#if __cplusplus > 201703L && __glibcxx_concepts
1415 template<
typename _Iterator>
1416 struct __move_iter_cat
1419 template<
typename _Iterator>
1420 requires requires {
typename __iter_category_t<_Iterator>; }
1421 struct __move_iter_cat<_Iterator>
1423 using iterator_category
1424 = __clamp_iter_cat<__iter_category_t<_Iterator>,
1425 random_access_iterator_tag>;
1439 template<
typename _Iterator>
1442 :
public __detail::__move_iter_cat<_Iterator>
1445 _Iterator _M_current;
1448#if ! (__cplusplus > 201703L && __glibcxx_concepts)
1449 using __base_ref =
typename __traits_type::reference;
1452 template<
typename _Iter2>
1455#if __glibcxx_concepts
1458 template<
typename _Iter2>
1463#if __cplusplus > 201703L && __glibcxx_concepts
1479 using iterator_type = _Iterator;
1481#ifdef __glibcxx_move_iterator_concept
1487 using pointer = _Iterator;
1490 typedef typename __traits_type::iterator_category iterator_category;
1491 typedef typename __traits_type::value_type
value_type;
1494 typedef _Iterator pointer;
1499 typename remove_reference<__base_ref>::type&&,
1511 template<
typename _Iter>
1512#if __glibcxx_concepts
1517 : _M_current(__i._M_current) { }
1519 template<
typename _Iter>
1520#if __glibcxx_concepts
1527 _M_current = __i._M_current;
1531#if __cplusplus <= 201703L
1535 {
return _M_current; }
1538 constexpr const iterator_type&
1539 base()
const &
noexcept
1540 {
return _M_current; }
1543 constexpr iterator_type
1551#if __cplusplus > 201703L && __glibcxx_concepts
1552 {
return ranges::iter_move(_M_current); }
1554 {
return static_cast<reference>(*_M_current); }
1560 {
return _M_current; }
1577#if __glibcxx_concepts
1625#if __cplusplus > 201703L && __glibcxx_concepts
1626 {
return ranges::iter_move(_M_current + __n); }
1631#if __cplusplus > 201703L && __glibcxx_concepts
1632 template<sentinel_for<_Iterator> _Sent>
1634 friend constexpr bool
1636 {
return __x.base() ==
__y.base(); }
1638 template<sized_sentinel_for<_Iterator> _Sent>
1642 {
return __x.base() -
__y.base(); }
1644 template<sized_sentinel_for<_Iterator> _Sent>
1648 {
return __x.base() -
__y.base(); }
1653 noexcept(
noexcept(ranges::iter_move(__i._M_current)))
1654 {
return ranges::iter_move(__i._M_current); }
1656 template<indirectly_swappable<_Iterator> _Iter2>
1657 friend constexpr void
1659 noexcept(
noexcept(ranges::iter_swap(__x._M_current,
__y._M_current)))
1660 {
return ranges::iter_swap(__x._M_current,
__y._M_current); }
1664 template<
typename _IteratorL,
typename _IteratorR>
1669#if __cplusplus > 201703L && __glibcxx_concepts
1670 requires requires { { __x.base() ==
__y.base() } -> convertible_to<bool>; }
1672 {
return __x.base() == __y.base(); }
1674#if __cpp_lib_three_way_comparison
1675 template<
typename _IteratorL,
1676 three_way_comparable_with<_IteratorL> _IteratorR>
1678 constexpr compare_three_way_result_t<_IteratorL, _IteratorR>
1679 operator<=>(
const move_iterator<_IteratorL>& __x,
1680 const move_iterator<_IteratorR>& __y)
1681 {
return __x.base() <=> __y.base(); }
1683 template<
typename _IteratorL,
typename _IteratorR>
1685 inline _GLIBCXX17_CONSTEXPR
bool
1686 operator!=(
const move_iterator<_IteratorL>& __x,
1687 const move_iterator<_IteratorR>& __y)
1688 {
return !(__x == __y); }
1691 template<
typename _IteratorL,
typename _IteratorR>
1693 inline _GLIBCXX17_CONSTEXPR
bool
1694 operator<(
const move_iterator<_IteratorL>& __x,
1695 const move_iterator<_IteratorR>& __y)
1696#if __cplusplus > 201703L && __glibcxx_concepts
1697 requires requires { { __x.base() < __y.base() } -> convertible_to<bool>; }
1699 {
return __x.base() < __y.base(); }
1701 template<
typename _IteratorL,
typename _IteratorR>
1703 inline _GLIBCXX17_CONSTEXPR
bool
1704 operator<=(
const move_iterator<_IteratorL>& __x,
1705 const move_iterator<_IteratorR>& __y)
1706#if __cplusplus > 201703L && __glibcxx_concepts
1707 requires requires { { __y.base() < __x.base() } -> convertible_to<bool>; }
1709 {
return !(__y < __x); }
1711 template<
typename _IteratorL,
typename _IteratorR>
1713 inline _GLIBCXX17_CONSTEXPR
bool
1714 operator>(
const move_iterator<_IteratorL>& __x,
1715 const move_iterator<_IteratorR>& __y)
1716#if __cplusplus > 201703L && __glibcxx_concepts
1717 requires requires { { __y.base() < __x.base() } -> convertible_to<bool>; }
1719 {
return __y < __x; }
1721 template<
typename _IteratorL,
typename _IteratorR>
1723 inline _GLIBCXX17_CONSTEXPR
bool
1724 operator>=(
const move_iterator<_IteratorL>& __x,
1725 const move_iterator<_IteratorR>& __y)
1726#if __cplusplus > 201703L && __glibcxx_concepts
1727 requires requires { { __x.base() < __y.base() } -> convertible_to<bool>; }
1729 {
return !(__x < __y); }
1734 template<
typename _Iterator>
1736 inline _GLIBCXX17_CONSTEXPR
bool
1737 operator==(
const move_iterator<_Iterator>& __x,
1738 const move_iterator<_Iterator>& __y)
1739 {
return __x.base() == __y.base(); }
1741#if __cpp_lib_three_way_comparison
1742 template<three_way_comparable _Iterator>
1744 constexpr compare_three_way_result_t<_Iterator>
1745 operator<=>(
const move_iterator<_Iterator>& __x,
1746 const move_iterator<_Iterator>& __y)
1747 {
return __x.base() <=> __y.base(); }
1749 template<
typename _Iterator>
1751 inline _GLIBCXX17_CONSTEXPR
bool
1752 operator!=(
const move_iterator<_Iterator>& __x,
1753 const move_iterator<_Iterator>& __y)
1754 {
return !(__x == __y); }
1756 template<
typename _Iterator>
1758 inline _GLIBCXX17_CONSTEXPR
bool
1759 operator<(
const move_iterator<_Iterator>& __x,
1760 const move_iterator<_Iterator>& __y)
1761 {
return __x.base() < __y.base(); }
1763 template<
typename _Iterator>
1765 inline _GLIBCXX17_CONSTEXPR
bool
1766 operator<=(
const move_iterator<_Iterator>& __x,
1767 const move_iterator<_Iterator>& __y)
1768 {
return !(__y < __x); }
1770 template<
typename _Iterator>
1772 inline _GLIBCXX17_CONSTEXPR
bool
1773 operator>(
const move_iterator<_Iterator>& __x,
1774 const move_iterator<_Iterator>& __y)
1775 {
return __y < __x; }
1777 template<
typename _Iterator>
1779 inline _GLIBCXX17_CONSTEXPR
bool
1780 operator>=(
const move_iterator<_Iterator>& __x,
1781 const move_iterator<_Iterator>& __y)
1782 {
return !(__x < __y); }
1786 template<
typename _IteratorL,
typename _IteratorR>
1788 inline _GLIBCXX17_CONSTEXPR
auto
1789 operator-(
const move_iterator<_IteratorL>& __x,
1790 const move_iterator<_IteratorR>& __y)
1791 ->
decltype(__x.base() - __y.base())
1792 {
return __x.base() - __y.base(); }
1794 template<
typename _Iterator>
1796 inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator>
1797 operator+(
typename move_iterator<_Iterator>::difference_type __n,
1798 const move_iterator<_Iterator>& __x)
1799 {
return __x + __n; }
1801 template<
typename _Iterator>
1803 inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator>
1804 make_move_iterator(_Iterator __i)
1805 {
return move_iterator<_Iterator>(
std::move(__i)); }
1807 template<
typename _Iterator,
typename _ReturnType
1808 = __conditional_t<__move_if_noexcept_cond
1809 <
typename iterator_traits<_Iterator>::value_type>::value,
1810 _Iterator, move_iterator<_Iterator>>>
1811 inline _GLIBCXX17_CONSTEXPR _ReturnType
1812 __make_move_if_noexcept_iterator(_Iterator __i)
1813 {
return _ReturnType(__i); }
1817 template<
typename _Tp,
typename _ReturnType
1818 = __conditional_t<__move_if_noexcept_cond<_Tp>::value,
1819 const _Tp*, move_iterator<_Tp*>>>
1820 inline _GLIBCXX17_CONSTEXPR _ReturnType
1821 __make_move_if_noexcept_iterator(_Tp* __i)
1822 {
return _ReturnType(__i); }
1824#if __cplusplus > 201703L && __glibcxx_concepts
1829 template<
typename _It>
1830 concept __common_iter_has_arrow = indirectly_readable<const _It>
1831 && (
requires(
const _It& __it) { __it.operator->(); }
1832 || is_reference_v<iter_reference_t<_It>>
1833 || constructible_from<iter_value_t<_It>, iter_reference_t<_It>>);
1835 template<
typename _It>
1836 concept __common_iter_use_postfix_proxy
1837 = (!
requires (_It& __i) { { *__i++ } -> __can_reference; })
1838 && constructible_from<iter_value_t<_It>, iter_reference_t<_It>>
1839 && move_constructible<iter_value_t<_It>>;
1843 template<input_or_output_iterator _It, sentinel_for<_It> _Sent>
1844 requires (!same_as<_It, _Sent>) && copyable<_It>
1847 template<
typename _Tp,
typename _Up>
1848 static constexpr bool
1857 template<
typename _It2,
typename _Sent2>
1858 static constexpr bool
1874 operator->()
const noexcept
1878 class __postfix_proxy
1899 : _M_it(), _M_index(0)
1914 template<
typename _It2,
typename _Sent2>
1920 : _M_valueless(), _M_index(__x._M_index)
1922 __glibcxx_assert(__x._M_has_value());
1930 else if (_M_index == 1)
1945 : _M_valueless(), _M_index(__x._M_index)
1954 else if (_M_index == 1)
1957 _M_sent = __x._M_sent;
1969 : _M_valueless(), _M_index(__x._M_index)
1978 else if (_M_index == 1)
2020 template<
typename _It2,
typename _Sent2>
2032 __glibcxx_assert(__x._M_has_value());
2037#if __cpp_concepts >= 202002L
2051 else if (_M_index == 1)
2056 constexpr decltype(
auto)
2059 __glibcxx_assert(_M_index == 0);
2064 constexpr decltype(
auto)
2065 operator*()
const requires __detail::__dereferenceable<const _It>
2067 __glibcxx_assert(_M_index == 0);
2073 operator->()
const requires __detail::__common_iter_has_arrow<_It>
2075 __glibcxx_assert(_M_index == 0);
2080 auto&&
__tmp = *_M_it;
2084 return __arrow_proxy{*_M_it};
2090 __glibcxx_assert(_M_index == 0);
2095 constexpr decltype(
auto)
2098 __glibcxx_assert(_M_index == 0);
2105 else if constexpr (!__detail::__common_iter_use_postfix_proxy<_It>)
2109 __postfix_proxy __p(**
this);
2115 template<
typename _It2, sentinel_for<_It> _Sent2>
2117 friend constexpr bool
2121 switch(__x._M_index << 2 |
__y._M_index)
2127 return __x._M_it ==
__y._M_sent;
2129 return __x._M_sent ==
__y._M_it;
2131 __glibcxx_assert(__x._M_has_value());
2132 __glibcxx_assert(
__y._M_has_value());
2137 template<
typename _It2, sentinel_for<_It> _Sent2>
2139 friend constexpr bool
2143 switch(__x._M_index << 2 |
__y._M_index)
2148 return __x._M_it ==
__y._M_it;
2150 return __x._M_it ==
__y._M_sent;
2152 return __x._M_sent ==
__y._M_it;
2154 __glibcxx_assert(__x._M_has_value());
2155 __glibcxx_assert(
__y._M_has_value());
2160 template<sized_sentinel_for<_It> _It2, sized_sentinel_for<_It> _Sent2>
2166 switch(__x._M_index << 2 |
__y._M_index)
2171 return __x._M_it -
__y._M_it;
2173 return __x._M_it -
__y._M_sent;
2175 return __x._M_sent -
__y._M_it;
2177 __glibcxx_assert(__x._M_has_value());
2178 __glibcxx_assert(
__y._M_has_value());
2189 __glibcxx_assert(__i._M_index == 0);
2190 return ranges::iter_move(__i._M_it);
2193 template<indirectly_swappable<_It> _It2,
typename _Sent2>
2194 friend constexpr void
2200 __glibcxx_assert(__x._M_index == 0);
2201 __glibcxx_assert(
__y._M_index == 0);
2202 return ranges::iter_swap(__x._M_it,
__y._M_it);
2206 template<input_or_output_iterator _It2, sentinel_for<_It2> _Sent2>
2211 _M_has_value()
const noexcept {
return _M_index != _S_valueless; }
2213 template<
typename _CIt>
2215 _M_assign(
_CIt&& __x)
2217 if (_M_index == __x._M_index)
2221 else if (_M_index == 1)
2228 else if (_M_index == 1)
2230 _M_index = _S_valueless;
2232 if (__x._M_index == 0)
2235 else if (__x._M_index == 1)
2238 _M_index = __x._M_index;
2246 unsigned char _M_valueless;
2248 unsigned char _M_index;
2250 static constexpr unsigned char _S_valueless{2};
2253 template<
typename _It,
typename _Sent>
2259 template<input_iterator _It,
typename _Sent>
2260 struct iterator_traits<common_iterator<_It, _Sent>>
2263 template<
typename _Iter>
2269 template<
typename _Iter>
2270 requires __detail::__common_iter_has_arrow<_Iter>
2273 using _CIter = common_iterator<_Iter, _Sent>;
2280 if constexpr (
requires {
requires derived_from<__iter_category_t<_It>,
2281 forward_iterator_tag>; })
2282 return forward_iterator_tag{};
2284 return input_iterator_tag{};
2288 using iterator_concept = __conditional_t<forward_iterator<_It>,
2289 forward_iterator_tag,
2290 input_iterator_tag>;
2291 using iterator_category =
decltype(_S_iter_cat());
2292 using value_type = iter_value_t<_It>;
2293 using difference_type = iter_difference_t<_It>;
2294 using pointer =
typename __ptr<_It>::type;
2295 using reference = iter_reference_t<_It>;
2302 template<
typename _It>
2303 struct __counted_iter_value_type
2306 template<indirectly_readable _It>
2307 struct __counted_iter_value_type<_It>
2308 {
using value_type = iter_value_t<_It>; };
2310 template<
typename _It>
2311 struct __counted_iter_concept
2314 template<
typename _It>
2315 requires requires {
typename _It::iterator_concept; }
2316 struct __counted_iter_concept<_It>
2317 {
using iterator_concept =
typename _It::iterator_concept; };
2319 template<
typename _It>
2320 struct __counted_iter_cat
2323 template<
typename _It>
2324 requires requires {
typename _It::iterator_category; }
2325 struct __counted_iter_cat<_It>
2326 {
using iterator_category =
typename _It::iterator_category; };
2330 template<input_or_output_iterator _It>
2332 :
public __detail::__counted_iter_value_type<_It>,
2333 public __detail::__counted_iter_concept<_It>,
2334 public __detail::__counted_iter_cat<_It>
2337 using iterator_type = _It;
2347 : _M_current(
std::move(__i)), _M_length(__n)
2348 { __glibcxx_assert(__n >= 0); }
2350 template<
typename _It2>
2354 : _M_current(__x._M_current), _M_length(__x._M_length)
2357 template<
typename _It2>
2362 _M_current = __x._M_current;
2363 _M_length = __x._M_length;
2368 constexpr const _It&
2369 base()
const &
noexcept
2370 {
return _M_current; }
2380 count()
const noexcept {
return _M_length; }
2383 constexpr decltype(
auto)
2385 noexcept(
noexcept(*_M_current))
2387 __glibcxx_assert( _M_length > 0 );
2392 constexpr decltype(
auto)
2394 noexcept(
noexcept(*_M_current))
2395 requires __detail::__dereferenceable<const _It>
2397 __glibcxx_assert( _M_length > 0 );
2403 operator->()
const noexcept
2410 __glibcxx_assert(_M_length > 0);
2416 constexpr decltype(
auto)
2419 __glibcxx_assert(_M_length > 0);
2423 return _M_current++;
2426 __throw_exception_again;
2464 {
return __x + __n; }
2470 __glibcxx_assert(__n <= _M_length);
2482 template<common_with<_It> _It2>
2487 {
return __y._M_length - __x._M_length; }
2492 {
return -__x._M_length; }
2497 {
return __y._M_length; }
2503 __glibcxx_assert(-__n <= _M_length);
2510 constexpr decltype(
auto)
2512 noexcept(
noexcept(_M_current[__n]))
2515 __glibcxx_assert(__n < _M_length);
2516 return _M_current[__n];
2519 template<common_with<_It> _It2>
2521 friend constexpr bool
2524 {
return __x._M_length ==
__y._M_length; }
2527 friend constexpr bool
2529 {
return __x._M_length == 0; }
2531 template<common_with<_It> _It2>
2533 friend constexpr strong_ordering
2536 {
return __y._M_length <=> __x._M_length; }
2541 noexcept(
noexcept(ranges::iter_move(__i._M_current)))
2544 __glibcxx_assert( __i._M_length > 0 );
2545 return ranges::iter_move(__i._M_current);
2548 template<indirectly_swappable<_It> _It2>
2549 friend constexpr void
2552 noexcept(
noexcept(ranges::iter_swap(__x._M_current,
__y._M_current)))
2554 __glibcxx_assert( __x._M_length > 0 &&
__y._M_length > 0 );
2555 ranges::iter_swap(__x._M_current,
__y._M_current);
2561 _It _M_current = _It();
2565 template<input_iterator _It>
2574#if __cplusplus > 202020L
2575 template<indirectly_readable _It>
2576 using iter_const_reference_t
2577 = common_reference_t<const iter_value_t<_It>&&, iter_reference_t<_It>>;
2579 template<input_iterator _It>
class basic_const_iterator;
2583 template<
typename _It>
2584 concept __constant_iterator = input_iterator<_It>
2585 && same_as<iter_const_reference_t<_It>, iter_reference_t<_It>>;
2587 template<
typename _Tp>
2588 inline constexpr bool __is_const_iterator =
false;
2590 template<
typename _It>
2591 inline constexpr bool __is_const_iterator<basic_const_iterator<_It>> =
true;
2593 template<
typename _Tp>
2594 concept __not_a_const_iterator = !__is_const_iterator<_Tp>;
2596 template<indirectly_readable _It>
2597 using __iter_const_rvalue_reference_t
2598 = common_reference_t<const iter_value_t<_It>&&, iter_rvalue_reference_t<_It>>;
2600 template<
typename _It>
2601 struct __basic_const_iterator_iter_cat
2604 template<forward_iterator _It>
2605 struct __basic_const_iterator_iter_cat<_It>
2606 {
using iterator_category = __iter_category_t<_It>; };
2609 template<input_iterator _It>
2610 using const_iterator
2611 = __conditional_t<__detail::__constant_iterator<_It>, _It, basic_const_iterator<_It>>;
2615 template<
typename _Sent>
2616 struct __const_sentinel
2617 {
using type = _Sent; };
2619 template<input_iterator _Sent>
2620 struct __const_sentinel<_Sent>
2621 {
using type = const_iterator<_Sent>; };
2624 template<semiregular _Sent>
2625 using const_sentinel =
typename __detail::__const_sentinel<_Sent>::type;
2627 template<input_iterator _It>
2628 class basic_const_iterator
2629 :
public __detail::__basic_const_iterator_iter_cat<_It>
2631 _It _M_current = _It();
2632 using __reference = iter_const_reference_t<_It>;
2633 using __rvalue_reference = __detail::__iter_const_rvalue_reference_t<_It>;
2638 if constexpr (contiguous_iterator<_It>)
2639 return contiguous_iterator_tag{};
2640 else if constexpr (random_access_iterator<_It>)
2641 return random_access_iterator_tag{};
2642 else if constexpr (bidirectional_iterator<_It>)
2643 return bidirectional_iterator_tag{};
2644 else if constexpr (forward_iterator<_It>)
2645 return forward_iterator_tag{};
2647 return input_iterator_tag{};
2650 template<input_iterator _It2>
friend class basic_const_iterator;
2653 using iterator_concept =
decltype(_S_iter_concept());
2654 using value_type = iter_value_t<_It>;
2655 using difference_type = iter_difference_t<_It>;
2657 basic_const_iterator()
requires default_initializable<_It> = default;
2660 basic_const_iterator(_It __current)
2661 noexcept(is_nothrow_move_constructible_v<_It>)
2662 : _M_current(
std::
move(__current))
2665 template<convertible_to<_It> _It2>
2667 basic_const_iterator(basic_const_iterator<_It2> __current)
2668 noexcept(is_nothrow_constructible_v<_It, _It2>)
2669 : _M_current(
std::
move(__current._M_current))
2672 template<__detail::__different_from<basic_const_iterator> _Tp>
2673 requires convertible_to<_Tp, _It>
2675 basic_const_iterator(_Tp&& __current)
2676 noexcept(is_nothrow_constructible_v<_It, _Tp>)
2680 constexpr const _It&
2681 base() const & noexcept
2682 {
return _M_current; }
2686 noexcept(is_nothrow_move_constructible_v<_It>)
2689 constexpr __reference
2691 noexcept(noexcept(static_cast<__reference>(*_M_current)))
2692 {
return static_cast<__reference
>(*_M_current); }
2694 constexpr const auto*
2696 noexcept(contiguous_iterator<_It> || noexcept(*_M_current))
2697 requires is_lvalue_reference_v<iter_reference_t<_It>>
2698 && same_as<remove_cvref_t<iter_reference_t<_It>>, value_type>
2700 if constexpr (contiguous_iterator<_It>)
2706 constexpr basic_const_iterator&
2708 noexcept(noexcept(++_M_current))
2716 noexcept(
noexcept(++_M_current))
2719 constexpr basic_const_iterator
2721 noexcept(
noexcept(++*
this) && is_nothrow_copy_constructible_v<basic_const_iterator>)
2722 requires forward_iterator<_It>
2729 constexpr basic_const_iterator&
2731 noexcept(noexcept(--_M_current))
2732 requires bidirectional_iterator<_It>
2738 constexpr basic_const_iterator
2740 noexcept(
noexcept(--*
this) && is_nothrow_copy_constructible_v<basic_const_iterator>)
2741 requires bidirectional_iterator<_It>
2748 constexpr basic_const_iterator&
2749 operator+=(difference_type __n)
2750 noexcept(
noexcept(_M_current += __n))
2751 requires random_access_iterator<_It>
2757 constexpr basic_const_iterator&
2758 operator-=(difference_type __n)
2759 noexcept(
noexcept(_M_current -= __n))
2760 requires random_access_iterator<_It>
2766 constexpr __reference
2767 operator[](difference_type __n)
const
2768 noexcept(
noexcept(
static_cast<__reference
>(_M_current[__n])))
2769 requires random_access_iterator<_It>
2770 {
return static_cast<__reference
>(_M_current[__n]); }
2772 template<sentinel_for<_It> _Sent>
2774 operator==(
const _Sent& __s)
const
2775 noexcept(
noexcept(_M_current == __s))
2776 {
return _M_current == __s; }
2779 operator<(
const basic_const_iterator& __y)
const
2780 noexcept(
noexcept(_M_current < __y._M_current))
2781 requires random_access_iterator<_It>
2782 {
return _M_current < __y._M_current; }
2785 operator>(
const basic_const_iterator& __y)
const
2786 noexcept(
noexcept(_M_current > __y._M_current))
2787 requires random_access_iterator<_It>
2788 {
return _M_current > __y._M_current; }
2791 operator<=(
const basic_const_iterator& __y)
const
2792 noexcept(
noexcept(_M_current <= __y._M_current))
2793 requires random_access_iterator<_It>
2794 {
return _M_current <= __y._M_current; }
2797 operator>=(
const basic_const_iterator& __y)
const
2798 noexcept(
noexcept(_M_current >= __y._M_current))
2799 requires random_access_iterator<_It>
2800 {
return _M_current >= __y._M_current; }
2803 operator<=>(
const basic_const_iterator& __y)
const
2804 noexcept(
noexcept(_M_current <=> __y._M_current))
2805 requires random_access_iterator<_It> && three_way_comparable<_It>
2806 {
return _M_current <=> __y._M_current; }
2808 template<__detail::__different_from<basic_const_iterator> _It2>
2811 noexcept(
noexcept(_M_current < __y))
2812 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2813 {
return _M_current < __y; }
2815 template<__detail::__different_from<basic_const_iterator> _It2>
2818 noexcept(
noexcept(_M_current > __y))
2819 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2820 {
return _M_current > __y; }
2822 template<__detail::__different_from<basic_const_iterator> _It2>
2825 noexcept(
noexcept(_M_current <= __y))
2826 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2827 {
return _M_current <= __y; }
2829 template<__detail::__different_from<basic_const_iterator> _It2>
2832 noexcept(
noexcept(_M_current >= __y))
2833 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2834 {
return _M_current >= __y; }
2836 template<__detail::__different_from<basic_const_iterator> _It2>
2838 operator<=>(
const _It2& __y)
const
2839 noexcept(
noexcept(_M_current <=> __y))
2840 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2841 && three_way_comparable_with<_It, _It2>
2842 {
return _M_current <=> __y; }
2844 template<__detail::__not_a_const_iterator _It2>
2845 friend constexpr bool
2846 operator<(
const _It2& __x,
const basic_const_iterator& __y)
2847 noexcept(
noexcept(__x < __y._M_current))
2848 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2849 {
return __x < __y._M_current; }
2851 template<__detail::__not_a_const_iterator _It2>
2852 friend constexpr bool
2853 operator>(
const _It2& __x,
const basic_const_iterator& __y)
2854 noexcept(
noexcept(__x > __y._M_current))
2855 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2856 {
return __x > __y._M_current; }
2858 template<__detail::__not_a_const_iterator _It2>
2859 friend constexpr bool
2860 operator<=(
const _It2& __x,
const basic_const_iterator& __y)
2861 noexcept(
noexcept(__x <= __y._M_current))
2862 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2863 {
return __x <= __y._M_current; }
2865 template<__detail::__not_a_const_iterator _It2>
2866 friend constexpr bool
2867 operator>=(
const _It2& __x,
const basic_const_iterator& __y)
2868 noexcept(
noexcept(__x >= __y._M_current))
2869 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2870 {
return __x >= __y._M_current; }
2872 friend constexpr basic_const_iterator
2873 operator+(
const basic_const_iterator& __i, difference_type __n)
2874 noexcept(
noexcept(basic_const_iterator(__i._M_current + __n)))
2875 requires random_access_iterator<_It>
2876 {
return basic_const_iterator(__i._M_current + __n); }
2878 friend constexpr basic_const_iterator
2879 operator+(difference_type __n,
const basic_const_iterator& __i)
2880 noexcept(
noexcept(basic_const_iterator(__i._M_current + __n)))
2881 requires random_access_iterator<_It>
2882 {
return basic_const_iterator(__i._M_current + __n); }
2884 friend constexpr basic_const_iterator
2885 operator-(
const basic_const_iterator& __i, difference_type __n)
2886 noexcept(
noexcept(basic_const_iterator(__i._M_current - __n)))
2887 requires random_access_iterator<_It>
2888 {
return basic_const_iterator(__i._M_current - __n); }
2890 template<sized_sentinel_for<_It> _Sent>
2891 constexpr difference_type
2893 noexcept(
noexcept(_M_current - __y))
2894 {
return _M_current - __y; }
2896 template<__detail::__not_a_const_iterator _Sent>
2897 requires sized_sentinel_for<_Sent, _It>
2898 friend constexpr difference_type
2899 operator-(
const _Sent& __x,
const basic_const_iterator& __y)
2900 noexcept(
noexcept(__x - __y._M_current))
2901 {
return __x - __y._M_current; }
2903 friend constexpr __rvalue_reference
2904 iter_move(
const basic_const_iterator& __i)
2905 noexcept(
noexcept(
static_cast<__rvalue_reference
>(ranges::iter_move(__i._M_current))))
2906 {
return static_cast<__rvalue_reference
>(ranges::iter_move(__i._M_current)); }
2909 template<
typename _Tp, common_with<_Tp> _Up>
2910 requires input_iterator<common_type_t<_Tp, _Up>>
2911 struct common_type<basic_const_iterator<_Tp>, _Up>
2912 {
using type = basic_const_iterator<common_type_t<_Tp, _Up>>; };
2914 template<
typename _Tp, common_with<_Tp> _Up>
2915 requires input_iterator<common_type_t<_Tp, _Up>>
2916 struct common_type<_Up, basic_const_iterator<_Tp>>
2917 {
using type = basic_const_iterator<common_type_t<_Tp, _Up>>; };
2919 template<
typename _Tp, common_with<_Tp> _Up>
2920 requires input_iterator<common_type_t<_Tp, _Up>>
2921 struct common_type<basic_const_iterator<_Tp>, basic_const_iterator<_Up>>
2922 {
using type = basic_const_iterator<common_type_t<_Tp, _Up>>; };
2924 template<input_iterator _It>
2925 constexpr const_iterator<_It>
2926 make_const_iterator(_It __it)
2927 noexcept(is_nothrow_convertible_v<_It, const_iterator<_It>>)
2930 template<semiregular _Sent>
2931 constexpr const_sentinel<_Sent>
2932 make_const_sentinel(_Sent __s)
2933 noexcept(is_nothrow_convertible_v<_Sent, const_sentinel<_Sent>>)
2940 template<
typename _Iterator>
2941 _GLIBCXX20_CONSTEXPR
2943 __niter_base(move_iterator<_Iterator> __it)
2944 ->
decltype(make_move_iterator(__niter_base(__it.base())))
2945 {
return make_move_iterator(__niter_base(__it.base())); }
2947 template<
typename _Iterator>
2948 struct __is_move_iterator<move_iterator<_Iterator> >
2950 enum { __value = 1 };
2951 typedef __true_type __type;
2954 template<
typename _Iterator>
2955 _GLIBCXX20_CONSTEXPR
2957 __miter_base(move_iterator<_Iterator> __it)
2958 ->
decltype(__miter_base(__it.base()))
2959 {
return __miter_base(__it.base()); }
2961#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter)
2962#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) \
2963 std::__make_move_if_noexcept_iterator(_Iter)
2965#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter)
2966#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter)
2969#if __cpp_deduction_guides >= 201606
2972 template<
typename _InputIterator>
2973 using __iter_key_t = remove_const_t<
2974 typename iterator_traits<_InputIterator>::value_type::first_type>;
2976 template<
typename _InputIterator>
2978 =
typename iterator_traits<_InputIterator>::value_type::second_type;
2980 template<
typename _T1,
typename _T2>
2983 template<
typename _InputIterator>
2984 using __iter_to_alloc_t
2985 = pair<const __iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>>;
2988_GLIBCXX_END_NAMESPACE_VERSION
2991#ifdef _GLIBCXX_DEBUG
constexpr bool operator<=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator<(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
constexpr complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
constexpr _Tp * to_address(_Tp *__ptr) noexcept
Obtain address referenced by a pointer to an object.
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.
constexpr reverse_iterator< _Iterator > make_reverse_iterator(_Iterator __i)
Generator function for reverse_iterator.
constexpr insert_iterator< _Container > inserter(_Container &__x, std::__detail::__range_iter_t< _Container > __i)
constexpr front_insert_iterator< _Container > front_inserter(_Container &__x)
constexpr back_insert_iterator< _Container > back_inserter(_Container &__x)
ISO C++ entities toplevel namespace is std.
GNU extensions for public use.
is_nothrow_copy_constructible
Traits class for iterators.
constexpr reverse_iterator & operator-=(difference_type __n)
constexpr reverse_iterator & operator+=(difference_type __n)
constexpr reverse_iterator operator+(difference_type __n) const
constexpr iterator_type base() const noexcept(/*conditional */)
constexpr reference operator[](difference_type __n) const
constexpr reverse_iterator & operator--()
constexpr pointer operator->() const
constexpr reference operator*() const
constexpr reverse_iterator operator-(difference_type __n) const
constexpr reverse_iterator & operator++()
Turns assignment into insertion.
constexpr back_insert_iterator operator++(int)
Simply returns *this. (This iterator does not move.)
_Container container_type
A nested typedef for the type of whatever container you used.
constexpr back_insert_iterator & operator++()
Simply returns *this. (This iterator does not move.)
constexpr back_insert_iterator & operator=(const typename _Container::value_type &__value)
constexpr back_insert_iterator(_Container &__x)
The only way to create this iterator is with a container.
constexpr back_insert_iterator & operator*()
Simply returns *this.
Turns assignment into insertion.
_Container container_type
A nested typedef for the type of whatever container you used.
constexpr front_insert_iterator operator++(int)
Simply returns *this. (This iterator does not move.)
constexpr front_insert_iterator(_Container &__x)
The only way to create this iterator is with a container.
constexpr front_insert_iterator & operator++()
Simply returns *this. (This iterator does not move.)
constexpr front_insert_iterator & operator*()
Simply returns *this.
constexpr front_insert_iterator & operator=(const typename _Container::value_type &__value)
Turns assignment into insertion.
constexpr insert_iterator & operator++(int)
Simply returns *this. (This iterator does not move.)
constexpr insert_iterator & operator*()
Simply returns *this.
_Container container_type
A nested typedef for the type of whatever container you used.
constexpr insert_iterator & operator=(const typename _Container::value_type &__value)
constexpr insert_iterator & operator++()
Simply returns *this. (This iterator does not move.)
constexpr insert_iterator(_Container &__x, _Iter __i)
An iterator/sentinel adaptor for representing a non-common range.
An iterator adaptor that keeps track of the distance to the end.
Forward iterators support a superset of input iterator operations.
Bidirectional iterators support a superset of forward iterator operations.
Random-access iterators support a superset of bidirectional iterator operations.