60#ifndef _STL_ITERATOR_H
61#define _STL_ITERATOR_H 1
69#if __cplusplus >= 201103L
73#if __cplusplus >= 202002L
81#if __glibcxx_tuple_like
85namespace std _GLIBCXX_VISIBILITY(default)
87_GLIBCXX_BEGIN_NAMESPACE_VERSION
99 template<
typename _Cat,
typename _Limit,
typename _Otherwise = _Cat>
100 using __clamp_iter_cat
101 = __conditional_t<derived_from<_Cat, _Limit>, _Limit, _Otherwise>;
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
1827 template<
typename _Iterator1,
typename _Iterator2>
1828 requires (!sized_sentinel_for<_Iterator1, _Iterator2>)
1829 inline constexpr bool
1830 disable_sized_sentinel_for<move_iterator<_Iterator1>,
1831 move_iterator<_Iterator2>> =
true;
1837 template<
typename _It>
1838 concept __common_iter_has_arrow = indirectly_readable<const _It>
1839 && (
requires(
const _It& __it) { __it.operator->(); }
1840 || is_reference_v<iter_reference_t<_It>>
1841 || constructible_from<iter_value_t<_It>, iter_reference_t<_It>>);
1843 template<
typename _It>
1844 concept __common_iter_use_postfix_proxy
1845 = (!
requires (_It& __i) { { *__i++ } -> __can_reference; })
1846 && constructible_from<iter_value_t<_It>, iter_reference_t<_It>>
1847 && move_constructible<iter_value_t<_It>>;
1851 template<input_or_output_iterator _It, sentinel_for<_It> _Sent>
1852 requires (!same_as<_It, _Sent>) && copyable<_It>
1855 template<
typename _Tp,
typename _Up>
1856 static constexpr bool
1865 template<
typename _It2,
typename _Sent2>
1866 static constexpr bool
1882 operator->()
const noexcept
1886 class __postfix_proxy
1907 : _M_it(), _M_index(0)
1922 template<
typename _It2,
typename _Sent2>
1928 : _M_valueless(), _M_index(__x._M_index)
1930 __glibcxx_assert(__x._M_has_value());
1938 else if (_M_index == 1)
1953 : _M_valueless(), _M_index(__x._M_index)
1962 else if (_M_index == 1)
1965 _M_sent = __x._M_sent;
1977 : _M_valueless(), _M_index(__x._M_index)
1986 else if (_M_index == 1)
2028 template<
typename _It2,
typename _Sent2>
2040 __glibcxx_assert(__x._M_has_value());
2045#if __cpp_concepts >= 202002L
2059 else if (_M_index == 1)
2064 constexpr decltype(
auto)
2067 __glibcxx_assert(_M_index == 0);
2072 constexpr decltype(
auto)
2073 operator*()
const requires __detail::__dereferenceable<const _It>
2075 __glibcxx_assert(_M_index == 0);
2081 operator->()
const requires __detail::__common_iter_has_arrow<_It>
2083 __glibcxx_assert(_M_index == 0);
2088 auto&&
__tmp = *_M_it;
2092 return __arrow_proxy{*_M_it};
2098 __glibcxx_assert(_M_index == 0);
2103 constexpr decltype(
auto)
2106 __glibcxx_assert(_M_index == 0);
2113 else if constexpr (!__detail::__common_iter_use_postfix_proxy<_It>)
2117 __postfix_proxy __p(**
this);
2123 template<
typename _It2, sentinel_for<_It> _Sent2>
2125 friend constexpr bool
2129 switch(__x._M_index << 2 | __y._M_index)
2135 return __x._M_it == __y._M_sent;
2137 return __x._M_sent == __y._M_it;
2139 __glibcxx_assert(__x._M_has_value());
2140 __glibcxx_assert(__y._M_has_value());
2145 template<
typename _It2, sentinel_for<_It> _Sent2>
2147 friend constexpr bool
2151 switch(__x._M_index << 2 | __y._M_index)
2156 return __x._M_it == __y._M_it;
2158 return __x._M_it == __y._M_sent;
2160 return __x._M_sent == __y._M_it;
2162 __glibcxx_assert(__x._M_has_value());
2163 __glibcxx_assert(__y._M_has_value());
2168 template<sized_sentinel_for<_It> _It2, sized_sentinel_for<_It> _Sent2>
2174 switch(__x._M_index << 2 | __y._M_index)
2179 return __x._M_it - __y._M_it;
2181 return __x._M_it - __y._M_sent;
2183 return __x._M_sent - __y._M_it;
2185 __glibcxx_assert(__x._M_has_value());
2186 __glibcxx_assert(__y._M_has_value());
2197 __glibcxx_assert(__i._M_index == 0);
2198 return ranges::iter_move(__i._M_it);
2201 template<indirectly_swappable<_It> _It2,
typename _Sent2>
2202 friend constexpr void
2208 __glibcxx_assert(__x._M_index == 0);
2209 __glibcxx_assert(__y._M_index == 0);
2210 return ranges::iter_swap(__x._M_it, __y._M_it);
2214 template<input_or_output_iterator _It2, sentinel_for<_It2> _Sent2>
2219 _M_has_value()
const noexcept {
return _M_index != _S_valueless; }
2221 template<
typename _CIt>
2223 _M_assign(
_CIt&& __x)
2225 if (_M_index == __x._M_index)
2229 else if (_M_index == 1)
2236 else if (_M_index == 1)
2238 _M_index = _S_valueless;
2240 if (__x._M_index == 0)
2243 else if (__x._M_index == 1)
2246 _M_index = __x._M_index;
2254 unsigned char _M_valueless;
2256 unsigned char _M_index;
2258 static constexpr unsigned char _S_valueless{2};
2261 template<
typename _It,
typename _Sent>
2267 template<input_iterator _It,
typename _Sent>
2268 struct iterator_traits<common_iterator<_It, _Sent>>
2271 template<
typename _Iter>
2277 template<
typename _Iter>
2278 requires __detail::__common_iter_has_arrow<_Iter>
2281 using _CIter = common_iterator<_Iter, _Sent>;
2288 if constexpr (
requires {
requires derived_from<__iter_category_t<_It>,
2289 forward_iterator_tag>; })
2290 return forward_iterator_tag{};
2292 return input_iterator_tag{};
2296 using iterator_concept = __conditional_t<forward_iterator<_It>,
2297 forward_iterator_tag,
2298 input_iterator_tag>;
2299 using iterator_category =
decltype(_S_iter_cat());
2300 using value_type = iter_value_t<_It>;
2301 using difference_type = iter_difference_t<_It>;
2302 using pointer =
typename __ptr<_It>::type;
2303 using reference = iter_reference_t<_It>;
2310 template<
typename _It>
2311 struct __counted_iter_value_type
2314 template<indirectly_readable _It>
2315 struct __counted_iter_value_type<_It>
2316 {
using value_type = iter_value_t<_It>; };
2318 template<
typename _It>
2319 struct __counted_iter_concept
2322 template<
typename _It>
2323 requires requires {
typename _It::iterator_concept; }
2324 struct __counted_iter_concept<_It>
2325 {
using iterator_concept =
typename _It::iterator_concept; };
2327 template<
typename _It>
2328 struct __counted_iter_cat
2331 template<
typename _It>
2332 requires requires {
typename _It::iterator_category; }
2333 struct __counted_iter_cat<_It>
2334 {
using iterator_category =
typename _It::iterator_category; };
2338 template<input_or_output_iterator _It>
2340 :
public __detail::__counted_iter_value_type<_It>,
2341 public __detail::__counted_iter_concept<_It>,
2342 public __detail::__counted_iter_cat<_It>
2345 using iterator_type = _It;
2355 : _M_current(
std::move(__i)), _M_length(__n)
2356 { __glibcxx_assert(__n >= 0); }
2358 template<
typename _It2>
2362 : _M_current(__x._M_current), _M_length(__x._M_length)
2365 template<
typename _It2>
2370 _M_current = __x._M_current;
2371 _M_length = __x._M_length;
2376 constexpr const _It&
2377 base()
const &
noexcept
2378 {
return _M_current; }
2388 count()
const noexcept {
return _M_length; }
2391 constexpr decltype(
auto)
2393 noexcept(
noexcept(*_M_current))
2395 __glibcxx_assert( _M_length > 0 );
2400 constexpr decltype(
auto)
2402 noexcept(
noexcept(*_M_current))
2403 requires __detail::__dereferenceable<const _It>
2405 __glibcxx_assert( _M_length > 0 );
2411 operator->()
const noexcept
2418 __glibcxx_assert(_M_length > 0);
2424 constexpr decltype(
auto)
2427 __glibcxx_assert(_M_length > 0);
2431 return _M_current++;
2434 __throw_exception_again;
2472 {
return __x + __n; }
2478 __glibcxx_assert(__n <= _M_length);
2490 template<common_with<_It> _It2>
2495 {
return __y._M_length - __x._M_length; }
2500 {
return -__x._M_length; }
2505 {
return __y._M_length; }
2511 __glibcxx_assert(-__n <= _M_length);
2518 constexpr decltype(
auto)
2520 noexcept(
noexcept(_M_current[__n]))
2523 __glibcxx_assert(__n < _M_length);
2524 return _M_current[__n];
2527 template<common_with<_It> _It2>
2529 friend constexpr bool
2532 {
return __x._M_length == __y._M_length; }
2535 friend constexpr bool
2537 {
return __x._M_length == 0; }
2539 template<common_with<_It> _It2>
2541 friend constexpr strong_ordering
2544 {
return __y._M_length <=> __x._M_length; }
2549 noexcept(
noexcept(ranges::iter_move(__i._M_current)))
2552 __glibcxx_assert( __i._M_length > 0 );
2553 return ranges::iter_move(__i._M_current);
2556 template<indirectly_swappable<_It> _It2>
2557 friend constexpr void
2560 noexcept(
noexcept(ranges::iter_swap(__x._M_current, __y._M_current)))
2562 __glibcxx_assert( __x._M_length > 0 && __y._M_length > 0 );
2563 ranges::iter_swap(__x._M_current, __y._M_current);
2569 _It _M_current = _It();
2573 template<input_iterator _It>
2582#if __glibcxx_ranges_as_const
2583 template<indirectly_readable _It>
2584 using iter_const_reference_t
2585 = common_reference_t<const iter_value_t<_It>&&, iter_reference_t<_It>>;
2587 template<input_iterator _It>
class basic_const_iterator;
2591 template<
typename _It>
2592 concept __constant_iterator = input_iterator<_It>
2593 && same_as<iter_const_reference_t<_It>, iter_reference_t<_It>>;
2595 template<
typename _Tp>
2596 inline constexpr bool __is_const_iterator =
false;
2598 template<
typename _It>
2599 inline constexpr bool __is_const_iterator<basic_const_iterator<_It>> =
true;
2601 template<
typename _Tp>
2602 concept __not_a_const_iterator = !__is_const_iterator<_Tp>;
2604 template<indirectly_readable _It>
2605 using __iter_const_rvalue_reference_t
2606 = common_reference_t<const iter_value_t<_It>&&, iter_rvalue_reference_t<_It>>;
2608 template<
typename _It>
2609 struct __basic_const_iterator_iter_cat
2612 template<forward_iterator _It>
2613 struct __basic_const_iterator_iter_cat<_It>
2614 {
using iterator_category = __iter_category_t<_It>; };
2617 template<input_iterator _It>
2618 using const_iterator
2619 = __conditional_t<__detail::__constant_iterator<_It>, _It, basic_const_iterator<_It>>;
2623 template<
typename _Sent>
2624 struct __const_sentinel
2625 {
using type = _Sent; };
2627 template<input_iterator _Sent>
2628 struct __const_sentinel<_Sent>
2629 {
using type = const_iterator<_Sent>; };
2632 template<semiregular _Sent>
2633 using const_sentinel =
typename __detail::__const_sentinel<_Sent>::type;
2635 template<input_iterator _It>
2636 class basic_const_iterator
2637 :
public __detail::__basic_const_iterator_iter_cat<_It>
2639 _It _M_current = _It();
2640 using __reference = iter_const_reference_t<_It>;
2641 using __rvalue_reference = __detail::__iter_const_rvalue_reference_t<_It>;
2646 if constexpr (contiguous_iterator<_It>)
2647 return contiguous_iterator_tag{};
2648 else if constexpr (random_access_iterator<_It>)
2649 return random_access_iterator_tag{};
2650 else if constexpr (bidirectional_iterator<_It>)
2651 return bidirectional_iterator_tag{};
2652 else if constexpr (forward_iterator<_It>)
2653 return forward_iterator_tag{};
2655 return input_iterator_tag{};
2658 template<input_iterator _It2>
friend class basic_const_iterator;
2661 using iterator_concept =
decltype(_S_iter_concept());
2662 using value_type = iter_value_t<_It>;
2663 using difference_type = iter_difference_t<_It>;
2665 basic_const_iterator()
requires default_initializable<_It> = default;
2668 basic_const_iterator(_It __current)
2669 noexcept(is_nothrow_move_constructible_v<_It>)
2670 : _M_current(
std::
move(__current))
2673 template<convertible_to<_It> _It2>
2675 basic_const_iterator(basic_const_iterator<_It2> __current)
2676 noexcept(is_nothrow_constructible_v<_It, _It2>)
2677 : _M_current(
std::
move(__current._M_current))
2680 template<__detail::__different_from<basic_const_iterator> _Tp>
2681 requires convertible_to<_Tp, _It>
2683 basic_const_iterator(_Tp&& __current)
2684 noexcept(is_nothrow_constructible_v<_It, _Tp>)
2688 constexpr const _It&
2689 base() const & noexcept
2690 {
return _M_current; }
2694 noexcept(is_nothrow_move_constructible_v<_It>)
2697 constexpr __reference
2699 noexcept(noexcept(static_cast<__reference>(*_M_current)))
2700 {
return static_cast<__reference
>(*_M_current); }
2702 constexpr const auto*
2704 noexcept(contiguous_iterator<_It> || noexcept(*_M_current))
2705 requires is_lvalue_reference_v<iter_reference_t<_It>>
2706 && same_as<remove_cvref_t<iter_reference_t<_It>>, value_type>
2708 if constexpr (contiguous_iterator<_It>)
2714 constexpr basic_const_iterator&
2716 noexcept(noexcept(++_M_current))
2724 noexcept(
noexcept(++_M_current))
2727 constexpr basic_const_iterator
2729 noexcept(
noexcept(++*
this) && is_nothrow_copy_constructible_v<basic_const_iterator>)
2730 requires forward_iterator<_It>
2737 constexpr basic_const_iterator&
2739 noexcept(noexcept(--_M_current))
2740 requires bidirectional_iterator<_It>
2746 constexpr basic_const_iterator
2748 noexcept(
noexcept(--*
this) && is_nothrow_copy_constructible_v<basic_const_iterator>)
2749 requires bidirectional_iterator<_It>
2756 constexpr basic_const_iterator&
2757 operator+=(difference_type __n)
2758 noexcept(
noexcept(_M_current += __n))
2759 requires random_access_iterator<_It>
2765 constexpr basic_const_iterator&
2766 operator-=(difference_type __n)
2767 noexcept(
noexcept(_M_current -= __n))
2768 requires random_access_iterator<_It>
2774 constexpr __reference
2775 operator[](difference_type __n)
const
2776 noexcept(
noexcept(
static_cast<__reference
>(_M_current[__n])))
2777 requires random_access_iterator<_It>
2778 {
return static_cast<__reference
>(_M_current[__n]); }
2780 template<sentinel_for<_It> _Sent>
2782 operator==(
const _Sent& __s)
const
2783 noexcept(
noexcept(_M_current == __s))
2784 {
return _M_current == __s; }
2786 template<__detail::__not_a_const_iterator _CIt>
2787 requires __detail::__constant_iterator<_CIt> && convertible_to<_It, _CIt>
2789 operator _CIt() const&
2790 {
return _M_current; }
2792 template<__detail::__not_a_const_iterator _CIt>
2793 requires __detail::__constant_iterator<_CIt> && convertible_to<_It, _CIt>
2799 operator<(
const basic_const_iterator& __y)
const
2800 noexcept(
noexcept(_M_current < __y._M_current))
2801 requires random_access_iterator<_It>
2802 {
return _M_current < __y._M_current; }
2805 operator>(
const basic_const_iterator& __y)
const
2806 noexcept(
noexcept(_M_current > __y._M_current))
2807 requires random_access_iterator<_It>
2808 {
return _M_current > __y._M_current; }
2811 operator<=(
const basic_const_iterator& __y)
const
2812 noexcept(
noexcept(_M_current <= __y._M_current))
2813 requires random_access_iterator<_It>
2814 {
return _M_current <= __y._M_current; }
2817 operator>=(
const basic_const_iterator& __y)
const
2818 noexcept(
noexcept(_M_current >= __y._M_current))
2819 requires random_access_iterator<_It>
2820 {
return _M_current >= __y._M_current; }
2823 operator<=>(
const basic_const_iterator& __y)
const
2824 noexcept(
noexcept(_M_current <=> __y._M_current))
2825 requires random_access_iterator<_It> && three_way_comparable<_It>
2826 {
return _M_current <=> __y._M_current; }
2828 template<__detail::__different_from<basic_const_iterator> _It2>
2831 noexcept(
noexcept(_M_current < __y))
2832 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2833 {
return _M_current < __y; }
2835 template<__detail::__different_from<basic_const_iterator> _It2>
2838 noexcept(
noexcept(_M_current > __y))
2839 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2840 {
return _M_current > __y; }
2842 template<__detail::__different_from<basic_const_iterator> _It2>
2845 noexcept(
noexcept(_M_current <= __y))
2846 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2847 {
return _M_current <= __y; }
2849 template<__detail::__different_from<basic_const_iterator> _It2>
2852 noexcept(
noexcept(_M_current >= __y))
2853 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2854 {
return _M_current >= __y; }
2856 template<__detail::__different_from<basic_const_iterator> _It2>
2858 operator<=>(
const _It2& __y)
const
2859 noexcept(
noexcept(_M_current <=> __y))
2860 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2861 && three_way_comparable_with<_It, _It2>
2862 {
return _M_current <=> __y; }
2864 template<__detail::__not_a_const_iterator _It2>
2865 friend constexpr bool
2866 operator<(
const _It2& __x,
const basic_const_iterator& __y)
2867 noexcept(
noexcept(__x < __y._M_current))
2868 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2869 {
return __x < __y._M_current; }
2871 template<__detail::__not_a_const_iterator _It2>
2872 friend constexpr bool
2873 operator>(
const _It2& __x,
const basic_const_iterator& __y)
2874 noexcept(
noexcept(__x > __y._M_current))
2875 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2876 {
return __x > __y._M_current; }
2878 template<__detail::__not_a_const_iterator _It2>
2879 friend constexpr bool
2880 operator<=(
const _It2& __x,
const basic_const_iterator& __y)
2881 noexcept(
noexcept(__x <= __y._M_current))
2882 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2883 {
return __x <= __y._M_current; }
2885 template<__detail::__not_a_const_iterator _It2>
2886 friend constexpr bool
2887 operator>=(
const _It2& __x,
const basic_const_iterator& __y)
2888 noexcept(
noexcept(__x >= __y._M_current))
2889 requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
2890 {
return __x >= __y._M_current; }
2892 friend constexpr basic_const_iterator
2893 operator+(
const basic_const_iterator& __i, difference_type __n)
2894 noexcept(
noexcept(basic_const_iterator(__i._M_current + __n)))
2895 requires random_access_iterator<_It>
2896 {
return basic_const_iterator(__i._M_current + __n); }
2898 friend constexpr basic_const_iterator
2899 operator+(difference_type __n,
const basic_const_iterator& __i)
2900 noexcept(
noexcept(basic_const_iterator(__i._M_current + __n)))
2901 requires random_access_iterator<_It>
2902 {
return basic_const_iterator(__i._M_current + __n); }
2904 friend constexpr basic_const_iterator
2905 operator-(
const basic_const_iterator& __i, difference_type __n)
2906 noexcept(
noexcept(basic_const_iterator(__i._M_current - __n)))
2907 requires random_access_iterator<_It>
2908 {
return basic_const_iterator(__i._M_current - __n); }
2910 template<sized_sentinel_for<_It> _Sent>
2911 constexpr difference_type
2913 noexcept(
noexcept(_M_current - __y))
2914 {
return _M_current - __y; }
2916 template<__detail::__not_a_const_iterator _Sent>
2917 requires sized_sentinel_for<_Sent, _It>
2918 friend constexpr difference_type
2919 operator-(
const _Sent& __x,
const basic_const_iterator& __y)
2920 noexcept(
noexcept(__x - __y._M_current))
2921 {
return __x - __y._M_current; }
2923 friend constexpr __rvalue_reference
2924 iter_move(
const basic_const_iterator& __i)
2925 noexcept(
noexcept(
static_cast<__rvalue_reference
>(ranges::iter_move(__i._M_current))))
2926 {
return static_cast<__rvalue_reference
>(ranges::iter_move(__i._M_current)); }
2929 template<
typename _Tp, common_with<_Tp> _Up>
2930 requires input_iterator<common_type_t<_Tp, _Up>>
2931 struct common_type<basic_const_iterator<_Tp>, _Up>
2932 {
using type = basic_const_iterator<common_type_t<_Tp, _Up>>; };
2934 template<
typename _Tp, common_with<_Tp> _Up>
2935 requires input_iterator<common_type_t<_Tp, _Up>>
2936 struct common_type<_Up, basic_const_iterator<_Tp>>
2937 {
using type = basic_const_iterator<common_type_t<_Tp, _Up>>; };
2939 template<
typename _Tp, common_with<_Tp> _Up>
2940 requires input_iterator<common_type_t<_Tp, _Up>>
2941 struct common_type<basic_const_iterator<_Tp>, basic_const_iterator<_Up>>
2942 {
using type = basic_const_iterator<common_type_t<_Tp, _Up>>; };
2944 template<input_iterator _It>
2945 constexpr const_iterator<_It>
2946 make_const_iterator(_It __it)
2947 noexcept(is_nothrow_convertible_v<_It, const_iterator<_It>>)
2950 template<semiregular _Sent>
2951 constexpr const_sentinel<_Sent>
2952 make_const_sentinel(_Sent __s)
2953 noexcept(is_nothrow_convertible_v<_Sent, const_sentinel<_Sent>>)
2960 template<
typename _Iterator>
2961 _GLIBCXX20_CONSTEXPR
2963 __niter_base(move_iterator<_Iterator> __it)
2964 ->
decltype(make_move_iterator(__niter_base(__it.base())))
2965 {
return make_move_iterator(__niter_base(__it.base())); }
2967 template<
typename _Iterator>
2968 struct __is_move_iterator<move_iterator<_Iterator> >
2970 enum { __value = 1 };
2971 typedef __true_type __type;
2974 template<
typename _Iterator>
2975 _GLIBCXX20_CONSTEXPR
2977 __miter_base(move_iterator<_Iterator> __it)
2978 ->
decltype(__miter_base(__it.base()))
2979 {
return __miter_base(__it.base()); }
2981#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter)
2982#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) \
2983 std::__make_move_if_noexcept_iterator(_Iter)
2985#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter)
2986#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter)
2989#if __cpp_deduction_guides >= 201606
2992 template<
typename _InputIterator>
2993 using __iter_key_t = remove_const_t<
2994#if __glibcxx_tuple_like
2995 tuple_element_t<0, typename iterator_traits<_InputIterator>::value_type>>;
2997 typename iterator_traits<_InputIterator>::value_type::first_type>;
3000 template<
typename _InputIterator>
3002#if __glibcxx_tuple_like
3003 = tuple_element_t<1, typename iterator_traits<_InputIterator>::value_type>;
3005 =
typename iterator_traits<_InputIterator>::value_type::second_type;
3008 template<
typename _T1,
typename _T2>
3011 template<
typename _InputIterator>
3012 using __iter_to_alloc_t
3013 = pair<const __iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>>;
3016_GLIBCXX_END_NAMESPACE_VERSION
3019#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.