60 #ifndef _STL_ITERATOR_H
61 #define _STL_ITERATOR_H 1
69 #if __cplusplus >= 201103L
73 #if __cplusplus > 201703L
74 # define __cpp_lib_array_constexpr 201811L
75 # define __cpp_lib_constexpr_iterator 201811L
76 #elif __cplusplus == 201703L
77 # define __cpp_lib_array_constexpr 201803L
80 #if __cplusplus >= 202002L
88 namespace std _GLIBCXX_VISIBILITY(default)
90 _GLIBCXX_BEGIN_NAMESPACE_VERSION
97 #if __cpp_lib_concepts
102 template<
typename _Cat,
typename _Limit,
typename _Otherwise = _Cat>
103 using __clamp_iter_cat
104 = __conditional_t<derived_from<_Cat, _Limit>, _Limit, _Otherwise>;
109 #pragma GCC diagnostic push
110 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
131 template<
typename _Iterator>
133 :
public iterator<typename iterator_traits<_Iterator>::iterator_category,
134 typename iterator_traits<_Iterator>::value_type,
135 typename iterator_traits<_Iterator>::difference_type,
136 typename iterator_traits<_Iterator>::pointer,
137 typename iterator_traits<_Iterator>::reference>
139 template<
typename _Iter>
142 #if __cpp_lib_concepts
145 template<
typename _Iter>
146 static constexpr
bool __convertible = !is_same_v<_Iter, _Iterator>
147 && convertible_to<const _Iter&, _Iterator>;
156 typedef _Iterator iterator_type;
157 typedef typename __traits_type::pointer pointer;
158 #if ! __cpp_lib_concepts
159 typedef typename __traits_type::difference_type difference_type;
160 typedef typename __traits_type::reference reference;
162 using iterator_concept
163 = __conditional_t<random_access_iterator<_Iterator>,
166 using iterator_category
167 = __detail::__clamp_iter_cat<
typename __traits_type::iterator_category,
169 using value_type = iter_value_t<_Iterator>;
170 using difference_type = iter_difference_t<_Iterator>;
171 using reference = iter_reference_t<_Iterator>;
183 _GLIBCXX_NOEXCEPT_IF(noexcept(_Iterator()))
190 explicit _GLIBCXX17_CONSTEXPR
192 _GLIBCXX_NOEXCEPT_IF(noexcept(_Iterator(__x)))
201 _GLIBCXX_NOEXCEPT_IF(noexcept(_Iterator(__x.current)))
202 : current(__x.current)
205 #if __cplusplus >= 201103L
213 template<
typename _Iter>
214 #if __cpp_lib_concepts
219 _GLIBCXX_NOEXCEPT_IF(noexcept(_Iterator(__x.current)))
220 : current(__x.current)
223 #if __cplusplus >= 201103L
224 template<
typename _Iter>
225 #if __cpp_lib_concepts
227 && assignable_from<_Iterator&, const _Iter&>
232 _GLIBCXX_NOEXCEPT_IF(noexcept(current = __x.current))
234 current = __x.current;
243 _GLIBCXX17_CONSTEXPR iterator_type
245 _GLIBCXX_NOEXCEPT_IF(noexcept(_Iterator(current)))
259 _GLIBCXX17_CONSTEXPR reference
262 _Iterator __tmp = current;
272 _GLIBCXX17_CONSTEXPR pointer
274 #if __cplusplus > 201703L && __cpp_concepts >= 201907L
276 ||
requires(
const _Iterator __i) { __i.operator->(); }
281 _Iterator __tmp = current;
283 return _S_to_pointer(__tmp);
291 _GLIBCXX17_CONSTEXPR reverse_iterator&
388 _GLIBCXX17_CONSTEXPR reference
390 {
return *(*
this + __n); }
392 #if __cplusplus > 201703L && __cpp_lib_concepts
394 friend constexpr iter_rvalue_reference_t<_Iterator>
396 noexcept(is_nothrow_copy_constructible_v<_Iterator>
397 && noexcept(ranges::iter_move(--std::declval<_Iterator&>())))
399 auto __tmp = __i.base();
400 return ranges::iter_move(--__tmp);
403 template<indirectly_swappable<_Iterator> _Iter2>
404 friend constexpr
void
405 iter_swap(
const reverse_iterator& __x,
406 const reverse_iterator<_Iter2>& __y)
407 noexcept(is_nothrow_copy_constructible_v<_Iterator>
408 && is_nothrow_copy_constructible_v<_Iter2>
409 && noexcept(ranges::iter_swap(--std::declval<_Iterator&>(),
410 --std::declval<_Iter2&>())))
412 auto __xtmp = __x.base();
413 auto __ytmp = __y.base();
414 ranges::iter_swap(--__xtmp, --__ytmp);
419 template<
typename _Tp>
420 static _GLIBCXX17_CONSTEXPR _Tp*
421 _S_to_pointer(_Tp* __p)
424 template<
typename _Tp>
425 static _GLIBCXX17_CONSTEXPR pointer
426 _S_to_pointer(_Tp __t)
427 {
return __t.operator->(); }
440 #if __cplusplus <= 201703L || ! defined __cpp_lib_concepts
441 template<
typename _Iterator>
443 inline _GLIBCXX17_CONSTEXPR
bool
444 operator==(
const reverse_iterator<_Iterator>& __x,
445 const reverse_iterator<_Iterator>& __y)
446 {
return __x.base() == __y.base(); }
448 template<
typename _Iterator>
450 inline _GLIBCXX17_CONSTEXPR
bool
451 operator<(
const reverse_iterator<_Iterator>& __x,
452 const reverse_iterator<_Iterator>& __y)
453 {
return __y.base() < __x.base(); }
455 template<
typename _Iterator>
457 inline _GLIBCXX17_CONSTEXPR
bool
458 operator!=(
const reverse_iterator<_Iterator>& __x,
459 const reverse_iterator<_Iterator>& __y)
460 {
return !(__x == __y); }
462 template<
typename _Iterator>
464 inline _GLIBCXX17_CONSTEXPR
bool
465 operator>(
const reverse_iterator<_Iterator>& __x,
466 const reverse_iterator<_Iterator>& __y)
467 {
return __y < __x; }
469 template<
typename _Iterator>
471 inline _GLIBCXX17_CONSTEXPR
bool
472 operator<=(
const reverse_iterator<_Iterator>& __x,
473 const reverse_iterator<_Iterator>& __y)
474 {
return !(__y < __x); }
476 template<
typename _Iterator>
478 inline _GLIBCXX17_CONSTEXPR
bool
479 operator>=(
const reverse_iterator<_Iterator>& __x,
480 const reverse_iterator<_Iterator>& __y)
481 {
return !(__x < __y); }
486 template<
typename _IteratorL,
typename _IteratorR>
488 inline _GLIBCXX17_CONSTEXPR
bool
489 operator==(
const reverse_iterator<_IteratorL>& __x,
490 const reverse_iterator<_IteratorR>& __y)
491 {
return __x.base() == __y.base(); }
493 template<
typename _IteratorL,
typename _IteratorR>
495 inline _GLIBCXX17_CONSTEXPR
bool
496 operator<(
const reverse_iterator<_IteratorL>& __x,
497 const reverse_iterator<_IteratorR>& __y)
498 {
return __x.base() > __y.base(); }
500 template<
typename _IteratorL,
typename _IteratorR>
502 inline _GLIBCXX17_CONSTEXPR
bool
503 operator!=(
const reverse_iterator<_IteratorL>& __x,
504 const reverse_iterator<_IteratorR>& __y)
505 {
return __x.base() != __y.base(); }
507 template<
typename _IteratorL,
typename _IteratorR>
509 inline _GLIBCXX17_CONSTEXPR
bool
510 operator>(
const reverse_iterator<_IteratorL>& __x,
511 const reverse_iterator<_IteratorR>& __y)
512 {
return __x.base() < __y.base(); }
514 template<
typename _IteratorL,
typename _IteratorR>
515 inline _GLIBCXX17_CONSTEXPR
bool
516 operator<=(
const reverse_iterator<_IteratorL>& __x,
517 const reverse_iterator<_IteratorR>& __y)
518 {
return __x.base() >= __y.base(); }
520 template<
typename _IteratorL,
typename _IteratorR>
522 inline _GLIBCXX17_CONSTEXPR
bool
523 operator>=(
const reverse_iterator<_IteratorL>& __x,
524 const reverse_iterator<_IteratorR>& __y)
525 {
return __x.base() <= __y.base(); }
527 template<
typename _IteratorL,
typename _IteratorR>
533 {
return __x.base() == __y.base(); }
535 template<
typename _IteratorL,
typename _IteratorR>
538 operator!=(
const reverse_iterator<_IteratorL>& __x,
539 const reverse_iterator<_IteratorR>& __y)
541 {
return __x.base() != __y.base(); }
543 template<
typename _IteratorL,
typename _IteratorR>
546 operator<(
const reverse_iterator<_IteratorL>& __x,
547 const reverse_iterator<_IteratorR>& __y)
549 {
return __x.base() > __y.base(); }
551 template<
typename _IteratorL,
typename _IteratorR>
554 operator>(
const reverse_iterator<_IteratorL>& __x,
555 const reverse_iterator<_IteratorR>& __y)
557 {
return __x.base() < __y.base(); }
559 template<
typename _IteratorL,
typename _IteratorR>
562 operator<=(
const reverse_iterator<_IteratorL>& __x,
563 const reverse_iterator<_IteratorR>& __y)
565 {
return __x.base() >= __y.base(); }
567 template<
typename _IteratorL,
typename _IteratorR>
570 operator>=(
const reverse_iterator<_IteratorL>& __x,
571 const reverse_iterator<_IteratorR>& __y)
573 {
return __x.base() <= __y.base(); }
575 template<
typename _IteratorL,
576 three_way_comparable_with<_IteratorL> _IteratorR>
578 constexpr compare_three_way_result_t<_IteratorL, _IteratorR>
579 operator<=>(
const reverse_iterator<_IteratorL>& __x,
580 const reverse_iterator<_IteratorR>& __y)
581 {
return __y.base() <=> __x.base(); }
586 template<
typename _Iterator>
589 operator==(
const reverse_iterator<_Iterator>& __x,
590 const reverse_iterator<_Iterator>& __y)
592 {
return __x.base() == __y.base(); }
594 template<three_way_comparable _Iterator>
596 constexpr compare_three_way_result_t<_Iterator, _Iterator>
597 operator<=>(
const reverse_iterator<_Iterator>& __x,
598 const reverse_iterator<_Iterator>& __y)
599 {
return __y.base() <=> __x.base(); }
603 #if __cplusplus < 201103L
604 template<
typename _Iterator>
605 inline typename reverse_iterator<_Iterator>::difference_type
606 operator-(
const reverse_iterator<_Iterator>& __x,
607 const reverse_iterator<_Iterator>& __y)
608 {
return __y.base() - __x.base(); }
610 template<
typename _IteratorL,
typename _IteratorR>
611 inline typename reverse_iterator<_IteratorL>::difference_type
612 operator-(
const reverse_iterator<_IteratorL>& __x,
613 const reverse_iterator<_IteratorR>& __y)
614 {
return __y.base() - __x.base(); }
618 template<
typename _IteratorL,
typename _IteratorR>
620 inline _GLIBCXX17_CONSTEXPR
auto
621 operator-(
const reverse_iterator<_IteratorL>& __x,
622 const reverse_iterator<_IteratorR>& __y)
623 -> decltype(__y.base() - __x.base())
624 {
return __y.base() - __x.base(); }
627 template<
typename _Iterator>
629 inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
630 operator+(
typename reverse_iterator<_Iterator>::difference_type __n,
631 const reverse_iterator<_Iterator>& __x)
632 {
return reverse_iterator<_Iterator>(__x.base() - __n); }
634 #if __cplusplus >= 201103L
636 template<
typename _Iterator>
637 inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
638 __make_reverse_iterator(_Iterator __i)
639 {
return reverse_iterator<_Iterator>(__i); }
641 # if __cplusplus >= 201402L
642 # define __cpp_lib_make_reverse_iterator 201402L
647 template<
typename _Iterator>
649 inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
653 # if __cplusplus > 201703L && defined __cpp_lib_concepts
654 template<
typename _Iterator1,
typename _Iterator2>
655 requires (!sized_sentinel_for<_Iterator1, _Iterator2>)
656 inline constexpr
bool
657 disable_sized_sentinel_for<reverse_iterator<_Iterator1>,
658 reverse_iterator<_Iterator2>> =
true;
662 template<
typename _Iterator>
665 __niter_base(reverse_iterator<_Iterator> __it)
666 -> decltype(__make_reverse_iterator(__niter_base(__it.base())))
667 {
return __make_reverse_iterator(__niter_base(__it.base())); }
669 template<
typename _Iterator>
670 struct __is_move_iterator<reverse_iterator<_Iterator> >
671 : __is_move_iterator<_Iterator>
674 template<
typename _Iterator>
677 __miter_base(reverse_iterator<_Iterator> __it)
678 -> decltype(__make_reverse_iterator(__miter_base(__it.base())))
679 {
return __make_reverse_iterator(__miter_base(__it.base())); }
693 template<
typename _Container>
695 :
public iterator<output_iterator_tag, void, void, void, void>
698 _Container* container;
703 #if __cplusplus > 201703L
704 using difference_type = ptrdiff_t;
708 explicit _GLIBCXX20_CONSTEXPR
723 #if __cplusplus < 201103L
725 operator=(
typename _Container::const_reference __value)
727 container->push_back(__value);
733 operator=(
const typename _Container::value_type& __value)
735 container->push_back(__value);
741 operator=(
typename _Container::value_type&& __value)
743 container->push_back(
std::move(__value));
749 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
778 template<
typename _Container>
779 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
780 inline back_insert_iterator<_Container>
794 template<
typename _Container>
796 :
public iterator<output_iterator_tag, void, void, void, void>
799 _Container* container;
804 #if __cplusplus > 201703L
805 using difference_type = ptrdiff_t;
809 explicit _GLIBCXX20_CONSTEXPR
824 #if __cplusplus < 201103L
826 operator=(
typename _Container::const_reference __value)
828 container->push_front(__value);
834 operator=(
const typename _Container::value_type& __value)
836 container->push_front(__value);
842 operator=(
typename _Container::value_type&& __value)
844 container->push_front(
std::move(__value));
850 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
879 template<
typename _Container>
880 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
881 inline front_insert_iterator<_Container>
899 template<
typename _Container>
901 :
public iterator<output_iterator_tag, void, void, void, void>
903 #if __cplusplus > 201703L && defined __cpp_lib_concepts
904 using _Iter = std::__detail::__range_iter_t<_Container>;
906 typedef typename _Container::iterator _Iter;
909 _Container* container;
916 #if __cplusplus > 201703L && defined __cpp_lib_concepts
917 using difference_type = ptrdiff_t;
951 #if __cplusplus < 201103L
953 operator=(
typename _Container::const_reference __value)
955 iter = container->insert(iter, __value);
962 operator=(
const typename _Container::value_type& __value)
964 iter = container->insert(iter, __value);
971 operator=(
typename _Container::value_type&& __value)
973 iter = container->insert(iter,
std::move(__value));
980 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
998 #pragma GCC diagnostic pop
1012 #if __cplusplus > 201703L && defined __cpp_lib_concepts
1013 template<
typename _Container>
1015 constexpr insert_iterator<_Container>
1016 inserter(_Container& __x, std::__detail::__range_iter_t<_Container> __i)
1019 template<
typename _Container>
1021 inline insert_iterator<_Container>
1022 inserter(_Container& __x,
typename _Container::iterator __i)
1023 {
return insert_iterator<_Container>(__x, __i); }
1028 _GLIBCXX_END_NAMESPACE_VERSION
1031 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
1033 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1042 template<
typename _Iterator,
typename _Container>
1043 class __normal_iterator
1046 _Iterator _M_current;
1050 #if __cplusplus >= 201103L
1051 template<
typename _Iter>
1052 using __convertible_from
1053 = std::__enable_if_t<std::is_convertible<_Iter, _Iterator>::value>;
1057 typedef _Iterator iterator_type;
1058 typedef typename __traits_type::iterator_category iterator_category;
1059 typedef typename __traits_type::value_type value_type;
1060 typedef typename __traits_type::difference_type difference_type;
1061 typedef typename __traits_type::reference reference;
1062 typedef typename __traits_type::pointer pointer;
1064 #if __cplusplus > 201703L && __cpp_lib_concepts
1065 using iterator_concept = std::__detail::__iter_concept<_Iterator>;
1068 _GLIBCXX_CONSTEXPR __normal_iterator() _GLIBCXX_NOEXCEPT
1069 : _M_current(_Iterator()) { }
1071 explicit _GLIBCXX20_CONSTEXPR
1072 __normal_iterator(
const _Iterator& __i) _GLIBCXX_NOEXCEPT
1073 : _M_current(__i) { }
1076 #if __cplusplus >= 201103L
1077 template<
typename _Iter,
typename = __convertible_from<_Iter>>
1078 _GLIBCXX20_CONSTEXPR
1079 __normal_iterator(
const __normal_iterator<_Iter, _Container>& __i)
1084 template<
typename _Iter>
1085 __normal_iterator(
const __normal_iterator<_Iter,
1086 typename __enable_if<
1087 (std::__are_same<_Iter, typename _Container::pointer>::__value),
1088 _Container>::__type>& __i)
1090 : _M_current(__i.base()) { }
1093 _GLIBCXX20_CONSTEXPR
1096 {
return *_M_current; }
1098 _GLIBCXX20_CONSTEXPR
1100 operator->() const _GLIBCXX_NOEXCEPT
1101 {
return _M_current; }
1103 _GLIBCXX20_CONSTEXPR
1105 operator++() _GLIBCXX_NOEXCEPT
1111 _GLIBCXX20_CONSTEXPR
1113 operator++(
int) _GLIBCXX_NOEXCEPT
1114 {
return __normal_iterator(_M_current++); }
1117 _GLIBCXX20_CONSTEXPR
1119 operator--() _GLIBCXX_NOEXCEPT
1125 _GLIBCXX20_CONSTEXPR
1127 operator--(
int) _GLIBCXX_NOEXCEPT
1128 {
return __normal_iterator(_M_current--); }
1131 _GLIBCXX20_CONSTEXPR
1133 operator[](difference_type __n)
const _GLIBCXX_NOEXCEPT
1134 {
return _M_current[__n]; }
1136 _GLIBCXX20_CONSTEXPR
1138 operator+=(difference_type __n) _GLIBCXX_NOEXCEPT
1139 { _M_current += __n;
return *
this; }
1141 _GLIBCXX20_CONSTEXPR
1143 operator+(difference_type __n)
const _GLIBCXX_NOEXCEPT
1144 {
return __normal_iterator(_M_current + __n); }
1146 _GLIBCXX20_CONSTEXPR
1148 operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
1149 { _M_current -= __n;
return *
this; }
1151 _GLIBCXX20_CONSTEXPR
1153 operator-(difference_type __n)
const _GLIBCXX_NOEXCEPT
1154 {
return __normal_iterator(_M_current - __n); }
1156 _GLIBCXX20_CONSTEXPR
1158 base() const _GLIBCXX_NOEXCEPT
1159 {
return _M_current; }
1170 #if __cpp_lib_three_way_comparison
1171 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1174 operator==(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1175 const __normal_iterator<_IteratorR, _Container>& __rhs)
1176 noexcept(noexcept(__lhs.base() == __rhs.base()))
1178 { __lhs.base() == __rhs.base() } -> std::convertible_to<bool>;
1180 {
return __lhs.base() == __rhs.base(); }
1182 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1184 constexpr std::__detail::__synth3way_t<_IteratorR, _IteratorL>
1185 operator<=>(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1186 const __normal_iterator<_IteratorR, _Container>& __rhs)
1187 noexcept(noexcept(std::__detail::__synth3way(__lhs.base(), __rhs.base())))
1188 {
return std::__detail::__synth3way(__lhs.base(), __rhs.base()); }
1190 template<
typename _Iterator,
typename _Container>
1193 operator==(
const __normal_iterator<_Iterator, _Container>& __lhs,
1194 const __normal_iterator<_Iterator, _Container>& __rhs)
1195 noexcept(noexcept(__lhs.base() == __rhs.base()))
1197 { __lhs.base() == __rhs.base() } -> std::convertible_to<bool>;
1199 {
return __lhs.base() == __rhs.base(); }
1201 template<
typename _Iterator,
typename _Container>
1203 constexpr std::__detail::__synth3way_t<_Iterator>
1204 operator<=>(
const __normal_iterator<_Iterator, _Container>& __lhs,
1205 const __normal_iterator<_Iterator, _Container>& __rhs)
1206 noexcept(noexcept(std::__detail::__synth3way(__lhs.base(), __rhs.base())))
1207 {
return std::__detail::__synth3way(__lhs.base(), __rhs.base()); }
1210 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1211 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1213 operator==(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1214 const __normal_iterator<_IteratorR, _Container>& __rhs)
1216 {
return __lhs.base() == __rhs.base(); }
1218 template<
typename _Iterator,
typename _Container>
1219 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1221 operator==(
const __normal_iterator<_Iterator, _Container>& __lhs,
1222 const __normal_iterator<_Iterator, _Container>& __rhs)
1224 {
return __lhs.base() == __rhs.base(); }
1226 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1227 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1229 operator!=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1230 const __normal_iterator<_IteratorR, _Container>& __rhs)
1232 {
return __lhs.base() != __rhs.base(); }
1234 template<
typename _Iterator,
typename _Container>
1235 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1237 operator!=(
const __normal_iterator<_Iterator, _Container>& __lhs,
1238 const __normal_iterator<_Iterator, _Container>& __rhs)
1240 {
return __lhs.base() != __rhs.base(); }
1243 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1246 operator<(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1247 const __normal_iterator<_IteratorR, _Container>& __rhs)
1249 {
return __lhs.base() < __rhs.base(); }
1251 template<
typename _Iterator,
typename _Container>
1252 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1254 operator<(
const __normal_iterator<_Iterator, _Container>& __lhs,
1255 const __normal_iterator<_Iterator, _Container>& __rhs)
1257 {
return __lhs.base() < __rhs.base(); }
1259 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1262 operator>(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1263 const __normal_iterator<_IteratorR, _Container>& __rhs)
1265 {
return __lhs.base() > __rhs.base(); }
1267 template<
typename _Iterator,
typename _Container>
1268 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1270 operator>(
const __normal_iterator<_Iterator, _Container>& __lhs,
1271 const __normal_iterator<_Iterator, _Container>& __rhs)
1273 {
return __lhs.base() > __rhs.base(); }
1275 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1278 operator<=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1279 const __normal_iterator<_IteratorR, _Container>& __rhs)
1281 {
return __lhs.base() <= __rhs.base(); }
1283 template<
typename _Iterator,
typename _Container>
1284 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1286 operator<=(
const __normal_iterator<_Iterator, _Container>& __lhs,
1287 const __normal_iterator<_Iterator, _Container>& __rhs)
1289 {
return __lhs.base() <= __rhs.base(); }
1291 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1294 operator>=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1295 const __normal_iterator<_IteratorR, _Container>& __rhs)
1297 {
return __lhs.base() >= __rhs.base(); }
1299 template<
typename _Iterator,
typename _Container>
1300 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1302 operator>=(
const __normal_iterator<_Iterator, _Container>& __lhs,
1303 const __normal_iterator<_Iterator, _Container>& __rhs)
1305 {
return __lhs.base() >= __rhs.base(); }
1312 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1313 #if __cplusplus >= 201103L
1315 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1317 operator-(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1318 const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept
1319 -> decltype(__lhs.base() - __rhs.base())
1321 inline typename __normal_iterator<_IteratorL, _Container>::difference_type
1322 operator-(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1323 const __normal_iterator<_IteratorR, _Container>& __rhs)
1325 {
return __lhs.base() - __rhs.base(); }
1327 template<
typename _Iterator,
typename _Container>
1328 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1329 inline typename __normal_iterator<_Iterator, _Container>::difference_type
1330 operator-(
const __normal_iterator<_Iterator, _Container>& __lhs,
1331 const __normal_iterator<_Iterator, _Container>& __rhs)
1333 {
return __lhs.base() - __rhs.base(); }
1335 template<
typename _Iterator,
typename _Container>
1336 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1337 inline __normal_iterator<_Iterator, _Container>
1338 operator+(
typename __normal_iterator<_Iterator, _Container>::difference_type
1339 __n,
const __normal_iterator<_Iterator, _Container>& __i)
1341 {
return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
1343 _GLIBCXX_END_NAMESPACE_VERSION
1346 namespace std _GLIBCXX_VISIBILITY(default)
1348 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1350 template<
typename _Iterator,
typename _Container>
1351 _GLIBCXX20_CONSTEXPR
1353 __niter_base(__gnu_cxx::__normal_iterator<_Iterator, _Container> __it)
1355 {
return __it.base(); }
1357 #if __cplusplus >= 201103L
1359 #if __cplusplus <= 201703L
1362 template<
typename _Iterator,
typename _Container>
1364 __to_address(
const __gnu_cxx::__normal_iterator<_Iterator,
1365 _Container>& __it) noexcept
1366 -> decltype(std::__to_address(__it.base()))
1367 {
return std::__to_address(__it.base()); }
1375 #if __cplusplus > 201703L && __cpp_lib_concepts
1376 template<semiregular _Sent>
1382 noexcept(is_nothrow_default_constructible_v<_Sent>)
1386 move_sentinel(_Sent __s)
1387 noexcept(is_nothrow_move_constructible_v<_Sent>)
1390 template<
typename _S2> requires convertible_to<const _S2&, _Sent>
1392 move_sentinel(
const move_sentinel<_S2>& __s)
1393 noexcept(is_nothrow_constructible_v<_Sent, const _S2&>)
1394 : _M_last(__s.base())
1397 template<
typename _S2> requires assignable_from<_Sent&, const _S2&>
1398 constexpr move_sentinel&
1399 operator=(
const move_sentinel<_S2>& __s)
1400 noexcept(is_nothrow_assignable_v<_Sent, const _S2&>)
1402 _M_last = __s.base();
1409 noexcept(is_nothrow_copy_constructible_v<_Sent>)
1419 #if __cplusplus > 201703L && __cpp_lib_concepts
1420 template<
typename _Iterator>
1421 struct __move_iter_cat
1424 template<
typename _Iterator>
1425 requires requires {
typename iterator_traits<_Iterator>::iterator_category; }
1426 struct __move_iter_cat<_Iterator>
1428 using iterator_category
1429 = __clamp_iter_cat<typename iterator_traits<_Iterator>::iterator_category,
1430 random_access_iterator_tag>;
1444 template<
typename _Iterator>
1446 #if __cplusplus > 201703L && __cpp_lib_concepts
1447 :
public __detail::__move_iter_cat<_Iterator>
1450 _Iterator _M_current;
1453 #if ! (__cplusplus > 201703L && __cpp_lib_concepts)
1454 using __base_ref =
typename __traits_type::reference;
1457 template<
typename _Iter2>
1460 #if __cpp_lib_concepts
1463 template<
typename _Iter2>
1464 static constexpr
bool __convertible = !is_same_v<_Iter2, _Iterator>
1465 && convertible_to<const _Iter2&, _Iterator>;
1469 using iterator_type = _Iterator;
1471 #if __cplusplus > 201703L && __cpp_lib_concepts
1474 using value_type = iter_value_t<_Iterator>;
1475 using difference_type = iter_difference_t<_Iterator>;
1476 using pointer = _Iterator;
1477 using reference = iter_rvalue_reference_t<_Iterator>;
1479 typedef typename __traits_type::iterator_category iterator_category;
1480 typedef typename __traits_type::value_type value_type;
1481 typedef typename __traits_type::difference_type difference_type;
1483 typedef _Iterator pointer;
1487 = __conditional_t<is_reference<__base_ref>::value,
1488 typename remove_reference<__base_ref>::type&&,
1492 _GLIBCXX17_CONSTEXPR
1496 explicit _GLIBCXX17_CONSTEXPR
1500 template<
typename _Iter>
1501 #if __cpp_lib_concepts
1504 _GLIBCXX17_CONSTEXPR
1506 : _M_current(__i._M_current) { }
1508 template<
typename _Iter>
1509 #if __cpp_lib_concepts
1511 && assignable_from<_Iterator&, const _Iter&>
1513 _GLIBCXX17_CONSTEXPR
1516 _M_current = __i._M_current;
1520 #if __cplusplus <= 201703L
1522 _GLIBCXX17_CONSTEXPR iterator_type
1524 {
return _M_current; }
1527 constexpr
const iterator_type&
1528 base()
const & noexcept
1529 {
return _M_current; }
1532 constexpr iterator_type
1538 _GLIBCXX17_CONSTEXPR reference
1540 #if __cplusplus > 201703L && __cpp_lib_concepts
1541 {
return ranges::iter_move(_M_current); }
1543 {
return static_cast<reference
>(*_M_current); }
1547 _GLIBCXX17_CONSTEXPR pointer
1549 {
return _M_current; }
1566 #if __cpp_lib_concepts
1568 operator++(
int)
requires (!forward_iterator<_Iterator>)
1593 operator+=(difference_type __n)
1605 operator-=(difference_type __n)
1612 _GLIBCXX17_CONSTEXPR reference
1613 operator[](difference_type __n)
const
1614 #if __cplusplus > 201703L && __cpp_lib_concepts
1615 {
return ranges::iter_move(_M_current + __n); }
1620 #if __cplusplus > 201703L && __cpp_lib_concepts
1621 template<sentinel_for<_Iterator> _Sent>
1623 friend constexpr
bool
1624 operator==(
const move_iterator& __x,
const move_sentinel<_Sent>& __y)
1625 {
return __x.base() == __y.base(); }
1627 template<sized_sentinel_for<_Iterator> _Sent>
1629 friend constexpr iter_difference_t<_Iterator>
1631 {
return __x.base() - __y.base(); }
1633 template<sized_sentinel_for<_Iterator> _Sent>
1635 friend constexpr iter_difference_t<_Iterator>
1637 {
return __x.base() - __y.base(); }
1640 friend constexpr iter_rvalue_reference_t<_Iterator>
1642 noexcept(noexcept(ranges::iter_move(__i._M_current)))
1643 {
return ranges::iter_move(__i._M_current); }
1645 template<indirectly_swappable<_Iterator> _Iter2>
1646 friend constexpr
void
1648 noexcept(noexcept(ranges::iter_swap(__x._M_current, __y._M_current)))
1649 {
return ranges::iter_swap(__x._M_current, __y._M_current); }
1653 template<
typename _IteratorL,
typename _IteratorR>
1655 inline _GLIBCXX17_CONSTEXPR
bool
1658 #if __cplusplus > 201703L && __cpp_lib_concepts
1659 requires requires { { __x.base() == __y.base() } -> convertible_to<bool>; }
1661 {
return __x.base() == __y.base(); }
1663 #if __cpp_lib_three_way_comparison
1664 template<
typename _IteratorL,
1665 three_way_comparable_with<_IteratorL> _IteratorR>
1667 constexpr compare_three_way_result_t<_IteratorL, _IteratorR>
1668 operator<=>(
const move_iterator<_IteratorL>& __x,
1669 const move_iterator<_IteratorR>& __y)
1670 {
return __x.base() <=> __y.base(); }
1672 template<
typename _IteratorL,
typename _IteratorR>
1674 inline _GLIBCXX17_CONSTEXPR
bool
1675 operator!=(
const move_iterator<_IteratorL>& __x,
1676 const move_iterator<_IteratorR>& __y)
1677 {
return !(__x == __y); }
1680 template<
typename _IteratorL,
typename _IteratorR>
1682 inline _GLIBCXX17_CONSTEXPR
bool
1683 operator<(
const move_iterator<_IteratorL>& __x,
1684 const move_iterator<_IteratorR>& __y)
1685 #if __cplusplus > 201703L && __cpp_lib_concepts
1688 {
return __x.base() < __y.base(); }
1690 template<
typename _IteratorL,
typename _IteratorR>
1692 inline _GLIBCXX17_CONSTEXPR
bool
1693 operator<=(
const move_iterator<_IteratorL>& __x,
1694 const move_iterator<_IteratorR>& __y)
1695 #if __cplusplus > 201703L && __cpp_lib_concepts
1698 {
return !(__y < __x); }
1700 template<
typename _IteratorL,
typename _IteratorR>
1702 inline _GLIBCXX17_CONSTEXPR
bool
1703 operator>(
const move_iterator<_IteratorL>& __x,
1704 const move_iterator<_IteratorR>& __y)
1705 #if __cplusplus > 201703L && __cpp_lib_concepts
1708 {
return __y < __x; }
1710 template<
typename _IteratorL,
typename _IteratorR>
1712 inline _GLIBCXX17_CONSTEXPR
bool
1713 operator>=(
const move_iterator<_IteratorL>& __x,
1714 const move_iterator<_IteratorR>& __y)
1715 #if __cplusplus > 201703L && __cpp_lib_concepts
1718 {
return !(__x < __y); }
1723 template<
typename _Iterator>
1725 inline _GLIBCXX17_CONSTEXPR
bool
1726 operator==(
const move_iterator<_Iterator>& __x,
1727 const move_iterator<_Iterator>& __y)
1728 {
return __x.base() == __y.base(); }
1730 #if __cpp_lib_three_way_comparison
1731 template<three_way_comparable _Iterator>
1733 constexpr compare_three_way_result_t<_Iterator>
1734 operator<=>(
const move_iterator<_Iterator>& __x,
1735 const move_iterator<_Iterator>& __y)
1736 {
return __x.base() <=> __y.base(); }
1738 template<
typename _Iterator>
1740 inline _GLIBCXX17_CONSTEXPR
bool
1741 operator!=(
const move_iterator<_Iterator>& __x,
1742 const move_iterator<_Iterator>& __y)
1743 {
return !(__x == __y); }
1745 template<
typename _Iterator>
1747 inline _GLIBCXX17_CONSTEXPR
bool
1748 operator<(
const move_iterator<_Iterator>& __x,
1749 const move_iterator<_Iterator>& __y)
1750 {
return __x.base() < __y.base(); }
1752 template<
typename _Iterator>
1754 inline _GLIBCXX17_CONSTEXPR
bool
1755 operator<=(
const move_iterator<_Iterator>& __x,
1756 const move_iterator<_Iterator>& __y)
1757 {
return !(__y < __x); }
1759 template<
typename _Iterator>
1761 inline _GLIBCXX17_CONSTEXPR
bool
1762 operator>(
const move_iterator<_Iterator>& __x,
1763 const move_iterator<_Iterator>& __y)
1764 {
return __y < __x; }
1766 template<
typename _Iterator>
1768 inline _GLIBCXX17_CONSTEXPR
bool
1769 operator>=(
const move_iterator<_Iterator>& __x,
1770 const move_iterator<_Iterator>& __y)
1771 {
return !(__x < __y); }
1775 template<
typename _IteratorL,
typename _IteratorR>
1777 inline _GLIBCXX17_CONSTEXPR
auto
1778 operator-(
const move_iterator<_IteratorL>& __x,
1779 const move_iterator<_IteratorR>& __y)
1780 -> decltype(__x.base() - __y.base())
1781 {
return __x.base() - __y.base(); }
1783 template<
typename _Iterator>
1785 inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator>
1786 operator+(
typename move_iterator<_Iterator>::difference_type __n,
1787 const move_iterator<_Iterator>& __x)
1788 {
return __x + __n; }
1790 template<
typename _Iterator>
1792 inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator>
1793 make_move_iterator(_Iterator __i)
1794 {
return move_iterator<_Iterator>(
std::move(__i)); }
1796 template<
typename _Iterator,
typename _ReturnType
1797 = __conditional_t<__move_if_noexcept_cond
1798 <
typename iterator_traits<_Iterator>::value_type>::value,
1799 _Iterator, move_iterator<_Iterator>>>
1800 inline _GLIBCXX17_CONSTEXPR _ReturnType
1801 __make_move_if_noexcept_iterator(_Iterator __i)
1802 {
return _ReturnType(__i); }
1806 template<
typename _Tp,
typename _ReturnType
1807 = __conditional_t<__move_if_noexcept_cond<_Tp>::value,
1808 const _Tp*, move_iterator<_Tp*>>>
1809 inline _GLIBCXX17_CONSTEXPR _ReturnType
1810 __make_move_if_noexcept_iterator(_Tp* __i)
1811 {
return _ReturnType(__i); }
1813 #if __cplusplus > 201703L && __cpp_lib_concepts
1818 template<
typename _It>
1819 concept __common_iter_has_arrow = indirectly_readable<const _It>
1820 && (requires(
const _It& __it) { __it.operator->(); }
1821 || is_reference_v<iter_reference_t<_It>>
1822 || constructible_from<iter_value_t<_It>, iter_reference_t<_It>>);
1824 template<
typename _It>
1825 concept __common_iter_use_postfix_proxy
1826 = (!requires (_It& __i) { { *__i++ } -> __can_reference; })
1832 template<input_or_output_iterator _It, sentinel_for<_It> _Sent>
1833 requires (!same_as<_It, _Sent>) && copyable<_It>
1834 class common_iterator
1836 template<
typename _Tp,
typename _Up>
1837 static constexpr
bool
1840 if constexpr (is_trivially_default_constructible_v<_Tp>)
1841 return is_nothrow_assignable_v<_Tp&, _Up>;
1843 return is_nothrow_constructible_v<_Tp, _Up>;
1846 template<
typename _It2,
typename _Sent2>
1847 static constexpr
bool
1849 {
return _S_noexcept1<_It, _It2>() && _S_noexcept1<_Sent, _Sent2>(); }
1853 iter_value_t<_It> _M_keep;
1856 __arrow_proxy(iter_reference_t<_It>&& __x)
1859 friend class common_iterator;
1862 constexpr
const iter_value_t<_It>*
1863 operator->()
const noexcept
1867 class __postfix_proxy
1869 iter_value_t<_It> _M_keep;
1872 __postfix_proxy(iter_reference_t<_It>&& __x)
1873 : _M_keep(
std::forward<iter_reference_t<_It>>(__x)) { }
1875 friend class common_iterator;
1878 constexpr
const iter_value_t<_It>&
1886 noexcept(is_nothrow_default_constructible_v<_It>)
1887 requires default_initializable<_It>
1888 : _M_it(), _M_index(0)
1892 common_iterator(_It __i)
1893 noexcept(is_nothrow_move_constructible_v<_It>)
1898 common_iterator(_Sent __s)
1899 noexcept(is_nothrow_move_constructible_v<_Sent>)
1903 template<
typename _It2,
typename _Sent2>
1904 requires convertible_to<const _It2&, _It>
1905 && convertible_to<const _Sent2&, _Sent>
1907 common_iterator(
const common_iterator<_It2, _Sent2>& __x)
1908 noexcept(_S_noexcept<const _It2&, const _Sent2&>())
1909 : _M_valueless(), _M_index(__x._M_index)
1911 __glibcxx_assert(__x._M_has_value());
1914 if constexpr (is_trivially_default_constructible_v<_It>)
1919 else if (_M_index == 1)
1921 if constexpr (is_trivially_default_constructible_v<_Sent>)
1929 common_iterator(
const common_iterator& __x)
1930 noexcept(_S_noexcept<const _It&, const _Sent&>())
1931 : _M_valueless(), _M_index(__x._M_index)
1935 if constexpr (is_trivially_default_constructible_v<_It>)
1940 else if (_M_index == 1)
1942 if constexpr (is_trivially_default_constructible_v<_Sent>)
1943 _M_sent = __x._M_sent;
1950 common_iterator(common_iterator&& __x)
1951 noexcept(_S_noexcept<_It, _Sent>())
1952 : _M_valueless(), _M_index(__x._M_index)
1956 if constexpr (is_trivially_default_constructible_v<_It>)
1961 else if (_M_index == 1)
1963 if constexpr (is_trivially_default_constructible_v<_Sent>)
1971 constexpr common_iterator&
1972 operator=(
const common_iterator&) =
default;
1974 constexpr common_iterator&
1975 operator=(
const common_iterator& __x)
1976 noexcept(is_nothrow_copy_assignable_v<_It>
1977 && is_nothrow_copy_assignable_v<_Sent>
1978 && is_nothrow_copy_constructible_v<_It>
1979 && is_nothrow_copy_constructible_v<_Sent>)
1980 requires (!is_trivially_copy_assignable_v<_It>
1981 || !is_trivially_copy_assignable_v<_Sent>)
1987 constexpr common_iterator&
1988 operator=(common_iterator&&) =
default;
1990 constexpr common_iterator&
1991 operator=(common_iterator&& __x)
1992 noexcept(is_nothrow_move_assignable_v<_It>
1993 && is_nothrow_move_assignable_v<_Sent>
1994 && is_nothrow_move_constructible_v<_It>
1995 && is_nothrow_move_constructible_v<_Sent>)
1996 requires (!is_trivially_move_assignable_v<_It>
1997 || !is_trivially_move_assignable_v<_Sent>)
2003 template<
typename _It2,
typename _Sent2>
2004 requires convertible_to<const _It2&, _It>
2005 && convertible_to<const _Sent2&, _Sent>
2006 && assignable_from<_It&, const _It2&>
2007 && assignable_from<_Sent&, const _Sent2&>
2008 constexpr common_iterator&
2009 operator=(
const common_iterator<_It2, _Sent2>& __x)
2010 noexcept(is_nothrow_constructible_v<_It, const _It2&>
2011 && is_nothrow_constructible_v<_Sent, const _Sent2&>
2012 && is_nothrow_assignable_v<_It&, const _It2&>
2013 && is_nothrow_assignable_v<_Sent&, const _Sent2&>)
2015 __glibcxx_assert(__x._M_has_value());
2025 else if (_M_index == 1)
2030 constexpr decltype(
auto)
2033 __glibcxx_assert(_M_index == 0);
2038 constexpr decltype(
auto)
2041 __glibcxx_assert(_M_index == 0);
2047 operator->()
const requires __detail::__common_iter_has_arrow<_It>
2049 __glibcxx_assert(_M_index == 0);
2050 if constexpr (is_pointer_v<_It> ||
requires { _M_it.operator->(); })
2052 else if constexpr (is_reference_v<iter_reference_t<_It>>)
2054 auto&& __tmp = *_M_it;
2058 return __arrow_proxy{*_M_it};
2061 constexpr common_iterator&
2064 __glibcxx_assert(_M_index == 0);
2069 constexpr decltype(
auto)
2072 __glibcxx_assert(_M_index == 0);
2073 if constexpr (forward_iterator<_It>)
2075 common_iterator __tmp = *
this;
2079 else if constexpr (!__detail::__common_iter_use_postfix_proxy<_It>)
2083 __postfix_proxy __p(**
this);
2089 template<
typename _It2, sentinel_for<_It> _Sent2>
2091 friend constexpr
bool
2092 operator== [[nodiscard]] (
const common_iterator& __x,
2093 const common_iterator<_It2, _Sent2>& __y)
2095 switch(__x._M_index << 2 | __y._M_index)
2101 return __x._M_it == __y._M_sent;
2103 return __x._M_sent == __y._M_it;
2105 __glibcxx_assert(__x._M_has_value());
2106 __glibcxx_assert(__y._M_has_value());
2107 __builtin_unreachable();
2111 template<
typename _It2, sentinel_for<_It> _Sent2>
2112 requires sentinel_for<_Sent, _It2> && equality_comparable_with<_It, _It2>
2113 friend constexpr
bool
2114 operator== [[nodiscard]] (
const common_iterator& __x,
2115 const common_iterator<_It2, _Sent2>& __y)
2117 switch(__x._M_index << 2 | __y._M_index)
2122 return __x._M_it == __y._M_it;
2124 return __x._M_it == __y._M_sent;
2126 return __x._M_sent == __y._M_it;
2128 __glibcxx_assert(__x._M_has_value());
2129 __glibcxx_assert(__y._M_has_value());
2130 __builtin_unreachable();
2134 template<sized_sentinel_for<_It> _It2, sized_sentinel_for<_It> _Sent2>
2135 requires sized_sentinel_for<_Sent, _It2>
2136 friend constexpr iter_difference_t<_It2>
2137 operator- [[nodiscard]] (
const common_iterator& __x,
2138 const common_iterator<_It2, _Sent2>& __y)
2140 switch(__x._M_index << 2 | __y._M_index)
2145 return __x._M_it - __y._M_it;
2147 return __x._M_it - __y._M_sent;
2149 return __x._M_sent - __y._M_it;
2151 __glibcxx_assert(__x._M_has_value());
2152 __glibcxx_assert(__y._M_has_value());
2153 __builtin_unreachable();
2158 friend constexpr iter_rvalue_reference_t<_It>
2159 iter_move(
const common_iterator& __i)
2160 noexcept(noexcept(ranges::iter_move(std::declval<const _It&>())))
2163 __glibcxx_assert(__i._M_index == 0);
2164 return ranges::iter_move(__i._M_it);
2167 template<indirectly_swappable<_It> _It2,
typename _Sent2>
2168 friend constexpr
void
2169 iter_swap(
const common_iterator& __x,
2170 const common_iterator<_It2, _Sent2>& __y)
2171 noexcept(noexcept(ranges::iter_swap(std::declval<const _It&>(),
2172 std::declval<const _It2&>())))
2174 __glibcxx_assert(__x._M_index == 0);
2175 __glibcxx_assert(__y._M_index == 0);
2176 return ranges::iter_swap(__x._M_it, __y._M_it);
2180 template<input_or_output_iterator _It2, sentinel_for<_It2> _Sent2>
2181 requires (!same_as<_It2, _Sent2>) && copyable<_It2>
2182 friend class common_iterator;
2185 _M_has_value()
const noexcept {
return _M_index != _S_valueless; }
2187 template<
typename _CIt>
2189 _M_assign(_CIt&& __x)
2191 if (_M_index == __x._M_index)
2194 _M_it = std::forward<_CIt>(__x)._M_it;
2195 else if (_M_index == 1)
2196 _M_sent = std::forward<_CIt>(__x)._M_sent;
2202 else if (_M_index == 1)
2204 _M_index = _S_valueless;
2206 if (__x._M_index == 0)
2208 std::forward<_CIt>(__x)._M_it);
2209 else if (__x._M_index == 1)
2211 std::forward<_CIt>(__x)._M_sent);
2212 _M_index = __x._M_index;
2220 unsigned char _M_valueless;
2222 unsigned char _M_index;
2224 static constexpr
unsigned char _S_valueless{2};
2227 template<
typename _It,
typename _Sent>
2228 struct incrementable_traits<common_iterator<_It, _Sent>>
2230 using difference_type = iter_difference_t<_It>;
2233 template<input_iterator _It,
typename _Sent>
2234 struct iterator_traits<common_iterator<_It, _Sent>>
2237 template<
typename _Iter>
2243 template<
typename _Iter>
2244 requires __detail::__common_iter_has_arrow<_Iter>
2247 using _CIter = common_iterator<_Iter, _Sent>;
2248 using type = decltype(std::declval<const _CIter&>().operator->());
2254 using _Traits = iterator_traits<_It>;
2255 if constexpr (requires { requires
derived_from<
typename _Traits::iterator_category,
2256 forward_iterator_tag>; })
2257 return forward_iterator_tag{};
2259 return input_iterator_tag{};
2263 using iterator_concept = __conditional_t<forward_iterator<_It>,
2264 forward_iterator_tag,
2265 input_iterator_tag>;
2266 using iterator_category = decltype(_S_iter_cat());
2267 using value_type = iter_value_t<_It>;
2268 using difference_type = iter_difference_t<_It>;
2269 using pointer =
typename __ptr<_It>::type;
2270 using reference = iter_reference_t<_It>;
2277 template<
typename _It>
2278 struct __counted_iter_value_type
2281 template<indirectly_readable _It>
2282 struct __counted_iter_value_type<_It>
2283 {
using value_type = iter_value_t<_It>; };
2285 template<
typename _It>
2286 struct __counted_iter_concept
2289 template<
typename _It>
2290 requires requires {
typename _It::iterator_concept; }
2291 struct __counted_iter_concept<_It>
2292 {
using iterator_concept =
typename _It::iterator_concept; };
2294 template<
typename _It>
2295 struct __counted_iter_cat
2298 template<
typename _It>
2299 requires requires {
typename _It::iterator_category; }
2300 struct __counted_iter_cat<_It>
2301 {
using iterator_category =
typename _It::iterator_category; };
2305 template<input_or_output_iterator _It>
2307 :
public __detail::__counted_iter_value_type<_It>,
2308 public __detail::__counted_iter_concept<_It>,
2309 public __detail::__counted_iter_cat<_It>
2312 using iterator_type = _It;
2314 using difference_type = iter_difference_t<_It>;
2318 constexpr
counted_iterator() requires default_initializable<_It> =
default;
2322 : _M_current(
std::move(__i)), _M_length(__n)
2323 { __glibcxx_assert(__n >= 0); }
2325 template<
typename _It2>
2326 requires convertible_to<const _It2&, _It>
2329 : _M_current(__x._M_current), _M_length(__x._M_length)
2332 template<
typename _It2>
2333 requires assignable_from<_It&, const _It2&>
2337 _M_current = __x._M_current;
2338 _M_length = __x._M_length;
2343 constexpr
const _It&
2344 base()
const & noexcept
2345 {
return _M_current; }
2350 noexcept(is_nothrow_move_constructible_v<_It>)
2354 constexpr iter_difference_t<_It>
2355 count()
const noexcept {
return _M_length; }
2358 constexpr decltype(
auto)
2360 noexcept(noexcept(*_M_current))
2362 __glibcxx_assert( _M_length > 0 );
2367 constexpr decltype(
auto)
2369 noexcept(noexcept(*_M_current))
2370 requires __detail::__dereferenceable<const _It>
2372 __glibcxx_assert( _M_length > 0 );
2378 operator->()
const noexcept
2379 requires contiguous_iterator<_It>
2385 __glibcxx_assert(_M_length > 0);
2391 constexpr decltype(
auto)
2394 __glibcxx_assert(_M_length > 0);
2398 return _M_current++;
2401 __throw_exception_again;
2406 operator++(
int) requires forward_iterator<_It>
2414 operator--() requires bidirectional_iterator<_It>
2422 operator--(
int) requires bidirectional_iterator<_It>
2431 operator+(iter_difference_t<_It> __n)
const
2432 requires random_access_iterator<_It>
2438 requires random_access_iterator<_It>
2439 {
return __x + __n; }
2442 operator+=(iter_difference_t<_It> __n)
2443 requires random_access_iterator<_It>
2445 __glibcxx_assert(__n <= _M_length);
2453 operator-(iter_difference_t<_It> __n)
const
2454 requires random_access_iterator<_It>
2457 template<common_with<_It> _It2>
2459 friend constexpr iter_difference_t<_It2>
2462 {
return __y._M_length - __x._M_length; }
2465 friend constexpr iter_difference_t<_It>
2467 {
return -__x._M_length; }
2470 friend constexpr iter_difference_t<_It>
2472 {
return __y._M_length; }
2475 operator-=(iter_difference_t<_It> __n)
2476 requires random_access_iterator<_It>
2478 __glibcxx_assert(-__n <= _M_length);
2485 constexpr decltype(
auto)
2486 operator[](iter_difference_t<_It> __n)
const
2487 noexcept(noexcept(_M_current[__n]))
2488 requires random_access_iterator<_It>
2490 __glibcxx_assert(__n < _M_length);
2491 return _M_current[__n];
2494 template<common_with<_It> _It2>
2496 friend constexpr
bool
2499 {
return __x._M_length == __y._M_length; }
2502 friend constexpr
bool
2504 {
return __x._M_length == 0; }
2506 template<common_with<_It> _It2>
2508 friend constexpr strong_ordering
2511 {
return __y._M_length <=> __x._M_length; }
2514 friend constexpr iter_rvalue_reference_t<_It>
2516 noexcept(noexcept(ranges::iter_move(__i._M_current)))
2517 requires input_iterator<_It>
2519 __glibcxx_assert( __i._M_length > 0 );
2520 return ranges::iter_move(__i._M_current);
2523 template<indirectly_swappable<_It> _It2>
2524 friend constexpr
void
2527 noexcept(noexcept(ranges::iter_swap(__x._M_current, __y._M_current)))
2529 __glibcxx_assert( __x._M_length > 0 && __y._M_length > 0 );
2530 ranges::iter_swap(__x._M_current, __y._M_current);
2536 _It _M_current = _It();
2537 iter_difference_t<_It> _M_length = 0;
2540 template<input_iterator _It>
2544 using pointer = __conditional_t<contiguous_iterator<_It>,
2552 template<
typename _Iterator>
2553 _GLIBCXX20_CONSTEXPR
2555 __niter_base(move_iterator<_Iterator> __it)
2556 -> decltype(make_move_iterator(__niter_base(__it.base())))
2557 {
return make_move_iterator(__niter_base(__it.base())); }
2559 template<
typename _Iterator>
2560 struct __is_move_iterator<move_iterator<_Iterator> >
2562 enum { __value = 1 };
2563 typedef __true_type __type;
2566 template<
typename _Iterator>
2567 _GLIBCXX20_CONSTEXPR
2569 __miter_base(move_iterator<_Iterator> __it)
2570 -> decltype(__miter_base(__it.base()))
2571 {
return __miter_base(__it.base()); }
2573 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter)
2574 #define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) \
2575 std::__make_move_if_noexcept_iterator(_Iter)
2577 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter)
2578 #define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter)
2581 #if __cpp_deduction_guides >= 201606
2584 template<
typename _InputIterator>
2586 typename iterator_traits<_InputIterator>::value_type::first_type>;
2588 template<
typename _InputIterator>
2589 using __iter_val_t =
2590 typename iterator_traits<_InputIterator>::value_type::second_type;
2592 template<
typename _T1,
typename _T2>
2595 template<
typename _InputIterator>
2596 using __iter_to_alloc_t =
2597 pair<add_const_t<__iter_key_t<_InputIterator>>,
2598 __iter_val_t<_InputIterator>>;
2601 _GLIBCXX_END_NAMESPACE_VERSION
2604 #ifdef _GLIBCXX_DEBUG
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.
typename remove_const< _Tp >::type remove_const_t
Alias template for remove_const.
typename add_pointer< _Tp >::type add_pointer_t
Alias template for add_pointer.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
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.
requires(!same_as< _It, _Sent >) &©able< _It > class common_iterator
An iterator/sentinel adaptor for representing a non-common range.
constexpr front_insert_iterator< _Container > front_inserter(_Container &__x)
constexpr insert_iterator< _Container > inserter(_Container &__x, std::__detail::__range_iter_t< _Container > __i)
constexpr back_insert_iterator< _Container > back_inserter(_Container &__x)
ISO C++ entities toplevel namespace is std.
concept derived_from
[concept.derived], concept derived_from
concept move_constructible
[concept.moveconstructible], concept move_constructible
concept constructible_from
[concept.constructible], concept constructible_from
GNU extensions for public use.
is_nothrow_copy_constructible
Traits class for iterators.
requires constexpr __convertible< _Iter > reverse_iterator(const reverse_iterator< _Iter > &__x) noexcept(/*conditional */)
constexpr reverse_iterator operator+(difference_type __n) const
constexpr iterator_type base() const noexcept(/*conditional */)
constexpr pointer operator->() const requires is_pointer_v< _Iterator >||requires(const _Iterator __i)
constexpr reverse_iterator(const reverse_iterator &__x) noexcept(/*conditional */)
constexpr reverse_iterator & operator+=(difference_type __n)
constexpr reference operator[](difference_type __n) const
constexpr reverse_iterator() noexcept(/*conditional */)
constexpr reverse_iterator(iterator_type __x) noexcept(/*conditional */)
constexpr reverse_iterator & operator--()
constexpr reverse_iterator & operator-=(difference_type __n)
constexpr reverse_iterator operator--(int)
constexpr reference operator*() const
constexpr reverse_iterator operator-(difference_type __n) const
constexpr reverse_iterator operator++(int)
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.
constexpr back_insert_iterator & operator=(const typename _Container::value_type &__value)
constexpr back_insert_iterator & operator++()
Simply returns *this. (This iterator does not move.)
constexpr back_insert_iterator(_Container &__x)
The only way to create this iterator is with a container.
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++()
Simply returns *this. (This iterator does not move.)
_Container container_type
A nested typedef for the type of whatever container you used.
constexpr insert_iterator & operator++(int)
Simply returns *this. (This iterator does not move.)
constexpr insert_iterator & operator=(const typename _Container::value_type &__value)
constexpr insert_iterator(_Container &__x, _Iter __i)
constexpr insert_iterator & operator*()
Simply returns *this.
An iterator adaptor that keeps track of the distance to the end.
Bidirectional iterators support a superset of forward iterator operations.
Random-access iterators support a superset of bidirectional iterator operations.