33 #include <type_traits> 40 template<
typename F,
typename... PrevArgs>
45 std::tuple<PrevArgs...> m_prevArgs;
47 template<
typename CF,
typename CT>
49 : m_f { std::forward<CF> (
f) }
50 , m_prevArgs { std::forward<CT> (prev) }
57 return run (*
this, std::forward<T> (arg));
63 return run (std::as_const (*
this), std::forward<T> (arg));
69 return run (std::move (*
this), std::forward<T> (arg));
72 template<
typename This,
typename T>
73 static auto run (This&& refThis, T&& arg)
75 if constexpr (std::is_invocable_v<F, PrevArgs..., T>)
77 auto wrapper = [&refThis, &arg] (
auto&&... args)
79 return std::invoke (std::move (refThis.m_f), std::forward<decltype (args)> (args)..., std::forward<T> (arg));
81 return std::apply (std::move (wrapper), std::move (refThis.m_prevArgs));
86 std::move (refThis.m_f),
87 std::tuple_cat (std::move (refThis.m_prevArgs), std::forward_as_tuple (std::forward<T> (arg)))
92 template<
typename F,
typename... Args>
95 return { std::forward<F> (
f), std::forward_as_tuple (std::forward<Args> (args)...) };
CurryImpl< std::decay_t< F >, Args... > Curry(F &&f, Args &&... args)
constexpr detail::ExprTree< detail::ExprType::LeafStaticPlaceholder, detail::MemberPtrs< Ptr > > f
CurryImpl(CF &&f, CT &&prev)
auto operator()(T &&arg) const &