41 template <
typename... OutputTs>
42 struct transducer_rf_gen
44 template <
typename StateT>
45 struct from_any_state_rf_gen
47 template <
typename ReducingFnT>
52 template <
typename ...InputTs>
53 any_state operator() (any_state s, InputTs&& ...is)
55 auto next = step(std::move(s).as<StateT>(),
56 std::forward<InputTs>(is)...);
63 template <
typename StateT>
64 using from_any_state = transducer_impl<from_any_state_rf_gen<StateT> >;
66 template <
typename ReducingFnT,
73 apply(ReducingFnT step_, XformT xform_)
74 : step(
std::move(step_)), xform(
std::move(xform_)) {}
76 using xformed_t =
typename XformT::result_type;
79 template <
typename StateT,
typename... InputTs>
80 auto operator() (StateT&& s, InputTs&& ...ins)
82 !std::is_same<estd::decay_t<StateT>, any_state>{},
85 xformed =
comp(xform, from_any_state<StateT>{})(step);
86 return xformed(std::forward<StateT>(s), std::forward<InputTs>(ins)...);
89 template <
typename StateT,
typename... InputTs>
90 auto operator() (StateT&& s, InputTs&& ...ins)
92 std::is_same<estd::decay_t<StateT>, any_state>{},
95 return xformed(std::forward<StateT>(s), std::forward<InputTs>(ins)...);
100 template <
typename... ArgTs>
101 struct reducing_function
103 using type = std::function<any_state(any_state, ArgTs...)>;
106 template <
typename InputT,
typename OutputT>
107 using transducer_function_t = std::function<
108 meta::unpack_t<reducing_function, InputT> (
109 meta::unpack_t<reducing_function, OutputT>)>;
113 template <
typename InputT,
typename OutputT=InputT>
115 meta::unpack<detail::transducer_rf_gen, OutputT>,
116 detail::transducer_function_t<InputT, OutputT> >;
typename std::enable_if< X, T >::type enable_if_t
Similar to C++14 std::enable_if_t.
auto comp(F &&f) -> F &&
Right-to left function composition.
C++ amazing templates and reusable implementations awesomeness.
auto xformed(Xform &&xform, InTs &&...ins) -> estd::enable_if_t< meta::all(In_value< InTs >()...), detail::xformed_input< typename decltype( detail::make_xform_down_signal( xform, detail::access::signal(ins)...) )::element_type > >
Returns a new in formed by applying a transducer xform on the successive values of the in...