16 #if !defined(RXCPP_OPERATORS_RX_LIFT_HPP) 17 #define RXCPP_OPERATORS_RX_LIFT_HPP 19 #include "../rx-includes.hpp" 25 template<
class V,
class S,
class F>
26 struct is_lift_function_for {
28 struct tag_not_valid {};
29 template<
class CS,
class CF>
30 static auto check(
int) -> decltype((*(CF*)
nullptr)(*(CS*)
nullptr));
31 template<
class CS,
class CF>
32 static tag_not_valid check(...);
34 using for_type = rxu::decay_t<S>;
35 using func_type = rxu::decay_t<F>;
36 using detail_result = decltype(check<for_type, func_type>(0));
38 static const bool value = rxu::all_true_type<
39 is_subscriber<detail_result>,
40 is_subscriber<for_type>,
41 std::is_convertible<V, typename rxu::value_type_from<detail_result>::type>>::value;
50 template<
class ResultType,
class SourceOperator,
class Operator>
53 typedef rxu::decay_t<ResultType> result_value_type;
54 typedef rxu::decay_t<SourceOperator> source_operator_type;
55 typedef rxu::decay_t<Operator> operator_type;
57 typedef typename source_operator_type::value_type source_value_type;
60 template<
class ResultType,
class SourceOperator,
class Operator>
61 struct lift_operator :
public operator_base<typename lift_traits<ResultType, SourceOperator, Operator>::result_value_type>
63 typedef lift_traits<ResultType, SourceOperator, Operator> traits;
64 typedef typename traits::source_operator_type source_operator_type;
65 typedef typename traits::operator_type operator_type;
66 source_operator_type source;
69 lift_operator(source_operator_type s, operator_type op)
70 : source(std::move(s))
71 , chain(std::move(op))
74 template<
class Subscriber>
75 void on_subscribe(Subscriber o)
const {
76 auto lifted = chain(std::move(o));
78 source.on_subscribe(std::move(lifted));
83 template<
class ResultType,
class Operator>
86 typedef rxu::decay_t<Operator> operator_type;
89 lift_factory(operator_type op) : chain(std::move(op)) {}
90 template<
class Observable>
91 auto operator()(
const Observable& source)
92 -> decltype(source.template lift<ResultType>(chain)) {
93 return source.template lift<ResultType>(chain);
94 static_assert(rxcpp::detail::is_lift_function_for<rxu::value_type_t<Observable>, subscriber<ResultType>, Operator>::value,
"Function passed for lift() must have the signature subscriber<...>(subscriber<T, ...>)");
100 template<
class ResultType,
class Operator>
102 -> detail::lift_factory<ResultType, Operator> {
103 return detail::lift_factory<ResultType, Operator>(std::forward<Operator>(op));
Definition: rx-all.hpp:26
auto trace_activity() -> decltype(rxcpp_trace_activity(trace_tag()))&
Definition: rx-predef.hpp:15
auto lift(Operator &&op) -> detail::lift_factory< ResultType, Operator >
Definition: rx-lift.hpp:101