File indexing completed on 2026-05-03 08:13:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___CXX03___RANGES_RANGE_ADAPTOR_H
0011 #define _LIBCPP___CXX03___RANGES_RANGE_ADAPTOR_H
0012
0013 #include <__cxx03/__concepts/constructible.h>
0014 #include <__cxx03/__concepts/derived_from.h>
0015 #include <__cxx03/__concepts/invocable.h>
0016 #include <__cxx03/__concepts/same_as.h>
0017 #include <__cxx03/__config>
0018 #include <__cxx03/__functional/compose.h>
0019 #include <__cxx03/__functional/invoke.h>
0020 #include <__cxx03/__ranges/concepts.h>
0021 #include <__cxx03/__type_traits/decay.h>
0022 #include <__cxx03/__type_traits/is_class.h>
0023 #include <__cxx03/__type_traits/is_nothrow_constructible.h>
0024 #include <__cxx03/__type_traits/remove_cvref.h>
0025 #include <__cxx03/__utility/forward.h>
0026 #include <__cxx03/__utility/move.h>
0027
0028 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0029 # pragma GCC system_header
0030 #endif
0031
0032 _LIBCPP_PUSH_MACROS
0033 #include <__cxx03/__undef_macros>
0034
0035 _LIBCPP_BEGIN_NAMESPACE_STD
0036
0037 #if _LIBCPP_STD_VER >= 20
0038
0039 namespace ranges {
0040
0041
0042
0043
0044
0045
0046 template <class _Tp>
0047 requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
0048 struct __range_adaptor_closure;
0049
0050
0051
0052 template <class _Fn>
0053 struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_closure_t<_Fn>> {
0054 _LIBCPP_HIDE_FROM_ABI constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(std::move(__f)) {}
0055 };
0056 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__range_adaptor_closure_t);
0057
0058 template <class _Tp>
0059 _Tp __derived_from_range_adaptor_closure(__range_adaptor_closure<_Tp>*);
0060
0061 template <class _Tp>
0062 concept _RangeAdaptorClosure = !ranges::range<remove_cvref_t<_Tp>> && requires {
0063
0064
0065 { ranges::__derived_from_range_adaptor_closure((remove_cvref_t<_Tp>*)nullptr) } -> same_as<remove_cvref_t<_Tp>>;
0066 };
0067
0068 template <ranges::range _Range, _RangeAdaptorClosure _Closure>
0069 requires invocable<_Closure, _Range>
0070 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto)
0071 operator|(_Range&& __range, _Closure&& __closure) noexcept(is_nothrow_invocable_v<_Closure, _Range>) {
0072 return std::invoke(std::forward<_Closure>(__closure), std::forward<_Range>(__range));
0073 }
0074
0075 template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure>
0076 requires constructible_from<decay_t<_Closure>, _Closure> && constructible_from<decay_t<_OtherClosure>, _OtherClosure>
0077 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2) noexcept(
0078 is_nothrow_constructible_v<decay_t<_Closure>, _Closure> &&
0079 is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>) {
0080 return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1)));
0081 }
0082
0083 template <class _Tp>
0084 requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
0085 struct __range_adaptor_closure {};
0086
0087 # if _LIBCPP_STD_VER >= 23
0088 template <class _Tp>
0089 requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
0090 class range_adaptor_closure : public __range_adaptor_closure<_Tp> {};
0091 # endif
0092
0093 }
0094
0095 #endif
0096
0097 _LIBCPP_END_NAMESPACE_STD
0098
0099 _LIBCPP_POP_MACROS
0100
0101 #endif