Skip to content

Commit a3a5d61

Browse files
committed
mapply and muncurry can be implemented in terms of mfor
1 parent 2018844 commit a3a5d61

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

include/stdexec/__detail/__meta.hpp

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -530,56 +530,51 @@ namespace STDEXEC {
530530
using __f = __minvoke<__mfold_left_<sizeof...(_Args) == 0>, _Fn, _Init, _Args...>;
531531
};
532532

533-
template <class _Fn>
534-
struct __mcurry {
535-
template <class... _Ts>
536-
using __f = __minvoke<_Fn, _Ts...>;
537-
};
538-
533+
// for:: [a] -> (a -> b) -> [b]
539534
template <class _Tp>
540-
struct __muncurry_;
535+
struct __mfor;
541536

542537
template <template <class...> class _Ap, class... _As>
543-
struct __muncurry_<_Ap<_As...>> {
538+
struct __mfor<_Ap<_As...>> {
544539
template <class _Fn>
545540
using __f = __minvoke<_Fn, _As...>;
546541
};
547542

548543
template <class _Ret, class... _As>
549-
struct __muncurry_<_Ret(_As...)> {
544+
struct __mfor<_Ret(_As...)> {
550545
template <class _Fn>
551546
using __f = __minvoke<_Fn, _Ret, _As...>;
552547
};
553548

554549
template <std::size_t... _Ns>
555-
struct __muncurry_<__indices<_Ns...>> {
550+
struct __mfor<__indices<_Ns...>> {
556551
template <class _Fn>
557552
using __f = __minvoke<_Fn, __msize_t<_Ns>...>;
558553
};
559554

560555
template <template <class _Np, _Np...> class _Cp, class _Np, _Np... _Ns>
561-
struct __muncurry_<_Cp<_Np, _Ns...>> {
556+
struct __mfor<_Cp<_Np, _Ns...>> {
562557
template <class _Fn>
563558
using __f = __minvoke<_Fn, std::integral_constant<_Np, _Ns>...>;
564559
};
565560

566561
template <class _What, class... _With>
567-
struct __muncurry_<_ERROR_<_What, _With...>> {
562+
struct __mfor<_ERROR_<_What, _With...>> {
568563
template <class _Fn>
569564
using __f = _ERROR_<_What, _With...>;
570565
};
571566

572-
template <class _Fn>
573-
struct __muncurry {
574-
template <class _Tp>
575-
using __f = __muncurry_<_Tp>::template __f<_Fn>;
576-
};
577-
578567
template <class _Fn, class _List>
579-
using __mapply = __minvoke<__muncurry<_Fn>, _List>;
568+
using __mapply = __mcall1<__mfor<_List>, _Fn>;
580569

581570
template <template <class...> class _Fn, class _List>
582-
using __mapply_q = __minvoke<__muncurry<__q<_Fn>>, _List>;
571+
using __mapply_q = __mcall1<__mfor<_List>, __q<_Fn>>;
572+
573+
template <class _Fn>
574+
struct __muncurry {
575+
template <class _List>
576+
using __f = __mapply<_Fn, _List>;
577+
};
583578

584579
template <std::size_t _Ny, class _Ty, class _Continuation = __qq<__mlist>>
585580
using __mfill_c = __mapply<__mtransform<__mconst<_Ty>, _Continuation>, __make_indices<_Ny>>;

include/stdexec/__detail/__sender_introspection.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ namespace STDEXEC {
8787
inline constexpr std::size_t __nbr_children_of = __tuple_size_v<_Sender> - 2;
8888

8989
template <auto _Descriptor>
90-
struct __muncurry_<__sexpr<_Descriptor>> : decltype(_Descriptor()){};
90+
struct __mfor<__sexpr<_Descriptor>> : decltype(_Descriptor()){};
9191

9292
template <auto _Descriptor>
93-
struct __muncurry_<__sexpr<_Descriptor> &> : decltype(_Descriptor()){};
93+
struct __mfor<__sexpr<_Descriptor> &> : decltype(_Descriptor()){};
9494

9595
template <auto _Descriptor>
96-
struct __muncurry_<__sexpr<_Descriptor> const &> : decltype(_Descriptor()){};
96+
struct __mfor<__sexpr<_Descriptor> const &> : decltype(_Descriptor()){};
9797

9898
template <class _Sender>
9999
concept sender_expr = __minvocable_q<tag_of_t, _Sender>;

include/stdexec/__detail/__variant.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ namespace STDEXEC {
267267

268268
// So we can use __variant as a typelist
269269
template <auto _Idx, class... _Ts>
270-
struct __muncurry_<__variant<_Idx, _Ts...>> {
270+
struct __mfor<__variant<_Idx, _Ts...>> {
271271
template <class _Fn>
272272
using __f = __minvoke<_Fn, _Ts...>;
273273
};

0 commit comments

Comments
 (0)