31#define _RANGES_UTIL_H 1
33#if __cplusplus > 201703L
38#if __glibcxx_tuple_like
42#ifdef __glibcxx_ranges
43namespace std _GLIBCXX_VISIBILITY(default)
45_GLIBCXX_BEGIN_NAMESPACE_VERSION
52 template<
typename _Range>
53 concept __simple_view = view<_Range> && range<const _Range>
54 && same_as<iterator_t<_Range>, iterator_t<const _Range>>
55 && same_as<sentinel_t<_Range>, sentinel_t<const _Range>>;
59 template<
typename _It>
60 concept __has_arrow = input_iterator<_It>
62 ||
requires(
const _It __it) { __it.operator->(); });
64 using std::__detail::__different_from;
68 template<
typename _Derived>
69 requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
73 constexpr _Derived& _M_derived()
noexcept
77 return static_cast<_Derived&
>(*this);
80 constexpr const _Derived& _M_derived()
const noexcept
84 return static_cast<const _Derived&
>(*this);
88 _S_bool(
bool)
noexcept;
90 template<
typename _Tp>
93 noexcept(
noexcept(_S_bool(ranges::begin(__t) == ranges::end(__t))))
94 {
return ranges::begin(__t) == ranges::end(__t); }
96 template<
typename _Tp>
99 noexcept(
noexcept(ranges::end(__t) - ranges::begin(__t)))
100 {
return ranges::end(__t) - ranges::begin(__t); }
105 noexcept(
noexcept(_S_empty(_M_derived())))
107 {
return _S_empty(_M_derived()); }
111 noexcept(
noexcept(ranges::size(_M_derived()) == 0))
113 {
return ranges::size(_M_derived()) == 0; }
117 noexcept(
noexcept(_S_empty(_M_derived())))
119 {
return _S_empty(_M_derived()); }
123 noexcept(
noexcept(ranges::size(_M_derived()) == 0))
125 {
return ranges::size(_M_derived()) == 0; }
128 operator bool()
noexcept(
noexcept(ranges::empty(_M_derived())))
129 requires requires { ranges::empty(_M_derived()); }
130 {
return !ranges::empty(_M_derived()); }
133 operator bool()
const noexcept(
noexcept(ranges::empty(_M_derived())))
134 requires requires { ranges::empty(_M_derived()); }
135 {
return !ranges::empty(_M_derived()); }
138 data()
noexcept(
noexcept(ranges::begin(_M_derived())))
139 requires contiguous_iterator<iterator_t<_Derived>>
143 data()
const noexcept(
noexcept(ranges::begin(_M_derived())))
145 && contiguous_iterator<iterator_t<const _Derived>>
149 size()
noexcept(
noexcept(_S_size(_M_derived())))
151 && sized_sentinel_for<sentinel_t<_Derived>, iterator_t<_Derived>>
152 {
return _S_size(_M_derived()); }
155 size()
const noexcept(
noexcept(_S_size(_M_derived())))
157 && sized_sentinel_for<sentinel_t<const _Derived>,
158 iterator_t<const _Derived>>
159 {
return _S_size(_M_derived()); }
161 constexpr decltype(
auto)
164 __glibcxx_assert(!empty());
165 return *ranges::begin(_M_derived());
168 constexpr decltype(
auto)
171 __glibcxx_assert(!empty());
172 return *ranges::begin(_M_derived());
175 constexpr decltype(
auto)
179 __glibcxx_assert(!empty());
180 return *ranges::prev(ranges::end(_M_derived()));
183 constexpr decltype(
auto)
188 __glibcxx_assert(!empty());
189 return *ranges::prev(ranges::end(_M_derived()));
192 template<random_access_range _Range = _Derived>
193 constexpr decltype(
auto)
194 operator[](range_difference_t<_Range> __n)
195 {
return ranges::begin(_M_derived())[__n]; }
197 template<random_access_range _Range = const _Derived>
198 constexpr decltype(
auto)
199 operator[](range_difference_t<_Range> __n)
const
200 {
return ranges::begin(_M_derived())[__n]; }
202#if __cplusplus > 202002L
205 {
return ranges::cbegin(_M_derived()); }
209 {
return ranges::cbegin(_M_derived()); }
213 {
return ranges::cend(_M_derived()); }
217 {
return ranges::cend(_M_derived()); }
223 template<
typename _From,
typename _To>
224 concept __uses_nonqualification_pointer_conversion
225 = is_pointer_v<_From> && is_pointer_v<_To>
229 template<
typename _From,
typename _To>
231 && !__uses_nonqualification_pointer_conversion<decay_t<_From>,
234#if __glibcxx_tuple_like
238 template<
typename _Tp>
240 = !is_reference_v<_Tp> &&
requires(_Tp __t)
244 typename tuple_element_t<0, remove_const_t<_Tp>>;
245 typename tuple_element_t<1, remove_const_t<_Tp>>;
247 { get<1>(__t) } -> convertible_to<const tuple_element_t<1, _Tp>&>;
251 template<
typename _Tp,
typename _Up,
typename _Vp>
252 concept __pair_like_convertible_from
253 = !range<_Tp> && !is_reference_v<_Tp> && __pair_like<_Tp>
254 && constructible_from<_Tp, _Up, _Vp>
255 && __convertible_to_non_slicing<_Up, tuple_element_t<0, _Tp>>
256 && convertible_to<_Vp, tuple_element_t<1, _Tp>>;
260 namespace views {
struct _Drop; }
262 enum class subrange_kind :
bool { unsized, sized };
265 template<input_or_output_iterator _It, sentinel_for<_It> _Sent = _It,
266 subrange_kind _Kind = sized_sentinel_for<_Sent, _It>
267 ? subrange_kind::sized : subrange_kind::unsized>
268 requires (_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _It>)
272 static constexpr bool _S_store_size
273 = _Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _It>;
275 friend struct views::_Drop;
277 _It _M_begin = _It();
278 [[no_unique_address]] _Sent _M_end = _Sent();
281 = __detail::__make_unsigned_like_t<iter_difference_t<_It>>;
283 template<
typename _Tp,
bool = _S_store_size>
286 [[__gnu__::__always_inline__]]
287 constexpr _Size(_Tp = {}) { }
290 template<
typename _Tp>
291 struct _Size<_Tp, true>
293 [[__gnu__::__always_inline__]]
294 constexpr _Size(_Tp __s = {}) : _M_size(__s) { }
299 [[no_unique_address]] _Size<__size_type> _M_size = {};
305 subrange(__detail::__convertible_to_non_slicing<_It>
auto __i, _Sent __s)
306 noexcept(is_nothrow_constructible_v<_It,
decltype(__i)>
307 && is_nothrow_constructible_v<_Sent, _Sent&>)
308 requires (!_S_store_size)
313 subrange(__detail::__convertible_to_non_slicing<_It>
auto __i, _Sent __s,
315 noexcept(is_nothrow_constructible_v<_It,
decltype(__i)>
316 && is_nothrow_constructible_v<_Sent, _Sent&>)
317 requires (_Kind == subrange_kind::sized)
318 : _M_begin(
std::move(__i)), _M_end(__s), _M_size(__n)
321 template<__detail::__different_from<subrange> _Rng>
323 && __detail::__convertible_to_non_slicing<iterator_t<_Rng>, _It>
327 noexcept(
noexcept(subrange(__r, ranges::size(__r))))
329 : subrange(__r, ranges::size(__r))
332 template<__detail::__different_from<subrange> _Rng>
334 && __detail::__convertible_to_non_slicing<iterator_t<_Rng>, _It>
338 noexcept(
noexcept(subrange(ranges::begin(__r), ranges::end(__r))))
339 requires (!_S_store_size)
340 : subrange(ranges::begin(__r), ranges::end(__r))
343 template<borrowed_range _Rng>
344 requires __detail::__convertible_to_non_slicing<iterator_t<_Rng>, _It>
347 subrange(_Rng&& __r, __size_type __n)
348 noexcept(
noexcept(subrange(ranges::begin(__r), ranges::end(__r), __n)))
349 requires (_Kind == subrange_kind::sized)
350 : subrange{ranges::begin(__r), ranges::end(__r), __n}
353 template<__detail::__different_from<subrange> _PairLike>
354 requires __detail::__pair_like_convertible_from<_PairLike,
const _It&,
357 operator _PairLike()
const
358 {
return _PairLike(_M_begin, _M_end); }
361 begin()
const requires copyable<_It>
364 [[nodiscard]]
constexpr _It
365 begin()
requires (!copyable<_It>)
368 constexpr _Sent
end()
const {
return _M_end; }
370 constexpr bool empty()
const {
return _M_begin == _M_end; }
372 constexpr __size_type
373 size()
const requires (_Kind == subrange_kind::sized)
375 if constexpr (_S_store_size)
376 return _M_size._M_size;
378 return __detail::__to_unsigned_like(_M_end - _M_begin);
381 [[nodiscard]]
constexpr subrange
382 next(iter_difference_t<_It> __n = 1)
const &
383 requires forward_iterator<_It>
390 [[nodiscard]]
constexpr subrange
391 next(iter_difference_t<_It> __n = 1) &&
397 [[nodiscard]]
constexpr subrange
398 prev(iter_difference_t<_It> __n = 1)
const
399 requires bidirectional_iterator<_It>
407 advance(iter_difference_t<_It> __n)
411 if constexpr (bidirectional_iterator<_It>)
414 ranges::advance(_M_begin, __n);
415 if constexpr (_S_store_size)
416 _M_size._M_size += __detail::__to_unsigned_like(-__n);
420 __glibcxx_assert(__n >= 0);
421 auto __d = __n - ranges::advance(_M_begin, __n, _M_end);
422 if constexpr (_S_store_size)
423 _M_size._M_size -= __detail::__to_unsigned_like(__d);
428 template<input_or_output_iterator _It, sentinel_for<_It> _Sent>
431 template<input_or_output_iterator _It, sentinel_for<_It> _Sent>
433 __detail::__make_unsigned_like_t<iter_difference_t<_It>>)
436 template<borrowed_range _Rng>
440 || sized_sentinel_for<sentinel_t<_Rng>, iterator_t<_Rng>>)
441 ? subrange_kind::sized : subrange_kind::unsized>;
443 template<borrowed_range _Rng>
445 __detail::__make_unsigned_like_t<range_difference_t<_Rng>>)
451 template<
size_t _Num,
class _It,
class _Sent, subrange_kind _Kind>
452 requires ((_Num == 0 && copyable<_It>) || _Num == 1)
456 if constexpr (_Num == 0)
462 template<
size_t _Num,
class _It,
class _Sent, subrange_kind _Kind>
465 get(subrange<_It, _Sent, _Kind>&& __r)
467 if constexpr (_Num == 0)
473 template<
typename _It,
typename _Sent, subrange_kind _Kind>
474 inline constexpr bool
475 enable_borrowed_range<subrange<_It, _Sent, _Kind>> =
true;
477 template<range _Range>
478 using borrowed_subrange_t = __conditional_t<borrowed_range<_Range>,
479 subrange<iterator_t<_Range>>,
483 template<
typename _Iter,
typename _Sent, subrange_kind _Kind>
484 inline constexpr bool __detail::__is_subrange<subrange<_Iter, _Sent, _Kind>> =
true;
489 template<
template<
typename...>
class _Trait,
typename _Tp,
typename _It,
typename _St>
490 constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, ranges::subrange<_It, _St>>
491 = _Trait<_Tp, _It, _St>{};
493 template<
template<
typename...>
class _Trait,
typename _Tp, copyable _It,
typename _St>
494 constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, ranges::subrange<_It, _St>&>
495 = _Trait<_Tp, _It, _St>{};
497 template<
template<
typename...>
class _Trait,
typename _Tp, copyable _It,
typename _St>
498 constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, const ranges::subrange<_It, _St>>
499 = _Trait<_Tp, _It, _St>{};
501 template<
template<
typename...>
class _Trait,
typename _Tp, copyable _It,
typename _St>
502 constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, const ranges::subrange<_It, _St>&>
503 = _Trait<_Tp, _It, _St>{};
506 template<
template<
typename...>
class _Trait,
typename _Tp,
typename _It,
typename _St>
507 constexpr bool __noexcept_unpack_tuple_like_v<_Trait, _Tp, ranges::subrange<_It, _St>>
510 template<
template<
typename...>
class _Trait,
typename _Tp,
typename _It,
typename _St>
511 constexpr bool __noexcept_unpack_tuple_like_v<_Trait, _Tp, ranges::subrange<_It, _St>&>
514 template<
template<
typename...>
class _Trait,
typename _Tp,
typename _It,
typename _St>
515 constexpr bool __noexcept_unpack_tuple_like_v<_Trait, _Tp, const ranges::subrange<_It, _St>>
518 template<
template<
typename...>
class _Trait,
typename _Tp,
typename _It,
typename _St>
519 constexpr bool __noexcept_unpack_tuple_like_v<_Trait, _Tp, const ranges::subrange<_It, _St>&>
522#if __glibcxx_tuple_like
524 template<
typename _It,
typename _Sent, ranges::subrange_kind _Kind>
525 inline constexpr bool __is_tuple_like_v<ranges::subrange<_It, _Sent, _Kind>> =
true;
534 template<input_iterator _Iter, sentinel_for<_Iter> _Sent,
535 typename _Proj =
identity,
536 typename _Tp _GLIBCXX26_RANGE_ALGO_DEF_VAL_T(_Iter, _Proj)>
537 requires indirect_binary_predicate<ranges::equal_to,
539 [[nodiscard]]
constexpr _Iter
540 operator()(_Iter __first, _Sent __last,
541 const _Tp& __value, _Proj __proj = {})
const
543 if constexpr (is_same_v<_Proj, identity>)
544 if constexpr(__can_use_memchr_for_find<iter_value_t<_Iter>, _Tp>)
545 if constexpr (sized_sentinel_for<_Sent, _Iter>)
546 if constexpr (contiguous_iterator<_Iter>)
547 if (!is_constant_evaluated())
549 using _Vt = iter_value_t<_Iter>;
550 auto __n = __last - __first;
551 if (
static_cast<_Vt
>(__value) == __value) [[likely]]
554 const size_t __nu =
static_cast<size_t>(__n);
555 const int __ival =
static_cast<int>(__value);
557 if (
auto __p1 = __builtin_memchr(__p0, __ival, __nu))
558 __n = (
const char*)__p1 - (
const char*)__p0;
560 return __first + __n;
563 while (__first != __last
569 template<input_range _Range,
typename _Proj = identity,
571 _GLIBCXX26_RANGE_ALGO_DEF_VAL_T(iterator_t<_Range>, _Proj)>
572 requires indirect_binary_predicate<ranges::equal_to,
575 [[nodiscard]]
constexpr borrowed_iterator_t<_Range>
576 operator()(_Range&& __r,
const _Tp& __value, _Proj __proj = {})
const
578 return (*
this)(ranges::begin(__r), ranges::end(__r),
583 inline constexpr __find_fn find{};
587 template<input_iterator _Iter, sentinel_for<_Iter> _Sent,
588 typename _Proj =
identity,
589 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
590 [[nodiscard]]
constexpr _Iter
591 operator()(_Iter __first, _Sent __last,
592 _Pred __pred, _Proj __proj = {})
const
594 while (__first != __last
600 template<input_range _Range,
typename _Proj = identity,
601 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>>
603 [[nodiscard]]
constexpr borrowed_iterator_t<_Range>
604 operator()(_Range&& __r, _Pred __pred, _Proj __proj = {})
const
606 return (*
this)(ranges::begin(__r), ranges::end(__r),
611 inline constexpr __find_if_fn find_if{};
613 struct __find_if_not_fn
615 template<input_iterator _Iter, sentinel_for<_Iter> _Sent,
616 typename _Proj =
identity,
617 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
618 [[nodiscard]]
constexpr _Iter
619 operator()(_Iter __first, _Sent __last,
620 _Pred __pred, _Proj __proj = {})
const
622 while (__first != __last
628 template<input_range _Range,
typename _Proj = identity,
629 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>>
631 [[nodiscard]]
constexpr borrowed_iterator_t<_Range>
632 operator()(_Range&& __r, _Pred __pred, _Proj __proj = {})
const
634 return (*
this)(ranges::begin(__r), ranges::end(__r),
639 inline constexpr __find_if_not_fn find_if_not{};
641 template<
typename _Iter1,
typename _Iter2>
644 [[no_unique_address]] _Iter1 in1;
645 [[no_unique_address]] _Iter2 in2;
647 template<
typename _IIter1,
typename _IIter2>
648 requires convertible_to<const _Iter1&, _IIter1>
649 && convertible_to<const _Iter2&, _IIter2>
651 operator in_in_result<_IIter1, _IIter2>() const &
652 {
return {in1, in2}; }
654 template<
typename _IIter1,
typename _IIter2>
655 requires convertible_to<_Iter1, _IIter1>
656 && convertible_to<_Iter2, _IIter2>
658 operator in_in_result<_IIter1, _IIter2>() &&
662 template<
typename _Iter1,
typename _Iter2>
663 using mismatch_result = in_in_result<_Iter1, _Iter2>;
667 template<input_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
668 input_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
669 typename _Pred = ranges::equal_to,
670 typename _Proj1 =
identity,
typename _Proj2 =
identity>
671 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
672 [[nodiscard]]
constexpr mismatch_result<_Iter1, _Iter2>
673 operator()(_Iter1 __first1, _Sent1 __last1,
674 _Iter2 __first2, _Sent2 __last2, _Pred __pred = {},
675 _Proj1 __proj1 = {}, _Proj2 __proj2 = {})
const
677 while (__first1 != __last1 && __first2 != __last2
688 template<input_range _Range1, input_range _Range2,
689 typename _Pred = ranges::equal_to,
690 typename _Proj1 = identity,
typename _Proj2 = identity>
691 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>,
692 _Pred, _Proj1, _Proj2>
694 constexpr mismatch_result<borrowed_iterator_t<_Range1>,
695 borrowed_iterator_t<_Range2>>
696 operator()(_Range1&& __r1, _Range2&& __r2, _Pred __pred = {},
697 _Proj1 __proj1 = {}, _Proj2 __proj2 = {})
const
699 return (*
this)(ranges::begin(__r1), ranges::end(__r1),
700 ranges::begin(__r2), ranges::end(__r2),
706 inline constexpr __mismatch_fn mismatch{};
710 template<forward_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
711 forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
712 typename _Pred = ranges::equal_to,
713 typename _Proj1 =
identity,
typename _Proj2 =
identity>
714 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
715 [[nodiscard]]
constexpr subrange<_Iter1>
716 operator()(_Iter1 __first1, _Sent1 __last1,
717 _Iter2 __first2, _Sent2 __last2, _Pred __pred = {},
718 _Proj1 __proj1 = {}, _Proj2 __proj2 = {})
const
720 if (__first1 == __last1 || __first2 == __last2)
721 return {__first1, __first1};
727 if (__first1 == __last1)
728 return {__first1, __first1};
735 auto __cur1 = __first1;
736 auto __cur2 = __first2;
739 if (++__cur2 == __last2)
740 return {__first1, ++__cur1};
741 if (++__cur1 == __last1)
742 return {__cur1, __cur1};
754 template<forward_range _Range1, forward_range _Range2,
755 typename _Pred = ranges::equal_to,
756 typename _Proj1 = identity,
typename _Proj2 = identity>
757 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>,
758 _Pred, _Proj1, _Proj2>
759 [[nodiscard]]
constexpr borrowed_subrange_t<_Range1>
760 operator()(_Range1&& __r1, _Range2&& __r2, _Pred __pred = {},
761 _Proj1 __proj1 = {}, _Proj2 __proj2 = {})
const
763 return (*
this)(ranges::begin(__r1), ranges::end(__r1),
764 ranges::begin(__r2), ranges::end(__r2),
770 inline constexpr __search_fn search{};
774 template<
typename _Tp,
typename _Proj = identity,
775 indirect_strict_weak_order<projected<const _Tp*, _Proj>>
776 _Comp = ranges::less>
777 [[nodiscard]]
constexpr const _Tp&
778 operator()(
const _Tp& __a,
const _Tp& __b,
779 _Comp __comp = {}, _Proj __proj = {})
const
789 template<input_range _Range,
typename _Proj = identity,
790 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>>
791 _Comp = ranges::less>
792 requires indirectly_copyable_storable<iterator_t<_Range>,
793 range_value_t<_Range>*>
794 [[nodiscard]]
constexpr range_value_t<_Range>
795 operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {})
const
797 auto __first = ranges::begin(__r);
798 auto __last = ranges::end(__r);
799 __glibcxx_assert(__first != __last);
800 range_value_t<_Range> __result(*__first);
801 while (++__first != __last)
803 auto&& __tmp = *__first;
812 template<copyable _Tp,
typename _Proj = identity,
813 indirect_strict_weak_order<projected<const _Tp*, _Proj>>
814 _Comp = ranges::less>
815 [[nodiscard]]
constexpr _Tp
816 operator()(initializer_list<_Tp> __r,
817 _Comp __comp = {}, _Proj __proj = {})
const
819 return (*
this)(ranges::subrange(__r),
824 inline constexpr __min_fn min{};
826 struct __adjacent_find_fn
828 template<forward_iterator _Iter, sentinel_for<_Iter> _Sent,
829 typename _Proj =
identity,
830 indirect_binary_predicate<projected<_Iter, _Proj>,
831 projected<_Iter, _Proj>> _Pred
833 [[nodiscard]]
constexpr _Iter
834 operator()(_Iter __first, _Sent __last,
835 _Pred __pred = {}, _Proj __proj = {})
const
837 if (__first == __last)
839 auto __next = __first;
840 for (; ++__next != __last; __first = __next)
850 template<forward_range _Range,
typename _Proj = identity,
851 indirect_binary_predicate<
854 [[nodiscard]]
constexpr borrowed_iterator_t<_Range>
855 operator()(_Range&& __r, _Pred __pred = {}, _Proj __proj = {})
const
857 return (*
this)(ranges::begin(__r), ranges::end(__r),
862 inline constexpr __adjacent_find_fn adjacent_find{};
868 template<
typename _Iter,
typename _Sent, ranges::subrange_kind _Kind>
869 struct tuple_size<ranges::subrange<_Iter, _Sent, _Kind>>
873 template<
typename _Iter,
typename _Sent, ranges::subrange_kind _Kind>
874 struct tuple_element<0, ranges::subrange<_Iter, _Sent, _Kind>>
875 {
using type = _Iter; };
877 template<
typename _Iter,
typename _Sent, ranges::subrange_kind _Kind>
878 struct tuple_element<1, ranges::subrange<_Iter, _Sent, _Kind>>
879 {
using type = _Sent; };
881 template<
typename _Iter,
typename _Sent, ranges::subrange_kind _Kind>
882 struct tuple_element<0, const ranges::subrange<_Iter, _Sent, _Kind>>
883 {
using type = _Iter; };
885 template<
typename _Iter,
typename _Sent, ranges::subrange_kind _Kind>
886 struct tuple_element<1, const ranges::subrange<_Iter, _Sent, _Kind>>
887 {
using type = _Sent; };
889template<
typename _Tp,
typename _IndexType>
890 class _Repeat_iterator;
892 template<
typename _Tp,
typename _IndexType>
893 constexpr _Repeat_iterator<_Tp, _IndexType>
894 __make_repeat_iterator(_Tp&, _IndexType);
896 template<
typename _Tp,
typename _IndexType>
897 class _Repeat_iterator
902 if constexpr (__detail::__is_signed_integer_like<_IndexType>)
905 return ranges::__detail::__to_signed_like(_IndexType{});
908 _Tp* _M_value =
nullptr;
909 _IndexType _M_current = _IndexType();
912 _Repeat_iterator(
const _Tp* __value, _IndexType __bound = _IndexType())
913 : _M_value(__value), _M_current(__bound)
917 using iterator_concept = random_access_iterator_tag;
918 using iterator_category = random_access_iterator_tag;
919 using value_type = remove_cv_t<_Tp>;
920 using difference_type =
decltype(_S_difference_type());
922 _Repeat_iterator() =
default;
925 operator*() const noexcept
926 {
return *_M_value; }
928 constexpr _Repeat_iterator&
935 constexpr _Repeat_iterator
943 constexpr _Repeat_iterator&
946 __glibcxx_assert(_M_current > 0);
951 constexpr _Repeat_iterator
959 constexpr _Repeat_iterator&
960 operator+=(difference_type __n)
962 __glibcxx_assert(_M_current + __n >= 0);
967 constexpr _Repeat_iterator&
968 operator-=(difference_type __n)
970 __glibcxx_assert(_M_current - __n >= 0);
976 operator[](difference_type __n)
const noexcept
977 {
return *(*
this + __n); }
979 friend constexpr bool
980 operator==(
const _Repeat_iterator& __x,
const _Repeat_iterator& __y)
981 {
return __x._M_current == __y._M_current; }
983 friend constexpr auto
984 operator<=>(
const _Repeat_iterator& __x,
const _Repeat_iterator& __y)
985 {
return __x._M_current <=> __y._M_current; }
987 friend constexpr _Repeat_iterator
988 operator+(_Repeat_iterator __i, difference_type __n)
994 friend constexpr _Repeat_iterator
995 operator+(difference_type __n, _Repeat_iterator __i)
996 {
return __i + __n; }
998 friend constexpr _Repeat_iterator
999 operator-(_Repeat_iterator __i, difference_type __n)
1005 friend constexpr difference_type
1006 operator-(
const _Repeat_iterator& __x,
const _Repeat_iterator& __y)
1008 return (
static_cast<difference_type
>(__x._M_current)
1009 -
static_cast<difference_type
>(__y._M_current));
1012 friend constexpr _Repeat_iterator<_Tp, _IndexType>
1013 __make_repeat_iterator<_Tp, _IndexType>(_Tp&, _IndexType);
1016 template<
typename _Tp,
typename _IndexType>
1017 constexpr _Repeat_iterator<_Tp, _IndexType>
1018 __make_repeat_iterator(_Tp& __tp, _IndexType __bound)
1019 {
return _Repeat_iterator<_Tp, _IndexType>(
std::addressof(__tp), __bound); }
1021_GLIBCXX_END_NAMESPACE_VERSION
constexpr _Tp * to_address(_Tp *__ptr) noexcept
Obtain address referenced by a pointer to an object.
typename remove_pointer< _Tp >::type remove_pointer_t
Alias template for remove_pointer.
typename decay< _Tp >::type decay_t
Alias template for decay.
constexpr _Tp * addressof(_Tp &__r) noexcept
Returns the actual address of the object or function referenced by r, even in the presence of an over...
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr __invoke_result< _Callable, _Args... >::type __invoke(_Callable &&__fn, _Args &&... __args) noexcept(__is_nothrow_invocable< _Callable, _Args... >::value)
Invoke a callable object.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.
constexpr auto end(_Container &__cont) noexcept(noexcept(__cont.end())) -> decltype(__cont.end())
Return an iterator pointing to one past the last element of the container.
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
Return whether a container is empty.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
typename __detail::__projected< _Iter, _Proj >::__type projected
[projected], projected
constexpr auto begin(_Container &__cont) noexcept(noexcept(__cont.begin())) -> decltype(__cont.begin())
Return an iterator pointing to the first element of the container.
The ranges::view_interface class template.
The ranges::subrange class template.
Finds the size of a given tuple type.
Gives the type of the ith element of a given tuple type.
[concept.derived], concept derived_from
[concept.convertible], concept convertible_to
[concept.defaultinitializable], concept default_initializable
[range.range] The range concept.
[range.range] The borrowed_range concept.
[range.sized] The sized_range concept.
[range.view] The ranges::view concept.
A range for which ranges::begin returns an input iterator.
A range for which ranges::begin returns a forward iterator.
A range for which ranges::begin returns a bidirectional iterator.
A range for which ranges::begin and ranges::end return the same type.