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 > 201703L
86 namespace std _GLIBCXX_VISIBILITY(default)
88 _GLIBCXX_BEGIN_NAMESPACE_VERSION
95 #if __cpp_lib_concepts
100 template<
typename _Cat,
typename _Limit,
typename _Otherwise = _Cat>
101 using __clamp_iter_cat
102 = conditional_t<derived_from<_Cat, _Limit>, _Limit, _Otherwise>;
125 template<
typename _Iterator>
127 :
public iterator<typename iterator_traits<_Iterator>::iterator_category,
128 typename iterator_traits<_Iterator>::value_type,
129 typename iterator_traits<_Iterator>::difference_type,
130 typename iterator_traits<_Iterator>::pointer,
131 typename iterator_traits<_Iterator>::reference>
139 typedef _Iterator iterator_type;
140 typedef typename __traits_type::pointer pointer;
141 #if ! __cpp_lib_concepts
142 typedef typename __traits_type::difference_type difference_type;
143 typedef typename __traits_type::reference reference;
145 using iterator_concept
150 = __detail::__clamp_iter_cat<
typename __traits_type::iterator_category,
153 using difference_type = iter_difference_t<_Iterator>;
154 using reference = iter_reference_t<_Iterator>;
170 explicit _GLIBCXX17_CONSTEXPR
178 : current(__x.current) { }
180 #if __cplusplus >= 201103L
188 template<
typename _Iter>
191 : current(__x.
base()) { }
196 _GLIBCXX17_CONSTEXPR iterator_type
210 _GLIBCXX17_CONSTEXPR reference
213 _Iterator __tmp = current;
222 _GLIBCXX17_CONSTEXPR pointer
224 #if __cplusplus > 201703L && __cpp_concepts >= 201907L
225 requires is_pointer_v<_Iterator>
226 || requires(
const _Iterator __i) { __i.operator->(); }
231 _Iterator __tmp = current;
233 return _S_to_pointer(__tmp);
335 _GLIBCXX17_CONSTEXPR reference
337 {
return *(*
this + __n); }
339 #if __cplusplus > 201703L && __cpp_lib_concepts
340 friend constexpr iter_rvalue_reference_t<_Iterator>
342 noexcept(is_nothrow_copy_constructible_v<_Iterator>
343 && noexcept(ranges::iter_move(--std::declval<_Iterator&>())))
345 auto __tmp = __i.base();
346 return ranges::iter_move(--__tmp);
349 template<indirectly_swappable<_Iterator> _Iter2>
350 friend constexpr
void
352 const reverse_iterator<_Iter2>& __y)
353 noexcept(is_nothrow_copy_constructible_v<_Iterator>
354 && is_nothrow_copy_constructible_v<_Iter2>
355 && noexcept(ranges::iter_swap(--std::declval<_Iterator&>(),
356 --std::declval<_Iter2&>())))
358 auto __xtmp = __x.base();
359 auto __ytmp = __y.base();
360 ranges::iter_swap(--__xtmp, --__ytmp);
365 template<
typename _Tp>
366 static _GLIBCXX17_CONSTEXPR _Tp*
367 _S_to_pointer(_Tp* __p)
370 template<
typename _Tp>
371 static _GLIBCXX17_CONSTEXPR pointer
372 _S_to_pointer(_Tp __t)
373 {
return __t.operator->(); }
386 #if __cplusplus <= 201703L || ! defined __cpp_lib_concepts
387 template<
typename _Iterator>
388 inline _GLIBCXX17_CONSTEXPR
bool
391 {
return __x.
base() == __y.
base(); }
393 template<
typename _Iterator>
394 inline _GLIBCXX17_CONSTEXPR
bool
395 operator<(
const reverse_iterator<_Iterator>& __x,
396 const reverse_iterator<_Iterator>& __y)
397 {
return __y.base() < __x.base(); }
399 template<
typename _Iterator>
400 inline _GLIBCXX17_CONSTEXPR
bool
401 operator!=(
const reverse_iterator<_Iterator>& __x,
402 const reverse_iterator<_Iterator>& __y)
403 {
return !(__x == __y); }
405 template<
typename _Iterator>
406 inline _GLIBCXX17_CONSTEXPR
bool
407 operator>(
const reverse_iterator<_Iterator>& __x,
408 const reverse_iterator<_Iterator>& __y)
409 {
return __y < __x; }
411 template<
typename _Iterator>
412 inline _GLIBCXX17_CONSTEXPR
bool
413 operator<=(
const reverse_iterator<_Iterator>& __x,
414 const reverse_iterator<_Iterator>& __y)
415 {
return !(__y < __x); }
417 template<
typename _Iterator>
418 inline _GLIBCXX17_CONSTEXPR
bool
419 operator>=(
const reverse_iterator<_Iterator>& __x,
420 const reverse_iterator<_Iterator>& __y)
421 {
return !(__x < __y); }
425 template<
typename _IteratorL,
typename _IteratorR>
426 inline _GLIBCXX17_CONSTEXPR
bool
427 operator==(
const reverse_iterator<_IteratorL>& __x,
428 const reverse_iterator<_IteratorR>& __y)
429 {
return __x.base() == __y.base(); }
431 template<
typename _IteratorL,
typename _IteratorR>
432 inline _GLIBCXX17_CONSTEXPR
bool
433 operator<(
const reverse_iterator<_IteratorL>& __x,
434 const reverse_iterator<_IteratorR>& __y)
435 {
return __y.base() < __x.base(); }
437 template<
typename _IteratorL,
typename _IteratorR>
438 inline _GLIBCXX17_CONSTEXPR
bool
439 operator!=(
const reverse_iterator<_IteratorL>& __x,
440 const reverse_iterator<_IteratorR>& __y)
441 {
return !(__x == __y); }
443 template<
typename _IteratorL,
typename _IteratorR>
444 inline _GLIBCXX17_CONSTEXPR
bool
445 operator>(
const reverse_iterator<_IteratorL>& __x,
446 const reverse_iterator<_IteratorR>& __y)
447 {
return __y < __x; }
449 template<
typename _IteratorL,
typename _IteratorR>
450 inline _GLIBCXX17_CONSTEXPR
bool
451 operator<=(
const reverse_iterator<_IteratorL>& __x,
452 const reverse_iterator<_IteratorR>& __y)
453 {
return !(__y < __x); }
455 template<
typename _IteratorL,
typename _IteratorR>
456 inline _GLIBCXX17_CONSTEXPR
bool
457 operator>=(
const reverse_iterator<_IteratorL>& __x,
458 const reverse_iterator<_IteratorR>& __y)
459 {
return !(__x < __y); }
461 template<
typename _IteratorL,
typename _IteratorR>
463 operator==(
const reverse_iterator<_IteratorL>& __x,
464 const reverse_iterator<_IteratorR>& __y)
465 requires requires { { __x.base() == __y.base() } -> convertible_to<bool>; }
466 {
return __x.base() == __y.base(); }
468 template<
typename _IteratorL,
typename _IteratorR>
470 operator!=(
const reverse_iterator<_IteratorL>& __x,
471 const reverse_iterator<_IteratorR>& __y)
472 requires requires { { __x.base() != __y.base() } -> convertible_to<bool>; }
473 {
return __x.base() != __y.base(); }
475 template<
typename _IteratorL,
typename _IteratorR>
477 operator<(
const reverse_iterator<_IteratorL>& __x,
478 const reverse_iterator<_IteratorR>& __y)
479 requires requires { { __x.base() > __y.base() } -> convertible_to<bool>; }
480 {
return __x.base() > __y.base(); }
482 template<
typename _IteratorL,
typename _IteratorR>
484 operator>(
const reverse_iterator<_IteratorL>& __x,
485 const reverse_iterator<_IteratorR>& __y)
486 requires requires { { __x.base() < __y.base() } -> convertible_to<bool>; }
487 {
return __x.base() < __y.base(); }
489 template<
typename _IteratorL,
typename _IteratorR>
491 operator<=(
const reverse_iterator<_IteratorL>& __x,
492 const reverse_iterator<_IteratorR>& __y)
493 requires requires { { __x.base() >= __y.base() } -> convertible_to<bool>; }
494 {
return __x.base() >= __y.base(); }
496 template<
typename _IteratorL,
typename _IteratorR>
498 operator>=(
const reverse_iterator<_IteratorL>& __x,
499 const reverse_iterator<_IteratorR>& __y)
500 requires requires { { __x.base() <= __y.base() } -> convertible_to<bool>; }
501 {
return __x.base() <= __y.base(); }
503 template<
typename _IteratorL,
504 three_way_comparable_with<_IteratorL> _IteratorR>
505 constexpr compare_three_way_result_t<_IteratorL, _IteratorR>
506 operator<=>(
const reverse_iterator<_IteratorL>& __x,
507 const reverse_iterator<_IteratorR>& __y)
508 {
return __y.base() <=> __x.base(); }
513 template<
typename _Iterator>
515 operator==(
const reverse_iterator<_Iterator>& __x,
516 const reverse_iterator<_Iterator>& __y)
517 requires requires { { __x.base() == __y.base() } -> convertible_to<bool>; }
518 {
return __x.base() == __y.base(); }
520 template<three_way_comparable _Iterator>
521 constexpr compare_three_way_result_t<_Iterator, _Iterator>
522 operator<=>(
const reverse_iterator<_Iterator>& __x,
523 const reverse_iterator<_Iterator>& __y)
524 {
return __y.base() <=> __x.base(); }
528 #if __cplusplus < 201103L
529 template<
typename _Iterator>
530 inline typename reverse_iterator<_Iterator>::difference_type
531 operator-(
const reverse_iterator<_Iterator>& __x,
532 const reverse_iterator<_Iterator>& __y)
533 {
return __y.base() - __x.base(); }
535 template<
typename _IteratorL,
typename _IteratorR>
536 inline typename reverse_iterator<_IteratorL>::difference_type
537 operator-(
const reverse_iterator<_IteratorL>& __x,
538 const reverse_iterator<_IteratorR>& __y)
539 {
return __y.base() - __x.base(); }
543 template<
typename _IteratorL,
typename _IteratorR>
544 inline _GLIBCXX17_CONSTEXPR
auto
545 operator-(
const reverse_iterator<_IteratorL>& __x,
546 const reverse_iterator<_IteratorR>& __y)
547 -> decltype(__y.base() - __x.base())
548 {
return __y.base() - __x.base(); }
551 template<
typename _Iterator>
552 inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
553 operator+(
typename reverse_iterator<_Iterator>::difference_type __n,
554 const reverse_iterator<_Iterator>& __x)
555 {
return reverse_iterator<_Iterator>(__x.base() - __n); }
557 #if __cplusplus >= 201103L
559 template<
typename _Iterator>
560 inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
561 __make_reverse_iterator(_Iterator __i)
562 {
return reverse_iterator<_Iterator>(__i); }
564 # if __cplusplus >= 201402L
565 # define __cpp_lib_make_reverse_iterator 201402
570 template<
typename _Iterator>
571 inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator>
575 # if __cplusplus > 201703L && defined __cpp_lib_concepts
576 template<
typename _Iterator1,
typename _Iterator2>
577 requires (!sized_sentinel_for<_Iterator1, _Iterator2>)
578 inline constexpr
bool
579 disable_sized_sentinel_for<reverse_iterator<_Iterator1>,
580 reverse_iterator<_Iterator2>> =
true;
584 template<
typename _Iterator>
587 __niter_base(reverse_iterator<_Iterator> __it)
588 -> decltype(__make_reverse_iterator(__niter_base(__it.base())))
589 {
return __make_reverse_iterator(__niter_base(__it.base())); }
591 template<
typename _Iterator>
592 struct __is_move_iterator<reverse_iterator<_Iterator> >
593 : __is_move_iterator<_Iterator>
596 template<
typename _Iterator>
599 __miter_base(reverse_iterator<_Iterator> __it)
600 -> decltype(__make_reverse_iterator(__miter_base(__it.base())))
601 {
return __make_reverse_iterator(__miter_base(__it.base())); }
615 template<
typename _Container>
617 :
public iterator<output_iterator_tag, void, void, void, void>
620 _Container* container;
625 #if __cplusplus > 201703L
632 explicit _GLIBCXX20_CONSTEXPR
647 #if __cplusplus < 201103L
649 operator=(
typename _Container::const_reference __value)
651 container->push_back(__value);
657 operator=(
const typename _Container::value_type& __value)
659 container->push_back(__value);
665 operator=(
typename _Container::value_type&& __value)
667 container->push_back(
std::move(__value));
702 template<
typename _Container>
704 inline back_insert_iterator<_Container>
718 template<
typename _Container>
720 :
public iterator<output_iterator_tag, void, void, void, void>
723 _Container* container;
728 #if __cplusplus > 201703L
735 explicit _GLIBCXX20_CONSTEXPR
750 #if __cplusplus < 201103L
752 operator=(
typename _Container::const_reference __value)
754 container->push_front(__value);
760 operator=(
const typename _Container::value_type& __value)
762 container->push_front(__value);
768 operator=(
typename _Container::value_type&& __value)
770 container->push_front(
std::move(__value));
805 template<
typename _Container>
807 inline front_insert_iterator<_Container>
825 template<
typename _Container>
827 :
public iterator<output_iterator_tag, void, void, void, void>
829 #if __cplusplus > 201703L && defined __cpp_lib_concepts
830 using _Iter = std::__detail::__range_iter_t<_Container>;
833 _Container* container =
nullptr;
834 _Iter iter = _Iter();
836 typedef typename _Container::iterator _Iter;
839 _Container* container;
847 #if __cplusplus > 201703L && defined __cpp_lib_concepts
884 #if __cplusplus < 201103L
886 operator=(
typename _Container::const_reference __value)
888 iter = container->insert(iter, __value);
895 operator=(
const typename _Container::value_type& __value)
897 iter = container->insert(iter, __value);
904 operator=(
typename _Container::value_type&& __value)
906 iter = container->insert(iter,
std::move(__value));
943 #if __cplusplus > 201703L && defined __cpp_lib_concepts
944 template<
typename _Container>
945 constexpr insert_iterator<_Container>
946 inserter(_Container& __x, std::__detail::__range_iter_t<_Container> __i)
947 {
return insert_iterator<_Container>(__x, __i); }
949 template<
typename _Container>
950 inline insert_iterator<_Container>
951 inserter(_Container& __x,
typename _Container::iterator __i)
957 _GLIBCXX_END_NAMESPACE_VERSION
960 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
962 _GLIBCXX_BEGIN_NAMESPACE_VERSION
971 template<
typename _Iterator,
typename _Container>
972 class __normal_iterator
975 _Iterator _M_current;
980 typedef _Iterator iterator_type;
981 typedef typename __traits_type::iterator_category iterator_category;
982 typedef typename __traits_type::value_type value_type;
983 typedef typename __traits_type::difference_type difference_type;
984 typedef typename __traits_type::reference reference;
985 typedef typename __traits_type::pointer pointer;
987 #if __cplusplus > 201703L && __cpp_lib_concepts
988 using iterator_concept = std::__detail::__iter_concept<_Iterator>;
991 _GLIBCXX_CONSTEXPR __normal_iterator() _GLIBCXX_NOEXCEPT
992 : _M_current(_Iterator()) { }
994 explicit _GLIBCXX20_CONSTEXPR
995 __normal_iterator(
const _Iterator& __i) _GLIBCXX_NOEXCEPT
996 : _M_current(__i) { }
999 template<
typename _Iter>
1000 _GLIBCXX20_CONSTEXPR
1001 __normal_iterator(
const __normal_iterator<_Iter,
1002 typename __enable_if<
1003 (std::__are_same<_Iter, typename _Container::pointer>::__value),
1004 _Container>::__type>& __i) _GLIBCXX_NOEXCEPT
1005 : _M_current(__i.base()) { }
1008 _GLIBCXX20_CONSTEXPR
1011 {
return *_M_current; }
1013 _GLIBCXX20_CONSTEXPR
1015 operator->() const _GLIBCXX_NOEXCEPT
1016 {
return _M_current; }
1018 _GLIBCXX20_CONSTEXPR
1020 operator++() _GLIBCXX_NOEXCEPT
1026 _GLIBCXX20_CONSTEXPR
1028 operator++(
int) _GLIBCXX_NOEXCEPT
1029 {
return __normal_iterator(_M_current++); }
1032 _GLIBCXX20_CONSTEXPR
1034 operator--() _GLIBCXX_NOEXCEPT
1040 _GLIBCXX20_CONSTEXPR
1042 operator--(
int) _GLIBCXX_NOEXCEPT
1043 {
return __normal_iterator(_M_current--); }
1046 _GLIBCXX20_CONSTEXPR
1048 operator[](difference_type __n)
const _GLIBCXX_NOEXCEPT
1049 {
return _M_current[__n]; }
1051 _GLIBCXX20_CONSTEXPR
1053 operator+=(difference_type __n) _GLIBCXX_NOEXCEPT
1054 { _M_current += __n;
return *
this; }
1056 _GLIBCXX20_CONSTEXPR
1058 operator+(difference_type __n)
const _GLIBCXX_NOEXCEPT
1059 {
return __normal_iterator(_M_current + __n); }
1061 _GLIBCXX20_CONSTEXPR
1063 operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
1064 { _M_current -= __n;
return *
this; }
1066 _GLIBCXX20_CONSTEXPR
1068 operator-(difference_type __n)
const _GLIBCXX_NOEXCEPT
1069 {
return __normal_iterator(_M_current - __n); }
1071 _GLIBCXX20_CONSTEXPR
1073 base() const _GLIBCXX_NOEXCEPT
1074 {
return _M_current; }
1085 #if __cpp_lib_three_way_comparison
1086 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1087 requires requires (_IteratorL __lhs, _IteratorR __rhs)
1088 { { __lhs == __rhs } -> std::convertible_to<bool>; }
1090 operator==(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1091 const __normal_iterator<_IteratorR, _Container>& __rhs)
1092 noexcept(noexcept(__lhs.base() == __rhs.base()))
1093 {
return __lhs.base() == __rhs.base(); }
1095 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1096 constexpr std::__detail::__synth3way_t<_IteratorR, _IteratorL>
1097 operator<=>(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1098 const __normal_iterator<_IteratorR, _Container>& __rhs)
1099 noexcept(noexcept(std::__detail::__synth3way(__lhs.base(), __rhs.base())))
1100 {
return std::__detail::__synth3way(__lhs.base(), __rhs.base()); }
1102 template<
typename _Iterator,
typename _Container>
1104 operator==(
const __normal_iterator<_Iterator, _Container>& __lhs,
1105 const __normal_iterator<_Iterator, _Container>& __rhs)
1106 noexcept(noexcept(__lhs.base() == __rhs.base()))
1108 { __lhs.base() == __rhs.base() } -> std::convertible_to<bool>;
1110 {
return __lhs.base() == __rhs.base(); }
1112 template<
typename _Iterator,
typename _Container>
1113 constexpr std::__detail::__synth3way_t<_Iterator>
1114 operator<=>(
const __normal_iterator<_Iterator, _Container>& __lhs,
1115 const __normal_iterator<_Iterator, _Container>& __rhs)
1116 noexcept(noexcept(std::__detail::__synth3way(__lhs.base(), __rhs.base())))
1117 {
return std::__detail::__synth3way(__lhs.base(), __rhs.base()); }
1120 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1121 _GLIBCXX20_CONSTEXPR
1123 operator==(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1124 const __normal_iterator<_IteratorR, _Container>& __rhs)
1126 {
return __lhs.base() == __rhs.base(); }
1128 template<
typename _Iterator,
typename _Container>
1129 _GLIBCXX20_CONSTEXPR
1131 operator==(
const __normal_iterator<_Iterator, _Container>& __lhs,
1132 const __normal_iterator<_Iterator, _Container>& __rhs)
1134 {
return __lhs.base() == __rhs.base(); }
1136 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1137 _GLIBCXX20_CONSTEXPR
1139 operator!=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1140 const __normal_iterator<_IteratorR, _Container>& __rhs)
1142 {
return __lhs.base() != __rhs.base(); }
1144 template<
typename _Iterator,
typename _Container>
1145 _GLIBCXX20_CONSTEXPR
1147 operator!=(
const __normal_iterator<_Iterator, _Container>& __lhs,
1148 const __normal_iterator<_Iterator, _Container>& __rhs)
1150 {
return __lhs.base() != __rhs.base(); }
1153 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1155 operator<(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1156 const __normal_iterator<_IteratorR, _Container>& __rhs)
1158 {
return __lhs.base() < __rhs.base(); }
1160 template<
typename _Iterator,
typename _Container>
1161 _GLIBCXX20_CONSTEXPR
1163 operator<(
const __normal_iterator<_Iterator, _Container>& __lhs,
1164 const __normal_iterator<_Iterator, _Container>& __rhs)
1166 {
return __lhs.base() < __rhs.base(); }
1168 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1170 operator>(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1171 const __normal_iterator<_IteratorR, _Container>& __rhs)
1173 {
return __lhs.base() > __rhs.base(); }
1175 template<
typename _Iterator,
typename _Container>
1176 _GLIBCXX20_CONSTEXPR
1178 operator>(
const __normal_iterator<_Iterator, _Container>& __lhs,
1179 const __normal_iterator<_Iterator, _Container>& __rhs)
1181 {
return __lhs.base() > __rhs.base(); }
1183 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1185 operator<=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1186 const __normal_iterator<_IteratorR, _Container>& __rhs)
1188 {
return __lhs.base() <= __rhs.base(); }
1190 template<
typename _Iterator,
typename _Container>
1191 _GLIBCXX20_CONSTEXPR
1193 operator<=(
const __normal_iterator<_Iterator, _Container>& __lhs,
1194 const __normal_iterator<_Iterator, _Container>& __rhs)
1196 {
return __lhs.base() <= __rhs.base(); }
1198 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1200 operator>=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1201 const __normal_iterator<_IteratorR, _Container>& __rhs)
1203 {
return __lhs.base() >= __rhs.base(); }
1205 template<
typename _Iterator,
typename _Container>
1206 _GLIBCXX20_CONSTEXPR
1208 operator>=(
const __normal_iterator<_Iterator, _Container>& __lhs,
1209 const __normal_iterator<_Iterator, _Container>& __rhs)
1211 {
return __lhs.base() >= __rhs.base(); }
1218 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
1219 #if __cplusplus >= 201103L
1221 _GLIBCXX20_CONSTEXPR
1223 operator-(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1224 const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept
1225 -> decltype(__lhs.base() - __rhs.base())
1227 inline typename __normal_iterator<_IteratorL, _Container>::difference_type
1228 operator-(
const __normal_iterator<_IteratorL, _Container>& __lhs,
1229 const __normal_iterator<_IteratorR, _Container>& __rhs)
1231 {
return __lhs.base() - __rhs.base(); }
1233 template<
typename _Iterator,
typename _Container>
1234 _GLIBCXX20_CONSTEXPR
1235 inline typename __normal_iterator<_Iterator, _Container>::difference_type
1236 operator-(
const __normal_iterator<_Iterator, _Container>& __lhs,
1237 const __normal_iterator<_Iterator, _Container>& __rhs)
1239 {
return __lhs.base() - __rhs.base(); }
1241 template<
typename _Iterator,
typename _Container>
1242 _GLIBCXX20_CONSTEXPR
1243 inline __normal_iterator<_Iterator, _Container>
1244 operator+(
typename __normal_iterator<_Iterator, _Container>::difference_type
1245 __n,
const __normal_iterator<_Iterator, _Container>& __i)
1247 {
return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
1249 _GLIBCXX_END_NAMESPACE_VERSION
1252 namespace std _GLIBCXX_VISIBILITY(default)
1254 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1256 template<
typename _Iterator,
typename _Container>
1257 _GLIBCXX20_CONSTEXPR
1259 __niter_base(__gnu_cxx::__normal_iterator<_Iterator, _Container> __it)
1261 {
return __it.base(); }
1263 #if __cplusplus >= 201103L
1269 #if __cplusplus > 201703L && __cpp_lib_concepts
1270 template<semiregular _Sent>
1276 noexcept(is_nothrow_default_constructible_v<_Sent>)
1280 move_sentinel(_Sent __s)
1281 noexcept(is_nothrow_move_constructible_v<_Sent>)
1284 template<
typename _S2> requires convertible_to<const _S2&, _Sent>
1286 move_sentinel(
const move_sentinel<_S2>& __s)
1287 noexcept(is_nothrow_constructible_v<_Sent, const _S2&>)
1288 : _M_last(__s.base())
1291 template<
typename _S2> requires assignable_from<_Sent&, const _S2&>
1292 constexpr move_sentinel&
1293 operator=(
const move_sentinel<_S2>& __s)
1294 noexcept(is_nothrow_assignable_v<_Sent, const _S2&>)
1296 _M_last = __s.base();
1302 noexcept(is_nothrow_copy_constructible_v<_Sent>)
1312 #if __cplusplus > 201703L && __cpp_lib_concepts
1313 template<
typename _Iterator>
1314 struct __move_iter_cat
1317 template<
typename _Iterator>
1318 requires requires {
typename iterator_traits<_Iterator>::iterator_category; }
1319 struct __move_iter_cat<_Iterator>
1321 using iterator_category
1322 = __clamp_iter_cat<typename iterator_traits<_Iterator>::iterator_category,
1323 random_access_iterator_tag>;
1337 template<
typename _Iterator>
1339 #if __cplusplus > 201703L && __cpp_lib_concepts
1340 :
public __detail::__move_iter_cat<_Iterator>
1343 _Iterator _M_current;
1346 #if ! (__cplusplus > 201703L && __cpp_lib_concepts)
1347 using __base_ref =
typename __traits_type::reference;
1351 using iterator_type = _Iterator;
1353 #if __cplusplus > 201703L && __cpp_lib_concepts
1356 using value_type = iter_value_t<_Iterator>;
1357 using difference_type = iter_difference_t<_Iterator>;
1358 using pointer = _Iterator;
1359 using reference = iter_rvalue_reference_t<_Iterator>;
1361 typedef typename __traits_type::iterator_category iterator_category;
1362 typedef typename __traits_type::value_type value_type;
1363 typedef typename __traits_type::difference_type difference_type;
1365 typedef _Iterator pointer;
1369 typename remove_reference<__base_ref>::type&&,
1370 __base_ref>::type reference;
1373 _GLIBCXX17_CONSTEXPR
1377 explicit _GLIBCXX17_CONSTEXPR
1381 template<
typename _Iter>
1382 _GLIBCXX17_CONSTEXPR
1384 : _M_current(__i.base()) { }
1386 template<
typename _Iter>
1387 _GLIBCXX17_CONSTEXPR
1390 _M_current = __i.base();
1394 #if __cplusplus <= 201703L
1395 _GLIBCXX17_CONSTEXPR iterator_type
1397 {
return _M_current; }
1399 constexpr
const iterator_type&
1400 base()
const & noexcept
1401 {
return _M_current; }
1403 constexpr iterator_type
1408 _GLIBCXX17_CONSTEXPR reference
1410 #if __cplusplus > 201703L && __cpp_lib_concepts
1411 {
return ranges::iter_move(_M_current); }
1413 {
return static_cast<reference
>(*_M_current); }
1416 _GLIBCXX17_CONSTEXPR pointer
1418 {
return _M_current; }
1435 #if __cpp_lib_concepts
1437 operator++(
int) requires (!forward_iterator<_Iterator>)
1461 operator+=(difference_type __n)
1472 operator-=(difference_type __n)
1478 _GLIBCXX17_CONSTEXPR reference
1479 operator[](difference_type __n)
const
1480 #if __cplusplus > 201703L && __cpp_lib_concepts
1481 {
return ranges::iter_move(_M_current + __n); }
1486 #if __cplusplus > 201703L && __cpp_lib_concepts
1487 template<sentinel_for<_Iterator> _Sent>
1488 friend constexpr
bool
1489 operator==(
const move_iterator& __x,
const move_sentinel<_Sent>& __y)
1490 {
return __x.base() == __y.base(); }
1492 template<sized_sentinel_for<_Iterator> _Sent>
1493 friend constexpr iter_difference_t<_Iterator>
1495 {
return __x.base() - __y.base(); }
1497 template<sized_sentinel_for<_Iterator> _Sent>
1498 friend constexpr iter_difference_t<_Iterator>
1500 {
return __x.base() - __y.base(); }
1502 friend constexpr iter_rvalue_reference_t<_Iterator>
1504 noexcept(noexcept(ranges::iter_move(__i._M_current)))
1505 {
return ranges::iter_move(__i._M_current); }
1507 template<indirectly_swappable<_Iterator> _Iter2>
1508 friend constexpr
void
1510 noexcept(noexcept(ranges::iter_swap(__x._M_current, __y._M_current)))
1511 {
return ranges::iter_swap(__x._M_current, __y._M_current); }
1515 template<
typename _IteratorL,
typename _IteratorR>
1516 inline _GLIBCXX17_CONSTEXPR
bool
1519 #if __cplusplus > 201703L && __cpp_lib_concepts
1520 requires requires { { __x.base() == __y.base() } -> convertible_to<bool>; }
1522 {
return __x.base() == __y.base(); }
1524 #if __cpp_lib_three_way_comparison
1525 template<
typename _IteratorL,
1526 three_way_comparable_with<_IteratorL> _IteratorR>
1527 constexpr compare_three_way_result_t<_IteratorL, _IteratorR>
1528 operator<=>(
const move_iterator<_IteratorL>& __x,
1529 const move_iterator<_IteratorR>& __y)
1530 {
return __x.base() <=> __y.base(); }
1532 template<
typename _IteratorL,
typename _IteratorR>
1533 inline _GLIBCXX17_CONSTEXPR
bool
1534 operator!=(
const move_iterator<_IteratorL>& __x,
1535 const move_iterator<_IteratorR>& __y)
1536 {
return !(__x == __y); }
1539 template<
typename _IteratorL,
typename _IteratorR>
1540 inline _GLIBCXX17_CONSTEXPR
bool
1541 operator<(
const move_iterator<_IteratorL>& __x,
1542 const move_iterator<_IteratorR>& __y)
1543 #if __cplusplus > 201703L && __cpp_lib_concepts
1544 requires requires { { __x.base() < __y.base() } -> convertible_to<bool>; }
1546 {
return __x.base() < __y.base(); }
1548 template<
typename _IteratorL,
typename _IteratorR>
1549 inline _GLIBCXX17_CONSTEXPR
bool
1550 operator<=(
const move_iterator<_IteratorL>& __x,
1551 const move_iterator<_IteratorR>& __y)
1552 #if __cplusplus > 201703L && __cpp_lib_concepts
1553 requires requires { { __y.base() < __x.base() } -> convertible_to<bool>; }
1555 {
return !(__y < __x); }
1557 template<
typename _IteratorL,
typename _IteratorR>
1558 inline _GLIBCXX17_CONSTEXPR
bool
1559 operator>(
const move_iterator<_IteratorL>& __x,
1560 const move_iterator<_IteratorR>& __y)
1561 #if __cplusplus > 201703L && __cpp_lib_concepts
1562 requires requires { { __y.base() < __x.base() } -> convertible_to<bool>; }
1564 {
return __y < __x; }
1566 template<
typename _IteratorL,
typename _IteratorR>
1567 inline _GLIBCXX17_CONSTEXPR
bool
1568 operator>=(
const move_iterator<_IteratorL>& __x,
1569 const move_iterator<_IteratorR>& __y)
1570 #if __cplusplus > 201703L && __cpp_lib_concepts
1571 requires requires { { __x.base() < __y.base() } -> convertible_to<bool>; }
1573 {
return !(__x < __y); }
1578 template<
typename _Iterator>
1579 inline _GLIBCXX17_CONSTEXPR
bool
1580 operator==(
const move_iterator<_Iterator>& __x,
1581 const move_iterator<_Iterator>& __y)
1582 {
return __x.base() == __y.base(); }
1584 #if __cpp_lib_three_way_comparison
1585 template<three_way_comparable _Iterator>
1586 constexpr compare_three_way_result_t<_Iterator>
1587 operator<=>(
const move_iterator<_Iterator>& __x,
1588 const move_iterator<_Iterator>& __y)
1589 {
return __x.base() <=> __y.base(); }
1591 template<
typename _Iterator>
1592 inline _GLIBCXX17_CONSTEXPR
bool
1593 operator!=(
const move_iterator<_Iterator>& __x,
1594 const move_iterator<_Iterator>& __y)
1595 {
return !(__x == __y); }
1597 template<
typename _Iterator>
1598 inline _GLIBCXX17_CONSTEXPR
bool
1599 operator<(
const move_iterator<_Iterator>& __x,
1600 const move_iterator<_Iterator>& __y)
1601 {
return __x.base() < __y.base(); }
1603 template<
typename _Iterator>
1604 inline _GLIBCXX17_CONSTEXPR
bool
1605 operator<=(
const move_iterator<_Iterator>& __x,
1606 const move_iterator<_Iterator>& __y)
1607 {
return !(__y < __x); }
1609 template<
typename _Iterator>
1610 inline _GLIBCXX17_CONSTEXPR
bool
1611 operator>(
const move_iterator<_Iterator>& __x,
1612 const move_iterator<_Iterator>& __y)
1613 {
return __y < __x; }
1615 template<
typename _Iterator>
1616 inline _GLIBCXX17_CONSTEXPR
bool
1617 operator>=(
const move_iterator<_Iterator>& __x,
1618 const move_iterator<_Iterator>& __y)
1619 {
return !(__x < __y); }
1623 template<
typename _IteratorL,
typename _IteratorR>
1624 inline _GLIBCXX17_CONSTEXPR
auto
1625 operator-(
const move_iterator<_IteratorL>& __x,
1626 const move_iterator<_IteratorR>& __y)
1627 -> decltype(__x.base() - __y.base())
1628 {
return __x.base() - __y.base(); }
1630 template<
typename _Iterator>
1631 inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator>
1632 operator+(
typename move_iterator<_Iterator>::difference_type __n,
1633 const move_iterator<_Iterator>& __x)
1634 {
return __x + __n; }
1636 template<
typename _Iterator>
1637 inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator>
1638 make_move_iterator(_Iterator __i)
1639 {
return move_iterator<_Iterator>(
std::move(__i)); }
1641 template<
typename _Iterator,
typename _ReturnType
1642 =
typename conditional<__move_if_noexcept_cond
1643 <
typename iterator_traits<_Iterator>::value_type>::value,
1644 _Iterator, move_iterator<_Iterator>>::type>
1645 inline _GLIBCXX17_CONSTEXPR _ReturnType
1646 __make_move_if_noexcept_iterator(_Iterator __i)
1647 {
return _ReturnType(__i); }
1651 template<
typename _Tp,
typename _ReturnType
1652 =
typename conditional<__move_if_noexcept_cond<_Tp>::value,
1653 const _Tp*, move_iterator<_Tp*>>::type>
1654 inline _GLIBCXX17_CONSTEXPR _ReturnType
1655 __make_move_if_noexcept_iterator(_Tp* __i)
1656 {
return _ReturnType(__i); }
1658 #if __cplusplus > 201703L && __cpp_lib_concepts
1663 template<
typename _It>
1664 concept __common_iter_has_arrow = indirectly_readable<const _It>
1665 && (requires(
const _It& __it) { __it.operator->(); }
1666 || is_reference_v<iter_reference_t<_It>>
1667 || constructible_from<iter_value_t<_It>, iter_reference_t<_It>>);
1669 template<
typename _It>
1670 concept __common_iter_use_postfix_proxy
1671 = (!requires (_It& __i) { { *__i++ } -> __can_reference; })
1672 && constructible_from<iter_value_t<_It>, iter_reference_t<_It>>
1673 && move_constructible<iter_value_t<_It>>;
1677 template<input_or_output_iterator _It, sentinel_for<_It> _Sent>
1678 requires (!same_as<_It, _Sent>) && copyable<_It>
1679 class common_iterator
1681 template<
typename _Tp,
typename _Up>
1682 static constexpr
bool
1685 if constexpr (is_trivially_default_constructible_v<_Tp>)
1686 return is_nothrow_assignable_v<_Tp, _Up>;
1688 return is_nothrow_constructible_v<_Tp, _Up>;
1691 template<
typename _It2,
typename _Sent2>
1692 static constexpr
bool
1694 {
return _S_noexcept1<_It, _It2>() && _S_noexcept1<_Sent, _Sent2>(); }
1698 iter_value_t<_It> _M_keep;
1701 __arrow_proxy(iter_reference_t<_It>&& __x)
1704 friend class common_iterator;
1707 constexpr
const iter_value_t<_It>*
1708 operator->() const noexcept
1712 class __postfix_proxy
1714 iter_value_t<_It> _M_keep;
1717 __postfix_proxy(iter_reference_t<_It>&& __x)
1718 : _M_keep(
std::
forward<iter_reference_t<_It>>(__x)) { }
1720 friend class common_iterator;
1723 constexpr
const iter_value_t<_It>&
1731 noexcept(is_nothrow_default_constructible_v<_It>)
1732 requires default_initializable<_It>
1733 : _M_it(), _M_index(0)
1737 common_iterator(_It __i)
1738 noexcept(is_nothrow_move_constructible_v<_It>)
1739 : _M_it(
std::
move(__i)), _M_index(0)
1743 common_iterator(_Sent __s)
1744 noexcept(is_nothrow_move_constructible_v<_Sent>)
1745 : _M_sent(
std::
move(__s)), _M_index(1)
1748 template<
typename _It2,
typename _Sent2>
1749 requires convertible_to<const _It2&, _It>
1750 && convertible_to<const _Sent2&, _Sent>
1752 common_iterator(
const common_iterator<_It2, _Sent2>& __x)
1753 noexcept(_S_noexcept<const _It2&, const _Sent2&>())
1754 : _M_valueless(), _M_index(__x._M_index)
1758 if constexpr (is_trivially_default_constructible_v<_It>)
1763 else if (_M_index == 1)
1765 if constexpr (is_trivially_default_constructible_v<_Sent>)
1773 common_iterator(
const common_iterator& __x)
1774 noexcept(_S_noexcept<const _It&, const _Sent&>())
1775 : _M_valueless(), _M_index(__x._M_index)
1779 if constexpr (is_trivially_default_constructible_v<_It>)
1784 else if (_M_index == 1)
1786 if constexpr (is_trivially_default_constructible_v<_Sent>)
1794 operator=(
const common_iterator& __x)
1795 noexcept(is_nothrow_copy_assignable_v<_It>
1796 && is_nothrow_copy_assignable_v<_Sent>
1797 && is_nothrow_copy_constructible_v<_It>
1798 && is_nothrow_copy_constructible_v<_Sent>)
1800 return this->
operator=<_It, _Sent>(__x);
1803 template<
typename _It2,
typename _Sent2>
1804 requires convertible_to<const _It2&, _It>
1805 && convertible_to<const _Sent2&, _Sent>
1806 && assignable_from<_It&, const _It2&>
1807 && assignable_from<_Sent&, const _Sent2&>
1809 operator=(
const common_iterator<_It2, _Sent2>& __x)
1810 noexcept(is_nothrow_constructible_v<_It, const _It2&>
1811 && is_nothrow_constructible_v<_Sent, const _Sent2&>
1812 && is_nothrow_assignable_v<_It, const _It2&>
1813 && is_nothrow_assignable_v<_Sent, const _Sent2&>)
1815 switch(_M_index << 2 | __x._M_index)
1821 _M_sent = __x._M_sent;
1840 __glibcxx_assert(__x._M_has_value());
1841 __builtin_unreachable();
1862 __glibcxx_assert(_M_index == 0);
1867 operator*() const requires __detail::__dereferenceable<const _It>
1869 __glibcxx_assert(_M_index == 0);
1874 operator->() const requires __detail::__common_iter_has_arrow<_It>
1876 __glibcxx_assert(_M_index == 0);
1877 if constexpr (is_pointer_v<_It> || requires { _M_it.operator->(); })
1879 else if constexpr (is_reference_v<iter_reference_t<_It>>)
1881 auto&& __tmp = *_M_it;
1885 return __arrow_proxy{*_M_it};
1891 __glibcxx_assert(_M_index == 0);
1899 __glibcxx_assert(_M_index == 0);
1900 if constexpr (forward_iterator<_It>)
1902 common_iterator __tmp = *
this;
1906 else if constexpr (!__detail::__common_iter_use_postfix_proxy<_It>)
1910 __postfix_proxy __p(**
this);
1916 template<
typename _It2, sentinel_for<_It> _Sent2>
1917 requires sentinel_for<_Sent, _It2>
1919 operator==(
const common_iterator& __x,
1920 const common_iterator<_It2, _Sent2>& __y)
1922 switch(__x._M_index << 2 | __y._M_index)
1928 return __x._M_it == __y._M_sent;
1930 return __x._M_sent == __y._M_it;
1932 __glibcxx_assert(__x._M_has_value());
1933 __glibcxx_assert(__y._M_has_value());
1934 __builtin_unreachable();
1938 template<
typename _It2, sentinel_for<_It> _Sent2>
1939 requires sentinel_for<_Sent, _It2> && equality_comparable_with<_It, _It2>
1941 operator==(
const common_iterator& __x,
1942 const common_iterator<_It2, _Sent2>& __y)
1944 switch(__x._M_index << 2 | __y._M_index)
1949 return __x._M_it == __y._M_it;
1951 return __x._M_it == __y._M_sent;
1953 return __x._M_sent == __y._M_it;
1955 __glibcxx_assert(__x._M_has_value());
1956 __glibcxx_assert(__y._M_has_value());
1957 __builtin_unreachable();
1961 template<sized_sentinel_for<_It> _It2, sized_sentinel_for<_It> _Sent2>
1962 requires sized_sentinel_for<_Sent, _It2>
1963 friend iter_difference_t<_It2>
1965 const common_iterator<_It2, _Sent2>& __y)
1967 switch(__x._M_index << 2 | __y._M_index)
1972 return __x._M_it - __y._M_it;
1974 return __x._M_it - __y._M_sent;
1976 return __x._M_sent - __y._M_it;
1978 __glibcxx_assert(__x._M_has_value());
1979 __glibcxx_assert(__y._M_has_value());
1980 __builtin_unreachable();
1984 friend iter_rvalue_reference_t<_It>
1985 iter_move(
const common_iterator& __i)
1986 noexcept(noexcept(ranges::iter_move(std::declval<const _It&>())))
1987 requires input_iterator<_It>
1989 __glibcxx_assert(__i._M_index == 0);
1990 return ranges::iter_move(__i._M_it);
1993 template<indirectly_swappable<_It> _It2,
typename _Sent2>
1995 iter_swap(
const common_iterator& __x,
1996 const common_iterator<_It2, _Sent2>& __y)
1997 noexcept(noexcept(ranges::iter_swap(std::declval<const _It&>(),
1998 std::declval<const _It2&>())))
2000 __glibcxx_assert(__x._M_index == 0);
2001 __glibcxx_assert(__y._M_index == 0);
2002 return ranges::iter_swap(__x._M_it, __y._M_it);
2006 template<input_or_output_iterator _It2, sentinel_for<_It2> _Sent2>
2007 friend class common_iterator;
2009 bool _M_has_value() const noexcept {
return _M_index < 2; }
2015 unsigned char _M_valueless;
2017 unsigned char _M_index;
2020 template<
typename _It,
typename _Sent>
2021 struct incrementable_traits<common_iterator<_It, _Sent>>
2023 using difference_type = iter_difference_t<_It>;
2026 template<input_iterator _It,
typename _Sent>
2027 struct iterator_traits<common_iterator<_It, _Sent>>
2030 template<
typename _Iter>
2036 template<
typename _Iter>
2037 requires __detail::__common_iter_has_arrow<_Iter>
2040 using _CIter = common_iterator<_Iter, _Sent>;
2041 using type = decltype(std::declval<const _CIter&>().operator->());
2047 using _Traits = iterator_traits<_It>;
2048 if constexpr (requires { requires derived_from<
typename _Traits::iterator_category,
2049 forward_iterator_tag>; })
2050 return forward_iterator_tag{};
2052 return input_iterator_tag{};
2056 using iterator_concept = conditional_t<forward_iterator<_It>,
2057 forward_iterator_tag, input_iterator_tag>;
2058 using iterator_category = decltype(_S_iter_cat());
2059 using value_type = iter_value_t<_It>;
2060 using difference_type = iter_difference_t<_It>;
2061 using pointer =
typename __ptr<_It>::type;
2062 using reference = iter_reference_t<_It>;
2069 template<
typename _It>
2070 struct __counted_iter_value_type
2073 template<indirectly_readable _It>
2074 struct __counted_iter_value_type<_It>
2075 {
using value_type = iter_value_t<_It>; };
2077 template<
typename _It>
2078 struct __counted_iter_concept
2081 template<
typename _It>
2082 requires requires {
typename _It::iterator_concept; }
2083 struct __counted_iter_concept<_It>
2084 {
using iterator_concept =
typename _It::iterator_concept; };
2086 template<
typename _It>
2087 struct __counted_iter_cat
2090 template<
typename _It>
2091 requires requires {
typename _It::iterator_category; }
2092 struct __counted_iter_cat<_It>
2093 {
using iterator_category =
typename _It::iterator_category; };
2097 template<input_or_output_iterator _It>
2098 class counted_iterator
2099 :
public __detail::__counted_iter_value_type<_It>,
2100 public __detail::__counted_iter_concept<_It>,
2101 public __detail::__counted_iter_cat<_It>
2104 using iterator_type = _It;
2106 using difference_type = iter_difference_t<_It>;
2110 constexpr counted_iterator() requires default_initializable<_It> = default;
2113 counted_iterator(_It __i, iter_difference_t<_It> __n)
2114 : _M_current(
std::
move(__i)), _M_length(__n)
2115 { __glibcxx_assert(__n >= 0); }
2117 template<
typename _It2>
2118 requires convertible_to<const _It2&, _It>
2120 counted_iterator(
const counted_iterator<_It2>& __x)
2121 : _M_current(__x._M_current), _M_length(__x._M_length)
2124 template<
typename _It2>
2125 requires assignable_from<_It&, const _It2&>
2126 constexpr counted_iterator&
2127 operator=(
const counted_iterator<_It2>& __x)
2129 _M_current = __x._M_current;
2130 _M_length = __x._M_length;
2134 constexpr
const _It&
2135 base() const & noexcept
2136 {
return _M_current; }
2140 noexcept(is_nothrow_move_constructible_v<_It>)
2143 constexpr iter_difference_t<_It>
2144 count() const noexcept {
return _M_length; }
2146 constexpr decltype(
auto)
2148 noexcept(noexcept(*_M_current))
2149 {
return *_M_current; }
2151 constexpr decltype(
auto)
2153 noexcept(noexcept(*_M_current))
2154 requires __detail::__dereferenceable<const _It>
2155 {
return *_M_current; }
2158 operator->() const noexcept
2159 requires contiguous_iterator<_It>
2160 {
return std::to_address(_M_current); }
2162 constexpr counted_iterator&
2165 __glibcxx_assert(_M_length > 0);
2174 __glibcxx_assert(_M_length > 0);
2178 return _M_current++;
2181 __throw_exception_again;
2186 constexpr counted_iterator
2187 operator++(
int) requires forward_iterator<_It>
2194 constexpr counted_iterator&
2195 operator--() requires bidirectional_iterator<_It>
2202 constexpr counted_iterator
2203 operator--(
int) requires bidirectional_iterator<_It>
2210 constexpr counted_iterator
2211 operator+(iter_difference_t<_It> __n)
const
2212 requires random_access_iterator<_It>
2213 {
return counted_iterator(_M_current + __n, _M_length - __n); }
2215 friend constexpr counted_iterator
2216 operator+(iter_difference_t<_It> __n,
const counted_iterator& __x)
2217 requires random_access_iterator<_It>
2218 {
return __x + __n; }
2220 constexpr counted_iterator&
2221 operator+=(iter_difference_t<_It> __n)
2222 requires random_access_iterator<_It>
2224 __glibcxx_assert(__n <= _M_length);
2230 constexpr counted_iterator
2231 operator-(iter_difference_t<_It> __n)
const
2232 requires random_access_iterator<_It>
2233 {
return counted_iterator(_M_current - __n, _M_length + __n); }
2235 template<common_with<_It> _It2>
2236 friend constexpr iter_difference_t<_It2>
2238 const counted_iterator<_It2>& __y)
2239 {
return __y._M_length - __x._M_length; }
2241 friend constexpr iter_difference_t<_It>
2242 operator-(
const counted_iterator& __x, default_sentinel_t)
2243 {
return -__x._M_length; }
2245 friend constexpr iter_difference_t<_It>
2246 operator-(default_sentinel_t,
const counted_iterator& __y)
2247 {
return __y._M_length; }
2249 constexpr counted_iterator&
2250 operator-=(iter_difference_t<_It> __n)
2251 requires random_access_iterator<_It>
2253 __glibcxx_assert(-__n <= _M_length);
2259 constexpr decltype(
auto)
2260 operator[](iter_difference_t<_It> __n) const
2261 noexcept(noexcept(_M_current[__n]))
2262 requires random_access_iterator<_It>
2264 __glibcxx_assert(__n < _M_length);
2265 return _M_current[__n];
2268 template<common_with<_It> _It2>
2269 friend constexpr
bool
2270 operator==(
const counted_iterator& __x,
2271 const counted_iterator<_It2>& __y)
2272 {
return __x._M_length == __y._M_length; }
2274 friend constexpr
bool
2275 operator==(
const counted_iterator& __x, default_sentinel_t)
2276 {
return __x._M_length == 0; }
2278 template<common_with<_It> _It2>
2279 friend constexpr strong_ordering
2280 operator<=>(
const counted_iterator& __x,
2281 const counted_iterator<_It2>& __y)
2282 {
return __y._M_length <=> __x._M_length; }
2284 friend constexpr iter_rvalue_reference_t<_It>
2285 iter_move(
const counted_iterator& __i)
2286 noexcept(noexcept(ranges::iter_move(__i._M_current)))
2287 requires input_iterator<_It>
2288 {
return ranges::iter_move(__i._M_current); }
2290 template<indirectly_swappable<_It> _It2>
2291 friend constexpr
void
2292 iter_swap(
const counted_iterator& __x,
2293 const counted_iterator<_It2>& __y)
2294 noexcept(noexcept(ranges::iter_swap(__x._M_current, __y._M_current)))
2295 { ranges::iter_swap(__x._M_current, __y._M_current); }
2298 template<input_or_output_iterator _It2>
friend class counted_iterator;
2300 _It _M_current = _It();
2301 iter_difference_t<_It> _M_length = 0;
2304 template<input_iterator _It>
2305 requires same_as<__detail::__iter_traits<_It>, iterator_traits<_It>>
2306 struct iterator_traits<counted_iterator<_It>> : iterator_traits<_It>
2308 using pointer = conditional_t<contiguous_iterator<_It>,
2309 add_pointer_t<iter_reference_t<_It>>,
2316 template<
typename _Iterator>
2317 _GLIBCXX20_CONSTEXPR
2319 __niter_base(move_iterator<_Iterator> __it)
2320 -> decltype(make_move_iterator(__niter_base(__it.base())))
2321 {
return make_move_iterator(__niter_base(__it.base())); }
2323 template<
typename _Iterator>
2324 struct __is_move_iterator<move_iterator<_Iterator> >
2326 enum { __value = 1 };
2327 typedef __true_type __type;
2330 template<
typename _Iterator>
2331 _GLIBCXX20_CONSTEXPR
2333 __miter_base(move_iterator<_Iterator> __it)
2334 -> decltype(__miter_base(__it.base()))
2335 {
return __miter_base(__it.base()); }
2337 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter)
2338 #define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) \
2339 std::__make_move_if_noexcept_iterator(_Iter)
2341 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter)
2342 #define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter)
2345 #if __cpp_deduction_guides >= 201606
2348 template<
typename _InputIterator>
2350 typename iterator_traits<_InputIterator>::value_type::first_type>;
2352 template<
typename _InputIterator>
2353 using __iter_val_t =
2354 typename iterator_traits<_InputIterator>::value_type::second_type;
2356 template<
typename _T1,
typename _T2>
2359 template<
typename _InputIterator>
2360 using __iter_to_alloc_t =
2361 pair<add_const_t<__iter_key_t<_InputIterator>>,
2362 __iter_val_t<_InputIterator>>;
2365 _GLIBCXX_END_NAMESPACE_VERSION
2368 #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.
typename conditional< _Cond, _Iftrue, _Iffalse >::type conditional_t
Alias template for conditional.
typename remove_const< _Tp >::type remove_const_t
Alias template for remove_const.
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.
insert_iterator< _Container > inserter(_Container &__x, typename _Container::iterator __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.
Define a member typedef type to one of two argument types.
is_nothrow_copy_constructible
Traits class for iterators.
constexpr pointer operator->() const
constexpr iterator_type base() const
constexpr reverse_iterator operator+(difference_type __n) const
constexpr reverse_iterator(iterator_type __x)
constexpr reverse_iterator & operator+=(difference_type __n)
constexpr reference operator[](difference_type __n) const
constexpr reverse_iterator & operator--()
constexpr reverse_iterator(const reverse_iterator &__x)
constexpr reverse_iterator & operator-=(difference_type __n)
constexpr reverse_iterator(const reverse_iterator< _Iter > &__x)
constexpr reverse_iterator operator--(int)
constexpr reference operator*() const
constexpr reverse_iterator operator-(difference_type __n) const
constexpr reverse_iterator()
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.
Bidirectional iterators support a superset of forward iterator operations.
Random-access iterators support a superset of bidirectional iterator operations.
iterator_traits< _Iterator >::iterator_category iterator_category
One of the tag types.
void difference_type
Distance between iterators is represented as this type.
iterator_traits< _Iterator >::value_type value_type
The type "pointed to" by the iterator.