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