30#ifndef _ITERATOR_CONCEPTS_H
31#define _ITERATOR_CONCEPTS_H 1
33#pragma GCC system_header
35#if __cplusplus >= 202002L
40namespace std _GLIBCXX_VISIBILITY(default)
42_GLIBCXX_BEGIN_NAMESPACE_VERSION
64 struct input_iterator_tag;
65 struct output_iterator_tag;
66 struct forward_iterator_tag;
67 struct bidirectional_iterator_tag;
68 struct random_access_iterator_tag;
69 struct contiguous_iterator_tag;
71 template<
typename _Iterator>
72 struct iterator_traits;
74 template<
typename _Tp>
requires is_object_v<_Tp>
75 struct iterator_traits<_Tp*>;
77 template<
typename _Iterator,
typename>
78 struct __iterator_traits;
82 template<
typename _Tp>
83 using __with_ref = _Tp&;
85 template<
typename _Tp>
86 concept __can_reference =
requires {
typename __with_ref<_Tp>; };
88 template<
typename _Tp>
89 concept __dereferenceable =
requires(_Tp& __t)
91 { *__t } -> __can_reference;
95 template<__detail::__dereferenceable _Tp>
96 using iter_reference_t =
decltype(*std::declval<_Tp&>());
100 namespace __cust_imove
104 template<
typename _Tp>
106 = (std::__detail::__class_or_enum<remove_reference_t<_Tp>>)
107 &&
requires(_Tp&& __t) { iter_move(
static_cast<_Tp&&
>(__t)); };
112 template<
typename _Tp>
114 {
using type = iter_reference_t<_Tp>; };
116 template<
typename _Tp>
117 requires __adl_imove<_Tp>
119 {
using type =
decltype(iter_move(std::declval<_Tp>())); };
121 template<
typename _Tp>
122 requires (!__adl_imove<_Tp>)
123 && is_lvalue_reference_v<iter_reference_t<_Tp>>
125 {
using type = remove_reference_t<iter_reference_t<_Tp>>&&; };
127 template<
typename _Tp>
128 static constexpr bool
131 if constexpr (__adl_imove<_Tp>)
132 return noexcept(iter_move(std::declval<_Tp>()));
134 return noexcept(*std::declval<_Tp>());
139 template<std::__detail::__dereferenceable _Tp>
140 using __type =
typename __result<_Tp>::type;
142 template<std::__detail::__dereferenceable _Tp>
144 constexpr __type<_Tp>
145 operator()(_Tp&& __e)
const
146 noexcept(_S_noexcept<_Tp>())
148 if constexpr (__adl_imove<_Tp>)
149 return iter_move(
static_cast<_Tp&&
>(__e));
150 else if constexpr (is_lvalue_reference_v<iter_reference_t<_Tp>>)
151 return static_cast<__type<_Tp>
>(*__e);
158 inline namespace __cust
160 inline constexpr __cust_imove::_IMove iter_move{};
164 template<__detail::__dereferenceable _Tp>
166 __can_reference<ranges::__cust_imove::_IMove::__type<_Tp&>>
167 using iter_rvalue_reference_t
168 = ranges::__cust_imove::_IMove::__type<_Tp&>;
170 template<
typename>
struct incrementable_traits { };
172 template<
typename _Tp>
requires is_object_v<_Tp>
173 struct incrementable_traits<_Tp*>
174 {
using difference_type = ptrdiff_t; };
176 template<
typename _Iter>
177 struct incrementable_traits<const _Iter>
178 : incrementable_traits<_Iter> { };
180 template<
typename _Tp>
requires requires {
typename _Tp::difference_type; }
181 struct incrementable_traits<_Tp>
182 {
using difference_type =
typename _Tp::difference_type; };
184 template<
typename _Tp>
185 requires (!
requires {
typename _Tp::difference_type; }
186 &&
requires(
const _Tp& __a,
const _Tp& __b)
187 { { __a - __b } -> integral; })
188 struct incrementable_traits<_Tp>
190 using difference_type
191 = make_signed_t<decltype(std::declval<_Tp>() - std::declval<_Tp>())>;
194#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
197 struct incrementable_traits<__int128>
198 {
using difference_type = __int128; };
201 struct incrementable_traits<unsigned __int128>
202 {
using difference_type = __int128; };
209 template<
typename _Iter>
210 concept __primary_traits_iter
211 = __is_base_of(__iterator_traits<_Iter, void>, iterator_traits<_Iter>);
213 template<
typename _Iter,
typename _Tp>
214 struct __iter_traits_impl
215 {
using type = iterator_traits<_Iter>; };
217 template<
typename _Iter,
typename _Tp>
218 requires __primary_traits_iter<_Iter>
219 struct __iter_traits_impl<_Iter, _Tp>
220 {
using type = _Tp; };
223 template<
typename _Iter,
typename _Tp = _Iter>
224 using __iter_traits =
typename __iter_traits_impl<_Iter, _Tp>::type;
226 template<
typename _Tp>
227 using __iter_diff_t =
typename
228 __iter_traits<_Tp, incrementable_traits<_Tp>>::difference_type;
231 template<
typename _Tp>
232 using iter_difference_t = __detail::__iter_diff_t<remove_cvref_t<_Tp>>;
236 template<
typename>
struct __cond_value_type { };
238 template<
typename _Tp>
requires is_object_v<_Tp>
239 struct __cond_value_type<_Tp>
240 {
using value_type = remove_cv_t<_Tp>; };
242 template<
typename _Tp>
243 concept __has_member_value_type
244 =
requires {
typename _Tp::value_type; };
246 template<
typename _Tp>
247 concept __has_member_element_type
248 =
requires {
typename _Tp::element_type; };
252 template<
typename>
struct indirectly_readable_traits { };
254 template<
typename _Tp>
255 struct indirectly_readable_traits<_Tp*>
256 : __detail::__cond_value_type<_Tp>
259 template<
typename _Iter>
requires is_array_v<_Iter>
260 struct indirectly_readable_traits<_Iter>
261 {
using value_type = remove_cv_t<remove_extent_t<_Iter>>; };
263 template<
typename _Iter>
264 struct indirectly_readable_traits<const _Iter>
265 : indirectly_readable_traits<_Iter>
268 template<__detail::__has_member_value_type _Tp>
269 struct indirectly_readable_traits<_Tp>
270 : __detail::__cond_value_type<typename _Tp::value_type>
273 template<__detail::__has_member_element_type _Tp>
274 struct indirectly_readable_traits<_Tp>
275 : __detail::__cond_value_type<typename _Tp::element_type>
280 template<__detail::__has_member_value_type _Tp>
281 requires __detail::__has_member_element_type<_Tp>
282 && same_as<remove_cv_t<typename _Tp::element_type>,
283 remove_cv_t<typename _Tp::value_type>>
284 struct indirectly_readable_traits<_Tp>
285 : __detail::__cond_value_type<typename _Tp::value_type>
290 template<__detail::__has_member_value_type _Tp>
291 requires __detail::__has_member_element_type<_Tp>
292 struct indirectly_readable_traits<_Tp>
297 template<
typename _Tp>
298 using __iter_value_t =
typename
299 __iter_traits<_Tp, indirectly_readable_traits<_Tp>>::value_type;
302 template<
typename _Tp>
303 using iter_value_t = __detail::__iter_value_t<remove_cvref_t<_Tp>>;
309 template<
typename _Iter>
310 concept __cpp17_iterator =
requires(_Iter __it)
312 { *__it } -> __can_reference;
313 { ++__it } -> same_as<_Iter&>;
314 { *__it++ } -> __can_reference;
315 } && copyable<_Iter>;
317 template<
typename _Iter>
318 concept __cpp17_input_iterator = __cpp17_iterator<_Iter>
319 && equality_comparable<_Iter>
320 &&
requires(_Iter __it)
322 typename incrementable_traits<_Iter>::difference_type;
323 typename indirectly_readable_traits<_Iter>::value_type;
324 typename common_reference_t<iter_reference_t<_Iter>&&,
325 typename indirectly_readable_traits<_Iter>::value_type&>;
326 typename common_reference_t<
decltype(*__it++)&&,
327 typename indirectly_readable_traits<_Iter>::value_type&>;
328 requires signed_integral<
329 typename incrementable_traits<_Iter>::difference_type>;
332 template<
typename _Iter>
333 concept __cpp17_fwd_iterator = __cpp17_input_iterator<_Iter>
334 && constructible_from<_Iter>
335 && is_lvalue_reference_v<iter_reference_t<_Iter>>
336 && same_as<remove_cvref_t<iter_reference_t<_Iter>>,
337 typename indirectly_readable_traits<_Iter>::value_type>
338 &&
requires(_Iter __it)
340 { __it++ } -> convertible_to<const _Iter&>;
341 { *__it++ } -> same_as<iter_reference_t<_Iter>>;
344 template<
typename _Iter>
345 concept __cpp17_bidi_iterator = __cpp17_fwd_iterator<_Iter>
346 &&
requires(_Iter __it)
348 { --__it } -> same_as<_Iter&>;
349 { __it-- } -> convertible_to<const _Iter&>;
350 { *__it-- } -> same_as<iter_reference_t<_Iter>>;
353 template<
typename _Iter>
354 concept __cpp17_randacc_iterator = __cpp17_bidi_iterator<_Iter>
355 && totally_ordered<_Iter>
356 &&
requires(_Iter __it,
357 typename incrementable_traits<_Iter>::difference_type __n)
359 { __it += __n } -> same_as<_Iter&>;
360 { __it -= __n } -> same_as<_Iter&>;
361 { __it + __n } -> same_as<_Iter>;
362 { __n + __it } -> same_as<_Iter>;
363 { __it - __n } -> same_as<_Iter>;
364 { __it - __it } -> same_as<
decltype(__n)>;
365 { __it[__n] } -> convertible_to<iter_reference_t<_Iter>>;
368 template<
typename _Iter>
369 concept __iter_with_nested_types =
requires {
370 typename _Iter::iterator_category;
371 typename _Iter::value_type;
372 typename _Iter::difference_type;
373 typename _Iter::reference;
376 template<
typename _Iter>
377 concept __iter_without_nested_types = !__iter_with_nested_types<_Iter>;
379 template<
typename _Iter>
380 concept __iter_without_category
381 = !
requires {
typename _Iter::iterator_category; };
385 template<
typename _Iterator>
386 requires __detail::__iter_with_nested_types<_Iterator>
387 struct __iterator_traits<_Iterator, void>
390 template<
typename _Iter>
392 {
using type = void; };
394 template<
typename _Iter>
requires requires {
typename _Iter::pointer; }
396 {
using type =
typename _Iter::pointer; };
399 using iterator_category =
typename _Iterator::iterator_category;
400 using value_type =
typename _Iterator::value_type;
401 using difference_type =
typename _Iterator::difference_type;
402 using pointer =
typename __ptr<_Iterator>::type;
403 using reference =
typename _Iterator::reference;
406 template<
typename _Iterator>
407 requires __detail::__iter_without_nested_types<_Iterator>
408 && __detail::__cpp17_input_iterator<_Iterator>
409 struct __iterator_traits<_Iterator, void>
412 template<
typename _Iter>
414 {
using type = input_iterator_tag; };
416 template<
typename _Iter>
417 requires requires {
typename _Iter::iterator_category; }
419 {
using type =
typename _Iter::iterator_category; };
421 template<
typename _Iter>
422 requires __detail::__iter_without_category<_Iter>
423 && __detail::__cpp17_randacc_iterator<_Iter>
425 {
using type = random_access_iterator_tag; };
427 template<
typename _Iter>
428 requires __detail::__iter_without_category<_Iter>
429 && __detail::__cpp17_bidi_iterator<_Iter>
431 {
using type = bidirectional_iterator_tag; };
433 template<
typename _Iter>
434 requires __detail::__iter_without_category<_Iter>
435 && __detail::__cpp17_fwd_iterator<_Iter>
437 {
using type = forward_iterator_tag; };
439 template<
typename _Iter>
441 {
using type = void; };
443 template<
typename _Iter>
requires requires {
typename _Iter::pointer; }
445 {
using type =
typename _Iter::pointer; };
447 template<
typename _Iter>
448 requires (!
requires {
typename _Iter::pointer; }
449 &&
requires(_Iter& __it) { __it.operator->(); })
451 {
using type =
decltype(std::declval<_Iter&>().operator->()); };
453 template<
typename _Iter>
455 {
using type = iter_reference_t<_Iter>; };
457 template<
typename _Iter>
requires requires {
typename _Iter::reference; }
459 {
using type =
typename _Iter::reference; };
462 using iterator_category =
typename __cat<_Iterator>::type;
464 =
typename indirectly_readable_traits<_Iterator>::value_type;
465 using difference_type
466 =
typename incrementable_traits<_Iterator>::difference_type;
467 using pointer =
typename __ptr<_Iterator>::type;
468 using reference =
typename __ref<_Iterator>::type;
471 template<
typename _Iterator>
472 requires __detail::__iter_without_nested_types<_Iterator>
473 && __detail::__cpp17_iterator<_Iterator>
474 struct __iterator_traits<_Iterator, void>
477 template<
typename _Iter>
479 {
using type = void; };
481 template<
typename _Iter>
483 {
typename incrementable_traits<_Iter>::difference_type; }
486 using type =
typename incrementable_traits<_Iter>::difference_type;
490 using iterator_category = output_iterator_tag;
491 using value_type = void;
492 using difference_type =
typename __diff<_Iterator>::type;
493 using pointer = void;
494 using reference = void;
499 template<
typename _Iter>
500 struct __iter_concept_impl;
503 template<
typename _Iter>
504 requires requires {
typename __iter_traits<_Iter>::iterator_concept; }
505 struct __iter_concept_impl<_Iter>
506 {
using type =
typename __iter_traits<_Iter>::iterator_concept; };
509 template<
typename _Iter>
510 requires (!
requires {
typename __iter_traits<_Iter>::iterator_concept; }
511 &&
requires {
typename __iter_traits<_Iter>::iterator_category; })
512 struct __iter_concept_impl<_Iter>
513 {
using type =
typename __iter_traits<_Iter>::iterator_category; };
516 template<
typename _Iter>
517 requires (!
requires {
typename __iter_traits<_Iter>::iterator_concept; }
518 && !
requires {
typename __iter_traits<_Iter>::iterator_category; }
519 && __primary_traits_iter<_Iter>)
520 struct __iter_concept_impl<_Iter>
521 {
using type = random_access_iterator_tag; };
524 template<
typename _Iter>
525 struct __iter_concept_impl
529 template<
typename _Iter>
530 using __iter_concept =
typename __iter_concept_impl<_Iter>::type;
532 template<
typename _In>
533 concept __indirectly_readable_impl =
requires
535 typename iter_value_t<_In>;
536 typename iter_reference_t<_In>;
537 typename iter_rvalue_reference_t<_In>;
538 requires same_as<iter_reference_t<const _In>,
539 iter_reference_t<_In>>;
540 requires same_as<iter_rvalue_reference_t<const _In>,
541 iter_rvalue_reference_t<_In>>;
543 && common_reference_with<iter_reference_t<_In>&&, iter_value_t<_In>&>
544 && common_reference_with<iter_reference_t<_In>&&,
545 iter_rvalue_reference_t<_In>&&>
546 && common_reference_with<iter_rvalue_reference_t<_In>&&,
547 const iter_value_t<_In>&>;
552 template<
typename _In>
554 = __detail::__indirectly_readable_impl<remove_cvref_t<_In>>;
556 template<indirectly_readable _Tp>
557 using iter_common_reference_t
558 = common_reference_t<iter_reference_t<_Tp>, iter_value_t<_Tp>&>;
561 template<
typename _Out,
typename _Tp>
564 *__o = std::forward<_Tp>(__t);
565 *std::forward<_Out>(__o) = std::forward<_Tp>(__t);
566 const_cast<const iter_reference_t<_Out>&&
>(*__o)
567 = std::forward<_Tp>(__t);
568 const_cast<const iter_reference_t<_Out>&&
>(*std::forward<_Out>(__o))
569 = std::forward<_Tp>(__t);
572 namespace ranges::__detail
574 class __max_diff_type;
575 class __max_size_type;
578 template<
typename _Tp>
579 concept __is_signed_int128
587 template<
typename _Tp>
588 concept __is_unsigned_int128
595 template<
typename _Tp>
598 template<
typename _Tp>
599 concept __integral_nonbool = integral<_Tp> && !__cv_bool<_Tp>;
601 template<
typename _Tp>
602 concept __is_int128 = __is_signed_int128<_Tp> || __is_unsigned_int128<_Tp>;
604 template<
typename _Tp>
605 concept __is_integer_like = __integral_nonbool<_Tp>
609 template<
typename _Tp>
610 concept __is_signed_integer_like = signed_integral<_Tp>
611 || __is_signed_int128<_Tp>
616 namespace __detail {
using ranges::__detail::__is_signed_integer_like; }
619 template<
typename _Iter>
621 &&
requires(_Iter __i)
623 typename iter_difference_t<_Iter>;
624 requires __detail::__is_signed_integer_like<iter_difference_t<_Iter>>;
629 template<
typename _Iter>
631 &&
requires(_Iter __i) { { __i++ } -> same_as<_Iter>; };
633 template<
typename _Iter>
634 concept input_or_output_iterator
635 =
requires(_Iter __i) { { *__i } -> __detail::__can_reference; }
636 && weakly_incrementable<_Iter>;
638 template<
typename _Sent,
typename _Iter>
639 concept sentinel_for = semiregular<_Sent>
640 && input_or_output_iterator<_Iter>
641 && __detail::__weakly_eq_cmp_with<_Sent, _Iter>;
643 template<
typename _Sent,
typename _Iter>
644 inline constexpr bool disable_sized_sentinel_for =
false;
646 template<
typename _Sent,
typename _Iter>
647 concept sized_sentinel_for = sentinel_for<_Sent, _Iter>
648 && !disable_sized_sentinel_for<remove_cv_t<_Sent>, remove_cv_t<_Iter>>
649 &&
requires(
const _Iter& __i,
const _Sent& __s)
651 { __s - __i } -> same_as<iter_difference_t<_Iter>>;
652 { __i - __s } -> same_as<iter_difference_t<_Iter>>;
655 template<
typename _Iter>
656 concept input_iterator = input_or_output_iterator<_Iter>
657 && indirectly_readable<_Iter>
658 &&
requires {
typename __detail::__iter_concept<_Iter>; }
659 && derived_from<__detail::__iter_concept<_Iter>, input_iterator_tag>;
661 template<
typename _Iter,
typename _Tp>
662 concept output_iterator = input_or_output_iterator<_Iter>
663 && indirectly_writable<_Iter, _Tp>
664 &&
requires(_Iter __i, _Tp&& __t) { *__i++ = std::forward<_Tp>(__t); };
666 template<
typename _Iter>
667 concept forward_iterator = input_iterator<_Iter>
668 && derived_from<__detail::__iter_concept<_Iter>, forward_iterator_tag>
669 && incrementable<_Iter> && sentinel_for<_Iter, _Iter>;
671 template<
typename _Iter>
672 concept bidirectional_iterator = forward_iterator<_Iter>
673 && derived_from<__detail::__iter_concept<_Iter>,
674 bidirectional_iterator_tag>
675 &&
requires(_Iter __i)
677 { --__i } -> same_as<_Iter&>;
678 { __i-- } -> same_as<_Iter>;
681 template<
typename _Iter>
682 concept random_access_iterator = bidirectional_iterator<_Iter>
683 && derived_from<__detail::__iter_concept<_Iter>,
684 random_access_iterator_tag>
685 && totally_ordered<_Iter> && sized_sentinel_for<_Iter, _Iter>
686 &&
requires(_Iter __i,
const _Iter __j,
687 const iter_difference_t<_Iter> __n)
689 { __i += __n } -> same_as<_Iter&>;
690 { __j + __n } -> same_as<_Iter>;
691 { __n + __j } -> same_as<_Iter>;
692 { __i -= __n } -> same_as<_Iter&>;
693 { __j - __n } -> same_as<_Iter>;
694 { __j[__n] } -> same_as<iter_reference_t<_Iter>>;
697 template<
typename _Iter>
698 concept contiguous_iterator = random_access_iterator<_Iter>
699 && derived_from<__detail::__iter_concept<_Iter>, contiguous_iterator_tag>
700 && is_lvalue_reference_v<iter_reference_t<_Iter>>
701 && same_as<iter_value_t<_Iter>, remove_cvref_t<iter_reference_t<_Iter>>>
702 &&
requires(
const _Iter& __i)
705 -> same_as<add_pointer_t<iter_reference_t<_Iter>>>;
712 template<
typename _Fn,
typename _Iter>
713 concept indirectly_unary_invocable = indirectly_readable<_Iter>
714 && copy_constructible<_Fn> && invocable<_Fn&, iter_value_t<_Iter>&>
715 && invocable<_Fn&, iter_reference_t<_Iter>>
716 && invocable<_Fn&, iter_common_reference_t<_Iter>>
717 && common_reference_with<invoke_result_t<_Fn&, iter_value_t<_Iter>&>,
718 invoke_result_t<_Fn&, iter_reference_t<_Iter>>>;
720 template<
typename _Fn,
typename _Iter>
721 concept indirectly_regular_unary_invocable = indirectly_readable<_Iter>
722 && copy_constructible<_Fn>
723 && regular_invocable<_Fn&, iter_value_t<_Iter>&>
724 && regular_invocable<_Fn&, iter_reference_t<_Iter>>
725 && regular_invocable<_Fn&, iter_common_reference_t<_Iter>>
726 && common_reference_with<invoke_result_t<_Fn&, iter_value_t<_Iter>&>,
727 invoke_result_t<_Fn&, iter_reference_t<_Iter>>>;
729 template<
typename _Fn,
typename _Iter>
730 concept indirect_unary_predicate = indirectly_readable<_Iter>
731 && copy_constructible<_Fn> && predicate<_Fn&, iter_value_t<_Iter>&>
732 && predicate<_Fn&, iter_reference_t<_Iter>>
733 && predicate<_Fn&, iter_common_reference_t<_Iter>>;
735 template<
typename _Fn,
typename _I1,
typename _I2>
736 concept indirect_binary_predicate
737 = indirectly_readable<_I1> && indirectly_readable<_I2>
738 && copy_constructible<_Fn>
739 && predicate<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&>
740 && predicate<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>>
741 && predicate<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&>
742 && predicate<_Fn&, iter_reference_t<_I1>, iter_reference_t<_I2>>
743 && predicate<_Fn&, iter_common_reference_t<_I1>,
744 iter_common_reference_t<_I2>>;
746 template<
typename _Fn,
typename _I1,
typename _I2 = _I1>
747 concept indirect_equivalence_relation
748 = indirectly_readable<_I1> && indirectly_readable<_I2>
749 && copy_constructible<_Fn>
750 && equivalence_relation<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&>
751 && equivalence_relation<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>>
752 && equivalence_relation<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&>
753 && equivalence_relation<_Fn&, iter_reference_t<_I1>,
754 iter_reference_t<_I2>>
755 && equivalence_relation<_Fn&, iter_common_reference_t<_I1>,
756 iter_common_reference_t<_I2>>;
758 template<
typename _Fn,
typename _I1,
typename _I2 = _I1>
759 concept indirect_strict_weak_order
760 = indirectly_readable<_I1> && indirectly_readable<_I2>
761 && copy_constructible<_Fn>
762 && strict_weak_order<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&>
763 && strict_weak_order<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>>
764 && strict_weak_order<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&>
765 && strict_weak_order<_Fn&, iter_reference_t<_I1>, iter_reference_t<_I2>>
766 && strict_weak_order<_Fn&, iter_common_reference_t<_I1>,
767 iter_common_reference_t<_I2>>;
769 template<
typename _Fn,
typename... _Is>
770 requires (indirectly_readable<_Is> && ...)
771 && invocable<_Fn, iter_reference_t<_Is>...>
772 using indirect_result_t = invoke_result_t<_Fn, iter_reference_t<_Is>...>;
775 template<indirectly_readable _Iter,
776 indirectly_regular_unary_invocable<_Iter> _Proj>
781 indirect_result_t<_Proj&, _Iter> operator*()
const;
784 template<weakly_incrementable _Iter,
typename _Proj>
785 struct incrementable_traits<
projected<_Iter, _Proj>>
786 {
using difference_type = iter_difference_t<_Iter>; };
792 template<
typename _In,
typename _Out>
796 template<
typename _In,
typename _Out>
799 && movable<iter_value_t<_In>>
804 template<
typename _In,
typename _Out>
808 template<
typename _In,
typename _Out>
814 && copyable<iter_value_t<_In>>
820 namespace __cust_iswap
822 template<
typename _It1,
typename _It2>
823 void iter_swap(_It1, _It2) =
delete;
825 template<
typename _Tp,
typename _Up>
827 = (std::__detail::__class_or_enum<remove_reference_t<_Tp>>
828 || std::__detail::__class_or_enum<remove_reference_t<_Up>>)
829 &&
requires(_Tp&& __t, _Up&& __u) {
830 iter_swap(
static_cast<_Tp&&
>(__t),
static_cast<_Up&&
>(__u));
833 template<
typename _Xp,
typename _Yp>
834 constexpr iter_value_t<_Xp>
835 __iter_exchange_move(_Xp&& __x, _Yp&& __y)
836 noexcept(
noexcept(iter_value_t<_Xp>(iter_move(__x)))
837 &&
noexcept(*__x = iter_move(__y)))
839 iter_value_t<_Xp> __old_value(iter_move(__x));
840 *__x = iter_move(__y);
847 template<
typename _Tp,
typename _Up>
848 static constexpr bool
851 if constexpr (__adl_iswap<_Tp, _Up>)
852 return noexcept(iter_swap(std::declval<_Tp>(),
853 std::declval<_Up>()));
856 && swappable_with<iter_reference_t<_Tp>, iter_reference_t<_Up>>)
857 return noexcept(ranges::swap(*std::declval<_Tp>(),
858 *std::declval<_Up>()));
860 return noexcept(*std::declval<_Tp>()
861 = __iter_exchange_move(std::declval<_Up>(),
862 std::declval<_Tp>()));
866 template<
typename _Tp,
typename _Up>
867 requires __adl_iswap<_Tp, _Up>
870 && swappable_with<iter_reference_t<_Tp>, iter_reference_t<_Up>>)
871 || (indirectly_movable_storable<_Tp, _Up>
872 && indirectly_movable_storable<_Up, _Tp>)
874 operator()(_Tp&& __e1, _Up&& __e2)
const
875 noexcept(_S_noexcept<_Tp, _Up>())
877 if constexpr (__adl_iswap<_Tp, _Up>)
878 iter_swap(
static_cast<_Tp&&
>(__e1),
static_cast<_Up&&
>(__e2));
881 && swappable_with<iter_reference_t<_Tp>, iter_reference_t<_Up>>)
882 ranges::swap(*__e1, *__e2);
884 *__e1 = __iter_exchange_move(__e2, __e1);
889 inline namespace __cust
891 inline constexpr __cust_iswap::_IterSwap iter_swap{};
897 template<
typename _I1,
typename _I2 = _I1>
900 &&
requires(
const _I1 __i1,
const _I2 __i2)
902 ranges::iter_swap(__i1, __i1);
903 ranges::iter_swap(__i2, __i2);
904 ranges::iter_swap(__i1, __i2);
905 ranges::iter_swap(__i2, __i1);
909 template<
typename _I1,
typename _I2,
typename _Rel,
typename _P1 =
identity,
910 typename _P2 = identity>
912 = indirect_binary_predicate<_Rel, projected<_I1, _P1>,
913 projected<_I2, _P2>>;
916 template<
typename _Iter>
918 && indirectly_movable_storable<_Iter, _Iter>
922 template<
typename _I1,
typename _I2,
typename _Out,
923 typename _Rel = ranges::less,
typename _P1 = identity,
924 typename _P2 = identity>
925 concept mergeable = input_iterator<_I1> && input_iterator<_I2>
928 && indirect_strict_weak_order<_Rel, projected<_I1, _P1>,
929 projected<_I2, _P2>>;
932 template<
typename _Iter,
typename _Rel = ranges::less,
933 typename _Proj = identity>
935 && indirect_strict_weak_order<_Rel, projected<_Iter, _Proj>>;
937 struct unreachable_sentinel_t
939 template<weakly_incrementable _It>
940 friend constexpr bool
941 operator==(unreachable_sentinel_t,
const _It&)
noexcept
945 inline constexpr unreachable_sentinel_t unreachable_sentinel{};
948 namespace ranges::__cust_access
950 using std::__detail::__class_or_enum;
952 struct _Decay_copy final
954 template<
typename _Tp>
955 constexpr decay_t<_Tp>
956 operator()(_Tp&& __t)
const
957 noexcept(is_nothrow_convertible_v<_Tp, decay_t<_Tp>>)
958 {
return std::forward<_Tp>(__t); }
959 }
inline constexpr __decay_copy{};
961 template<
typename _Tp>
962 concept __member_begin =
requires(_Tp& __t)
964 { __decay_copy(__t.begin()) } -> input_or_output_iterator;
968 void begin(
auto&) =
delete;
969 void begin(
const auto&) =
delete;
971 template<
typename _Tp>
972 concept __adl_begin = __class_or_enum<remove_reference_t<_Tp>>
973 &&
requires(_Tp& __t)
975 { __decay_copy(begin(__t)) } -> input_or_output_iterator;
980 template<
typename _Tp>
981 requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
985 if constexpr (is_array_v<_Tp>)
987 else if constexpr (__member_begin<_Tp&>)
997 template<
typename _Tp>
999 =
decltype(ranges::__cust_access::__begin(std::declval<_Tp&>()));
1004_GLIBCXX_END_NAMESPACE_VERSION
constexpr _Tp * to_address(_Tp *__ptr) noexcept
Obtain address referenced by a pointer to an object.
typename remove_cvref< _Tp >::type remove_cvref_t
ISO C++ entities toplevel namespace is std.
constexpr default_sentinel_t default_sentinel
A default sentinel value.
[func.identity] The identity function.
[concept.same], concept same_as
[concept.assignable], concept assignable_from
[concept.constructible], concept constructible_from
Requirements for types that are readable by applying operator*.
Requirements for writing a value into an iterator's referenced object.
Requirements on types that can be incremented with ++.
[alg.req.ind.move], concept indirectly_movable
[alg.req.ind.copy], concept indirectly_copyable
[alg.req.ind.swap], concept indirectly_swappable
[alg.req.ind.cmp], concept indirectly_comparable
[alg.req.permutable], concept permutable
[alg.req.mergeable], concept mergeable
[alg.req.sortable], concept sortable