30 #ifndef _ITERATOR_CONCEPTS_H
31 #define _ITERATOR_CONCEPTS_H 1
33 #pragma GCC system_header
39 #if __cpp_lib_concepts
40 namespace std _GLIBCXX_VISIBILITY(default)
42 _GLIBCXX_BEGIN_NAMESPACE_VERSION
44 struct input_iterator_tag;
45 struct output_iterator_tag;
46 struct forward_iterator_tag;
47 struct bidirectional_iterator_tag;
48 struct random_access_iterator_tag;
49 struct contiguous_iterator_tag;
51 template<
typename _Iterator>
52 struct iterator_traits;
54 template<
typename _Tp> requires is_object_v<_Tp>
55 struct iterator_traits<_Tp*>;
57 template<
typename _Iterator,
typename>
58 struct __iterator_traits;
62 template<
typename _Tp>
63 using __with_ref = _Tp&;
65 template<
typename _Tp>
66 concept __can_reference = requires {
typename __with_ref<_Tp>; };
68 template<
typename _Tp>
69 concept __dereferenceable = requires(_Tp& __t)
71 { *__t } -> __can_reference;
75 template<__detail::__dereferenceable _Tp>
76 using iter_reference_t = decltype(*std::declval<_Tp&>());
80 namespace __cust_imove
84 template<
typename _Tp>
86 = (std::__detail::__class_or_enum<remove_reference_t<_Tp>>)
87 && requires(_Tp&& __t) { iter_move(
static_cast<_Tp&&
>(__t)); };
92 template<
typename _Tp>
94 {
using type = iter_reference_t<_Tp>; };
96 template<
typename _Tp>
97 requires __adl_imove<_Tp>
99 {
using type = decltype(iter_move(std::declval<_Tp>())); };
101 template<
typename _Tp>
102 requires (!__adl_imove<_Tp>)
103 && is_lvalue_reference_v<iter_reference_t<_Tp>>
105 {
using type = remove_reference_t<iter_reference_t<_Tp>>&&; };
107 template<
typename _Tp>
108 static constexpr
bool
111 if constexpr (__adl_imove<_Tp>)
112 return noexcept(iter_move(std::declval<_Tp>()));
114 return noexcept(*std::declval<_Tp>());
119 template<std::__detail::__dereferenceable _Tp>
120 using __type =
typename __result<_Tp>::type;
122 template<std::__detail::__dereferenceable _Tp>
124 constexpr __type<_Tp>
125 operator()(_Tp&& __e)
const
126 noexcept(_S_noexcept<_Tp>())
128 if constexpr (__adl_imove<_Tp>)
129 return iter_move(
static_cast<_Tp&&
>(__e));
130 else if constexpr (is_lvalue_reference_v<iter_reference_t<_Tp>>)
131 return static_cast<__type<_Tp>>(*__e);
138 inline namespace __cust
140 inline constexpr __cust_imove::_IMove iter_move{};
144 template<__detail::__dereferenceable _Tp>
146 __can_reference<ranges::__cust_imove::_IMove::__type<_Tp&>>
147 using iter_rvalue_reference_t
148 = ranges::__cust_imove::_IMove::__type<_Tp&>;
150 template<
typename>
struct incrementable_traits { };
152 template<
typename _Tp> requires is_object_v<_Tp>
153 struct incrementable_traits<_Tp*>
154 {
using difference_type = ptrdiff_t; };
156 template<
typename _Iter>
157 struct incrementable_traits<const _Iter>
158 : incrementable_traits<_Iter> { };
160 template<
typename _Tp> requires requires {
typename _Tp::difference_type; }
161 struct incrementable_traits<_Tp>
162 {
using difference_type =
typename _Tp::difference_type; };
164 template<
typename _Tp>
165 requires (!requires {
typename _Tp::difference_type; }
166 && requires(
const _Tp& __a,
const _Tp& __b)
167 { { __a - __b } -> integral; })
168 struct incrementable_traits<_Tp>
170 using difference_type
171 = make_signed_t<decltype(std::declval<_Tp>() - std::declval<_Tp>())>;
174 #if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
177 struct incrementable_traits<__int128>
178 {
using difference_type = __int128; };
181 struct incrementable_traits<unsigned __int128>
182 {
using difference_type = __int128; };
189 template<
typename _Iter>
190 concept __primary_traits_iter
191 = __is_base_of(__iterator_traits<_Iter, void>, iterator_traits<_Iter>);
193 template<
typename _Iter,
typename _Tp>
194 struct __iter_traits_impl
195 {
using type = iterator_traits<_Iter>; };
197 template<
typename _Iter,
typename _Tp>
198 requires __primary_traits_iter<_Iter>
199 struct __iter_traits_impl<_Iter, _Tp>
200 {
using type = _Tp; };
203 template<
typename _Iter,
typename _Tp = _Iter>
204 using __iter_traits =
typename __iter_traits_impl<_Iter, _Tp>::type;
206 template<
typename _Tp>
207 using __iter_diff_t =
typename
208 __iter_traits<_Tp, incrementable_traits<_Tp>>::difference_type;
211 template<
typename _Tp>
212 using iter_difference_t = __detail::__iter_diff_t<remove_cvref_t<_Tp>>;
216 template<
typename>
struct __cond_value_type { };
218 template<
typename _Tp> requires is_object_v<_Tp>
219 struct __cond_value_type<_Tp>
220 {
using value_type = remove_cv_t<_Tp>; };
222 template<
typename _Tp>
223 concept __has_member_value_type
224 = requires {
typename _Tp::value_type; };
226 template<
typename _Tp>
227 concept __has_member_element_type
228 = requires {
typename _Tp::element_type; };
232 template<
typename>
struct indirectly_readable_traits { };
234 template<
typename _Tp>
235 struct indirectly_readable_traits<_Tp*>
236 : __detail::__cond_value_type<_Tp>
239 template<
typename _Iter> requires is_array_v<_Iter>
240 struct indirectly_readable_traits<_Iter>
241 {
using value_type = remove_cv_t<remove_extent_t<_Iter>>; };
243 template<
typename _Iter>
244 struct indirectly_readable_traits<const _Iter>
245 : indirectly_readable_traits<_Iter>
248 template<__detail::__has_member_value_type _Tp>
249 struct indirectly_readable_traits<_Tp>
250 : __detail::__cond_value_type<typename _Tp::value_type>
253 template<__detail::__has_member_element_type _Tp>
254 struct indirectly_readable_traits<_Tp>
255 : __detail::__cond_value_type<typename _Tp::element_type>
260 template<__detail::__has_member_value_type _Tp>
261 requires __detail::__has_member_element_type<_Tp>
262 && same_as<remove_cv_t<typename _Tp::element_type>,
263 remove_cv_t<typename _Tp::value_type>>
264 struct indirectly_readable_traits<_Tp>
265 : __detail::__cond_value_type<typename _Tp::value_type>
270 template<__detail::__has_member_value_type _Tp>
271 requires __detail::__has_member_element_type<_Tp>
272 struct indirectly_readable_traits<_Tp>
277 template<
typename _Tp>
278 using __iter_value_t =
typename
279 __iter_traits<_Tp, indirectly_readable_traits<_Tp>>::value_type;
282 template<
typename _Tp>
283 using iter_value_t = __detail::__iter_value_t<remove_cvref_t<_Tp>>;
289 template<
typename _Iter>
290 concept __cpp17_iterator = requires(_Iter __it)
292 { *__it } -> __can_reference;
293 { ++__it } -> same_as<_Iter&>;
294 { *__it++ } -> __can_reference;
295 } && copyable<_Iter>;
297 template<
typename _Iter>
298 concept __cpp17_input_iterator = __cpp17_iterator<_Iter>
299 && equality_comparable<_Iter>
300 && requires(_Iter __it)
302 typename incrementable_traits<_Iter>::difference_type;
303 typename indirectly_readable_traits<_Iter>::value_type;
304 typename common_reference_t<iter_reference_t<_Iter>&&,
305 typename indirectly_readable_traits<_Iter>::value_type&>;
306 typename common_reference_t<decltype(*__it++)&&,
307 typename indirectly_readable_traits<_Iter>::value_type&>;
308 requires signed_integral<
309 typename incrementable_traits<_Iter>::difference_type>;
312 template<
typename _Iter>
313 concept __cpp17_fwd_iterator = __cpp17_input_iterator<_Iter>
314 && constructible_from<_Iter>
315 && is_lvalue_reference_v<iter_reference_t<_Iter>>
316 && same_as<remove_cvref_t<iter_reference_t<_Iter>>,
317 typename indirectly_readable_traits<_Iter>::value_type>
318 && requires(_Iter __it)
320 { __it++ } -> convertible_to<const _Iter&>;
321 { *__it++ } -> same_as<iter_reference_t<_Iter>>;
324 template<
typename _Iter>
325 concept __cpp17_bidi_iterator = __cpp17_fwd_iterator<_Iter>
326 && requires(_Iter __it)
328 { --__it } -> same_as<_Iter&>;
329 { __it-- } -> convertible_to<const _Iter&>;
330 { *__it-- } -> same_as<iter_reference_t<_Iter>>;
333 template<
typename _Iter>
334 concept __cpp17_randacc_iterator = __cpp17_bidi_iterator<_Iter>
335 && totally_ordered<_Iter>
336 && requires(_Iter __it,
337 typename incrementable_traits<_Iter>::difference_type __n)
339 { __it += __n } -> same_as<_Iter&>;
340 { __it -= __n } -> same_as<_Iter&>;
341 { __it + __n } -> same_as<_Iter>;
342 { __n + __it } -> same_as<_Iter>;
343 { __it - __n } -> same_as<_Iter>;
344 { __it - __it } ->
same_as<decltype(__n)>;
345 { __it[__n] } -> convertible_to<iter_reference_t<_Iter>>;
348 template<
typename _Iter>
349 concept __iter_with_nested_types = requires {
350 typename _Iter::iterator_category;
351 typename _Iter::value_type;
352 typename _Iter::difference_type;
353 typename _Iter::reference;
356 template<
typename _Iter>
357 concept __iter_without_nested_types = !__iter_with_nested_types<_Iter>;
359 template<
typename _Iter>
360 concept __iter_without_category
361 = !requires {
typename _Iter::iterator_category; };
365 template<
typename _Iterator>
366 requires __detail::__iter_with_nested_types<_Iterator>
367 struct __iterator_traits<_Iterator, void>
370 template<
typename _Iter>
372 {
using type = void; };
374 template<
typename _Iter> requires requires {
typename _Iter::pointer; }
376 {
using type =
typename _Iter::pointer; };
379 using iterator_category =
typename _Iterator::iterator_category;
380 using value_type =
typename _Iterator::value_type;
381 using difference_type =
typename _Iterator::difference_type;
382 using pointer =
typename __ptr<_Iterator>::type;
383 using reference =
typename _Iterator::reference;
386 template<
typename _Iterator>
387 requires __detail::__iter_without_nested_types<_Iterator>
388 && __detail::__cpp17_input_iterator<_Iterator>
389 struct __iterator_traits<_Iterator, void>
392 template<
typename _Iter>
394 {
using type = input_iterator_tag; };
396 template<
typename _Iter>
397 requires requires {
typename _Iter::iterator_category; }
399 {
using type =
typename _Iter::iterator_category; };
401 template<
typename _Iter>
402 requires __detail::__iter_without_category<_Iter>
403 && __detail::__cpp17_randacc_iterator<_Iter>
405 {
using type = random_access_iterator_tag; };
407 template<
typename _Iter>
408 requires __detail::__iter_without_category<_Iter>
409 && __detail::__cpp17_bidi_iterator<_Iter>
411 {
using type = bidirectional_iterator_tag; };
413 template<
typename _Iter>
414 requires __detail::__iter_without_category<_Iter>
415 && __detail::__cpp17_fwd_iterator<_Iter>
417 {
using type = forward_iterator_tag; };
419 template<
typename _Iter>
421 {
using type = void; };
423 template<
typename _Iter> requires requires {
typename _Iter::pointer; }
425 {
using type =
typename _Iter::pointer; };
427 template<
typename _Iter>
428 requires (!requires {
typename _Iter::pointer; }
429 && requires(_Iter& __it) { __it.operator->(); })
431 {
using type = decltype(std::declval<_Iter&>().operator->()); };
433 template<
typename _Iter>
435 {
using type = iter_reference_t<_Iter>; };
437 template<
typename _Iter> requires requires {
typename _Iter::reference; }
439 {
using type =
typename _Iter::reference; };
442 using iterator_category =
typename __cat<_Iterator>::type;
444 =
typename indirectly_readable_traits<_Iterator>::value_type;
445 using difference_type
446 =
typename incrementable_traits<_Iterator>::difference_type;
447 using pointer =
typename __ptr<_Iterator>::type;
448 using reference =
typename __ref<_Iterator>::type;
451 template<
typename _Iterator>
452 requires __detail::__iter_without_nested_types<_Iterator>
453 && __detail::__cpp17_iterator<_Iterator>
454 struct __iterator_traits<_Iterator, void>
457 template<
typename _Iter>
459 {
using type = void; };
461 template<
typename _Iter>
463 {
typename incrementable_traits<_Iter>::difference_type; }
466 using type =
typename incrementable_traits<_Iter>::difference_type;
470 using iterator_category = output_iterator_tag;
471 using value_type = void;
472 using difference_type =
typename __diff<_Iterator>::type;
473 using pointer = void;
474 using reference = void;
479 template<
typename _Iter>
480 struct __iter_concept_impl;
483 template<
typename _Iter>
484 requires requires {
typename __iter_traits<_Iter>::iterator_concept; }
485 struct __iter_concept_impl<_Iter>
486 {
using type =
typename __iter_traits<_Iter>::iterator_concept; };
489 template<
typename _Iter>
490 requires (!requires {
typename __iter_traits<_Iter>::iterator_concept; }
491 && requires {
typename __iter_traits<_Iter>::iterator_category; })
492 struct __iter_concept_impl<_Iter>
493 {
using type =
typename __iter_traits<_Iter>::iterator_category; };
496 template<
typename _Iter>
497 requires (!requires {
typename __iter_traits<_Iter>::iterator_concept; }
498 && !requires {
typename __iter_traits<_Iter>::iterator_category; }
499 && __primary_traits_iter<_Iter>)
500 struct __iter_concept_impl<_Iter>
501 {
using type = random_access_iterator_tag; };
504 template<
typename _Iter>
505 struct __iter_concept_impl
509 template<
typename _Iter>
510 using __iter_concept =
typename __iter_concept_impl<_Iter>::type;
512 template<
typename _In>
513 concept __indirectly_readable_impl = requires
515 typename iter_value_t<_In>;
516 typename iter_reference_t<_In>;
517 typename iter_rvalue_reference_t<_In>;
518 requires same_as<iter_reference_t<const _In>,
519 iter_reference_t<_In>>;
520 requires same_as<iter_rvalue_reference_t<const _In>,
521 iter_rvalue_reference_t<_In>>;
523 && common_reference_with<iter_reference_t<_In>&&, iter_value_t<_In>&>
524 && common_reference_with<iter_reference_t<_In>&&,
525 iter_rvalue_reference_t<_In>&&>
526 && common_reference_with<iter_rvalue_reference_t<_In>&&,
527 const iter_value_t<_In>&>;
532 template<
typename _In>
534 = __detail::__indirectly_readable_impl<remove_cvref_t<_In>>;
536 template<indirectly_readable _Tp>
537 using iter_common_reference_t
538 = common_reference_t<iter_reference_t<_Tp>, iter_value_t<_Tp>&>;
541 template<
typename _Out,
typename _Tp>
544 *__o = std::forward<_Tp>(__t);
545 *std::forward<_Out>(__o) = std::forward<_Tp>(__t);
546 const_cast<const iter_reference_t<_Out>&&
>(*__o)
547 = std::forward<_Tp>(__t);
548 const_cast<const iter_reference_t<_Out>&&
>(*std::forward<_Out>(__o))
549 = std::forward<_Tp>(__t);
552 namespace ranges::__detail
554 class __max_diff_type;
555 class __max_size_type;
558 template<
typename _Tp>
559 concept __is_signed_int128
560 #if __SIZEOF_INT128__
561 = same_as<_Tp, __int128>;
567 template<
typename _Tp>
568 concept __is_unsigned_int128
569 #if __SIZEOF_INT128__
570 = same_as<_Tp, unsigned __int128>;
575 template<
typename _Tp>
576 concept __cv_bool = same_as<const volatile _Tp, const volatile bool>;
578 template<
typename _Tp>
579 concept __integral_nonbool = integral<_Tp> && !__cv_bool<_Tp>;
581 template<
typename _Tp>
582 concept __is_int128 = __is_signed_int128<_Tp> || __is_unsigned_int128<_Tp>;
584 template<
typename _Tp>
585 concept __is_integer_like = __integral_nonbool<_Tp>
587 || same_as<_Tp, __max_diff_type> || same_as<_Tp, __max_size_type>;
589 template<
typename _Tp>
590 concept __is_signed_integer_like = signed_integral<_Tp>
591 || __is_signed_int128<_Tp>
592 || same_as<_Tp, __max_diff_type>;
596 namespace __detail {
using ranges::__detail::__is_signed_integer_like; }
599 template<
typename _Iter>
601 && requires(_Iter __i)
603 typename iter_difference_t<_Iter>;
604 requires __detail::__is_signed_integer_like<iter_difference_t<_Iter>>;
605 { ++__i } -> same_as<_Iter&>;
609 template<
typename _Iter>
610 concept incrementable = regular<_Iter> && weakly_incrementable<_Iter>
611 && requires(_Iter __i) { { __i++ } -> same_as<_Iter>; };
613 template<
typename _Iter>
614 concept input_or_output_iterator
615 = requires(_Iter __i) { { *__i } -> __detail::__can_reference; }
616 && weakly_incrementable<_Iter>;
618 template<
typename _Sent,
typename _Iter>
619 concept sentinel_for = semiregular<_Sent>
620 && input_or_output_iterator<_Iter>
621 && __detail::__weakly_eq_cmp_with<_Sent, _Iter>;
623 template<
typename _Sent,
typename _Iter>
624 inline constexpr
bool disable_sized_sentinel_for =
false;
626 template<
typename _Sent,
typename _Iter>
627 concept sized_sentinel_for = sentinel_for<_Sent, _Iter>
628 && !disable_sized_sentinel_for<remove_cv_t<_Sent>, remove_cv_t<_Iter>>
629 && requires(
const _Iter& __i,
const _Sent& __s)
631 { __s - __i } -> same_as<iter_difference_t<_Iter>>;
632 { __i - __s } -> same_as<iter_difference_t<_Iter>>;
635 template<
typename _Iter>
636 concept input_iterator = input_or_output_iterator<_Iter>
637 && indirectly_readable<_Iter>
638 && requires {
typename __detail::__iter_concept<_Iter>; }
639 && derived_from<__detail::__iter_concept<_Iter>, input_iterator_tag>;
641 template<
typename _Iter,
typename _Tp>
642 concept output_iterator = input_or_output_iterator<_Iter>
643 && indirectly_writable<_Iter, _Tp>
644 && requires(_Iter __i, _Tp&& __t) { *__i++ = std::forward<_Tp>(__t); };
646 template<
typename _Iter>
647 concept forward_iterator = input_iterator<_Iter>
648 && derived_from<__detail::__iter_concept<_Iter>, forward_iterator_tag>
649 && incrementable<_Iter> && sentinel_for<_Iter, _Iter>;
651 template<
typename _Iter>
652 concept bidirectional_iterator = forward_iterator<_Iter>
653 && derived_from<__detail::__iter_concept<_Iter>,
654 bidirectional_iterator_tag>
655 && requires(_Iter __i)
657 { --__i } -> same_as<_Iter&>;
658 { __i-- } -> same_as<_Iter>;
661 template<
typename _Iter>
662 concept random_access_iterator = bidirectional_iterator<_Iter>
663 && derived_from<__detail::__iter_concept<_Iter>,
664 random_access_iterator_tag>
665 && totally_ordered<_Iter> && sized_sentinel_for<_Iter, _Iter>
666 && requires(_Iter __i,
const _Iter __j,
667 const iter_difference_t<_Iter> __n)
669 { __i += __n } -> same_as<_Iter&>;
670 { __j + __n } -> same_as<_Iter>;
671 { __n + __j } -> same_as<_Iter>;
672 { __i -= __n } -> same_as<_Iter&>;
673 { __j - __n } -> same_as<_Iter>;
674 { __j[__n] } -> same_as<iter_reference_t<_Iter>>;
677 template<
typename _Iter>
678 concept contiguous_iterator = random_access_iterator<_Iter>
679 && derived_from<__detail::__iter_concept<_Iter>, contiguous_iterator_tag>
680 && is_lvalue_reference_v<iter_reference_t<_Iter>>
681 && same_as<iter_value_t<_Iter>, remove_cvref_t<iter_reference_t<_Iter>>>
682 && requires(
const _Iter& __i)
685 -> same_as<add_pointer_t<iter_reference_t<_Iter>>>;
692 template<
typename _Fn,
typename _Iter>
693 concept indirectly_unary_invocable = indirectly_readable<_Iter>
694 && copy_constructible<_Fn> && invocable<_Fn&, iter_value_t<_Iter>&>
695 && invocable<_Fn&, iter_reference_t<_Iter>>
696 && invocable<_Fn&, iter_common_reference_t<_Iter>>
697 && common_reference_with<invoke_result_t<_Fn&, iter_value_t<_Iter>&>,
698 invoke_result_t<_Fn&, iter_reference_t<_Iter>>>;
700 template<
typename _Fn,
typename _Iter>
701 concept indirectly_regular_unary_invocable = indirectly_readable<_Iter>
702 && copy_constructible<_Fn>
703 && regular_invocable<_Fn&, iter_value_t<_Iter>&>
704 && regular_invocable<_Fn&, iter_reference_t<_Iter>>
705 && regular_invocable<_Fn&, iter_common_reference_t<_Iter>>
706 && common_reference_with<invoke_result_t<_Fn&, iter_value_t<_Iter>&>,
707 invoke_result_t<_Fn&, iter_reference_t<_Iter>>>;
709 template<
typename _Fn,
typename _Iter>
710 concept indirect_unary_predicate = indirectly_readable<_Iter>
711 && copy_constructible<_Fn> && predicate<_Fn&, iter_value_t<_Iter>&>
712 && predicate<_Fn&, iter_reference_t<_Iter>>
713 && predicate<_Fn&, iter_common_reference_t<_Iter>>;
715 template<
typename _Fn,
typename _I1,
typename _I2>
716 concept indirect_binary_predicate
717 = indirectly_readable<_I1> && indirectly_readable<_I2>
718 && copy_constructible<_Fn>
719 && predicate<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&>
720 && predicate<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>>
721 && predicate<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&>
722 && predicate<_Fn&, iter_reference_t<_I1>, iter_reference_t<_I2>>
723 && predicate<_Fn&, iter_common_reference_t<_I1>,
724 iter_common_reference_t<_I2>>;
726 template<
typename _Fn,
typename _I1,
typename _I2 = _I1>
727 concept indirect_equivalence_relation
728 = indirectly_readable<_I1> && indirectly_readable<_I2>
729 && copy_constructible<_Fn>
730 && equivalence_relation<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&>
731 && equivalence_relation<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>>
732 && equivalence_relation<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&>
733 && equivalence_relation<_Fn&, iter_reference_t<_I1>,
734 iter_reference_t<_I2>>
735 && equivalence_relation<_Fn&, iter_common_reference_t<_I1>,
736 iter_common_reference_t<_I2>>;
738 template<
typename _Fn,
typename _I1,
typename _I2 = _I1>
739 concept indirect_strict_weak_order
740 = indirectly_readable<_I1> && indirectly_readable<_I2>
741 && copy_constructible<_Fn>
742 && strict_weak_order<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&>
743 && strict_weak_order<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>>
744 && strict_weak_order<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&>
745 && strict_weak_order<_Fn&, iter_reference_t<_I1>, iter_reference_t<_I2>>
746 && strict_weak_order<_Fn&, iter_common_reference_t<_I1>,
747 iter_common_reference_t<_I2>>;
749 template<
typename _Fn,
typename... _Is>
750 requires (indirectly_readable<_Is> && ...)
751 && invocable<_Fn, iter_reference_t<_Is>...>
752 using indirect_result_t = invoke_result_t<_Fn, iter_reference_t<_Is>...>;
756 indirectly_regular_unary_invocable<_Iter> _Proj>
761 indirect_result_t<_Proj&, _Iter>
operator*()
const;
764 template<weakly_incrementable _Iter,
typename _Proj>
765 struct incrementable_traits<
projected<_Iter, _Proj>>
766 {
using difference_type = iter_difference_t<_Iter>; };
772 template<
typename _In,
typename _Out>
774 && indirectly_writable<_Out, iter_rvalue_reference_t<_In>>;
776 template<
typename _In,
typename _Out>
777 concept indirectly_movable_storable = indirectly_movable<_In, _Out>
778 && indirectly_writable<_Out, iter_value_t<_In>>
779 && movable<iter_value_t<_In>>
780 && constructible_from<iter_value_t<_In>, iter_rvalue_reference_t<_In>>
781 && assignable_from<iter_value_t<_In>&, iter_rvalue_reference_t<_In>>;
784 template<
typename _In,
typename _Out>
786 && indirectly_writable<_Out, iter_reference_t<_In>>;
788 template<
typename _In,
typename _Out>
789 concept indirectly_copyable_storable = indirectly_copyable<_In, _Out>
790 && indirectly_writable<_Out, iter_value_t<_In>&>
791 && indirectly_writable<_Out, const iter_value_t<_In>&>
792 && indirectly_writable<_Out, iter_value_t<_In>&&>
793 && indirectly_writable<_Out, const iter_value_t<_In>&&>
794 && copyable<iter_value_t<_In>>
795 && constructible_from<iter_value_t<_In>, iter_reference_t<_In>>
796 && assignable_from<iter_value_t<_In>&, iter_reference_t<_In>>;
800 namespace __cust_iswap
802 template<
typename _It1,
typename _It2>
803 void iter_swap(_It1, _It2) =
delete;
805 template<
typename _Tp,
typename _Up>
807 = (std::__detail::__class_or_enum<remove_reference_t<_Tp>>
808 || std::__detail::__class_or_enum<remove_reference_t<_Up>>)
809 && requires(_Tp&& __t, _Up&& __u) {
810 iter_swap(
static_cast<_Tp&&
>(__t),
static_cast<_Up&&
>(__u));
813 template<
typename _Xp,
typename _Yp>
814 constexpr iter_value_t<_Xp>
815 __iter_exchange_move(_Xp&& __x, _Yp&& __y)
816 noexcept(noexcept(iter_value_t<_Xp>(iter_move(__x)))
817 && noexcept(*__x = iter_move(__y)))
819 iter_value_t<_Xp> __old_value(iter_move(__x));
820 *__x = iter_move(__y);
827 template<
typename _Tp,
typename _Up>
828 static constexpr
bool
831 if constexpr (__adl_iswap<_Tp, _Up>)
832 return noexcept(iter_swap(std::declval<_Tp>(),
833 std::declval<_Up>()));
834 else if constexpr (indirectly_readable<_Tp>
835 && indirectly_readable<_Up>
836 && swappable_with<iter_reference_t<_Tp>, iter_reference_t<_Up>>)
837 return noexcept(ranges::swap(*std::declval<_Tp>(),
838 *std::declval<_Up>()));
840 return noexcept(*std::declval<_Tp>()
841 = __iter_exchange_move(std::declval<_Up>(),
842 std::declval<_Tp>()));
846 template<
typename _Tp,
typename _Up>
847 requires __adl_iswap<_Tp, _Up>
848 || (indirectly_readable<remove_reference_t<_Tp>>
849 && indirectly_readable<remove_reference_t<_Up>>
850 && swappable_with<iter_reference_t<_Tp>, iter_reference_t<_Up>>)
851 || (indirectly_movable_storable<_Tp, _Up>
852 && indirectly_movable_storable<_Up, _Tp>)
854 operator()(_Tp&& __e1, _Up&& __e2)
const
855 noexcept(_S_noexcept<_Tp, _Up>())
857 if constexpr (__adl_iswap<_Tp, _Up>)
858 iter_swap(
static_cast<_Tp&&
>(__e1),
static_cast<_Up&&
>(__e2));
859 else if constexpr (indirectly_readable<_Tp>
860 && indirectly_readable<_Up>
861 && swappable_with<iter_reference_t<_Tp>, iter_reference_t<_Up>>)
862 ranges::swap(*__e1, *__e2);
864 *__e1 = __iter_exchange_move(__e2, __e1);
869 inline namespace __cust
871 inline constexpr __cust_iswap::_IterSwap iter_swap{};
877 template<
typename _I1,
typename _I2 = _I1>
879 = indirectly_readable<_I1> && indirectly_readable<_I2>
880 && requires(
const _I1 __i1,
const _I2 __i2)
882 ranges::iter_swap(__i1, __i1);
883 ranges::iter_swap(__i2, __i2);
884 ranges::iter_swap(__i1, __i2);
885 ranges::iter_swap(__i2, __i1);
889 template<
typename _I1,
typename _I2,
typename _Rel,
typename _P1 = identity,
892 = indirect_binary_predicate<_Rel, projected<_I1, _P1>,
896 template<
typename _Iter>
898 && indirectly_movable_storable<_Iter, _Iter>
899 && indirectly_swappable<_Iter, _Iter>;
902 template<
typename _I1,
typename _I2,
typename _Out,
905 concept
mergeable = input_iterator<_I1> && input_iterator<_I2>
906 && weakly_incrementable<_Out> && indirectly_copyable<_I1, _Out>
907 && indirectly_copyable<_I2, _Out>
908 && indirect_strict_weak_order<_Rel, projected<_I1, _P1>,
914 concept
sortable = permutable<_Iter>
915 && indirect_strict_weak_order<_Rel, projected<_Iter, _Proj>>;
917 struct unreachable_sentinel_t
919 template<weakly_incrementable _It>
920 friend constexpr
bool
921 operator==(unreachable_sentinel_t,
const _It&) noexcept
925 inline constexpr unreachable_sentinel_t unreachable_sentinel{};
927 struct default_sentinel_t { };
928 inline constexpr default_sentinel_t default_sentinel{};
931 namespace ranges::__cust_access
933 using std::__detail::__class_or_enum;
935 struct _Decay_copy final
937 template<
typename _Tp>
938 constexpr decay_t<_Tp>
939 operator()(_Tp&& __t)
const
941 {
return std::forward<_Tp>(__t); }
942 }
inline constexpr __decay_copy{};
944 template<
typename _Tp>
945 concept __member_begin = requires(_Tp& __t)
947 { __decay_copy(__t.begin()) } -> input_or_output_iterator;
951 void begin(
auto&) =
delete;
952 void begin(
const auto&) =
delete;
954 template<
typename _Tp>
955 concept __adl_begin = __class_or_enum<remove_reference_t<_Tp>>
956 && requires(_Tp& __t)
958 { __decay_copy(
begin(__t)) } -> input_or_output_iterator;
963 template<
typename _Tp>
964 requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
968 if constexpr (is_array_v<_Tp>)
970 else if constexpr (__member_begin<_Tp&>)
980 template<
typename _Tp>
982 = decltype(ranges::__cust_access::__begin(std::declval<_Tp&>()));
986 _GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
constexpr _Tp * to_address(_Tp *__ptr) noexcept
Obtain address referenced by a pointer to an object.
constexpr bool is_nothrow_convertible_v
is_nothrow_convertible_v
typename remove_cvref< _Tp >::type remove_cvref_t
_Tp * begin(valarray< _Tp > &__va) noexcept
Return an iterator pointing to the first element of the valarray.
ISO C++ entities toplevel namespace is std.
concept weakly_incrementable
Requirements on types that can be incremented with ++.
concept mergeable
[alg.req.mergeable], concept mergeable
concept same_as
[concept.same], concept same_as
concept indirectly_readable
Requirements for types that are readable by applying operator*.
concept permutable
[alg.req.permutable], concept permutable
concept indirectly_swappable
[alg.req.ind.swap], concept indirectly_swappable
concept sortable
[alg.req.sortable], concept sortable
concept indirectly_movable
[alg.req.ind.move], concept indirectly_movable
concept indirectly_comparable
[alg.req.ind.cmp], concept indirectly_comparable
concept indirectly_copyable
[alg.req.ind.copy], concept indirectly_copyable
concept indirectly_writable
Requirements for writing a value into an iterator's referenced object.
[func.identity] The identity function.
ranges::less function object type.