[libcxx-commits] [libcxx] [libc++][ranges] P2387R3: Pipe support for user-defined range adaptors (PR #89148)
Xiaoyang Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Apr 22 12:28:24 PDT 2024
================
@@ -52,15 +54,21 @@ struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__range_adaptor_closure_t);
template <class _Tp>
-concept _RangeAdaptorClosure = derived_from<remove_cvref_t<_Tp>, __range_adaptor_closure<remove_cvref_t<_Tp>>>;
+_Tp __derived_from_range_adaptor_closure(__range_adaptor_closure<_Tp>*);
template <class _Tp>
+concept _RangeAdaptorClosure = !ranges::range<remove_cvref_t<_Tp>> && requires {
+ { __derived_from_range_adaptor_closure((remove_cvref_t<_Tp>*)nullptr) } -> same_as<remove_cvref_t<_Tp>>;
+};
+
+template <class _Tp>
+ requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
struct __range_adaptor_closure {
- template <ranges::viewable_range _View, _RangeAdaptorClosure _Closure>
- requires same_as<_Tp, remove_cvref_t<_Closure>> && invocable<_Closure, _View>
+ template <ranges::range _Range, _RangeAdaptorClosure _Closure>
+ requires same_as<_Tp, remove_cvref_t<_Closure>> && invocable<_Closure, _Range>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto)
----------------
xiaoyang-sde wrote:
I believe either way works. The difference I notice here is that defining these 2 `operator|`s in the `ranges` namespace will enable users to invoke them with `std::ranges::operator|(range, closure)`.
https://github.com/llvm/llvm-project/pull/89148
More information about the libcxx-commits
mailing list