26 #if !defined(RXCPP_OPERATORS_RX_TAP_HPP) 27 #define RXCPP_OPERATORS_RX_TAP_HPP 29 #include "../rx-includes.hpp" 38 struct tap_invalid_arguments {};
41 struct tap_invalid :
public rxo::operator_base<tap_invalid_arguments<AN...>> {
42 using type = observable<tap_invalid_arguments<
AN...>, tap_invalid<
AN...>>;
45 using tap_invalid_t =
typename tap_invalid<
AN...>::type;
47 template<
class T,
class MakeObserverArgN>
48 struct tap_observer_factory;
50 template<
class T,
class... ArgN>
51 struct tap_observer_factory<T, std::tuple<ArgN...>>
53 using source_value_type = rxu::decay_t<T>;
54 using out_type = decltype(make_observer<source_value_type, rxcpp::detail::OnErrorIgnore>(*((ArgN*)
nullptr)...));
55 auto operator()(ArgN&&... an) -> out_type
const {
56 return make_observer<source_value_type, rxcpp::detail::OnErrorIgnore>(std::forward<ArgN>(an)...);
60 template<
class T,
class MakeObserverArgN,
class Factory = tap_observer_factory<T, MakeObserverArgN>>
63 using source_value_type = rxu::decay_t<T>;
64 using args_type = rxu::decay_t<MakeObserverArgN>;
65 using factory_type = Factory;
66 using out_type =
typename factory_type::out_type;
70 : out(rxu::apply(std::move(a), factory_type()))
74 template<
class Subscriber>
77 using this_type = tap_observer<Subscriber>;
78 using value_type = source_value_type;
79 using dest_type = rxu::decay_t<Subscriber>;
80 using factory_type = Factory;
81 using out_type =
typename factory_type::out_type;
82 using observer_type = observer<value_type, this_type>;
86 tap_observer(dest_type d, out_type o)
91 void on_next(source_value_type v)
const {
95 void on_error(std::exception_ptr e)
const {
99 void on_completed()
const {
104 static subscriber<value_type, observer<value_type, this_type>> make(dest_type d, out_type o) {
105 return make_subscriber<value_type>(d, this_type(d, std::move(o)));
109 template<
class Subscriber>
110 auto operator()(Subscriber dest)
const 111 -> decltype(tap_observer<Subscriber>::make(std::move(dest), out)) {
112 return tap_observer<Subscriber>::make(std::move(dest), out);
120 template<
class...
AN>
131 template<
class Observable,
class... MakeObserverArgN,
135 class Tap = rxo::detail::tap<SourceValue, std::tuple<rxu::decay_t<MakeObserverArgN>...>>>
136 static auto member(Observable&& o, MakeObserverArgN&&... an)
137 -> decltype(o.template lift<SourceValue>(Tap(std::make_tuple(std::forward<MakeObserverArgN>(an)...)))) {
138 return o.template lift<SourceValue>(Tap(std::make_tuple(std::forward<MakeObserverArgN>(an)...)));
141 template<
class...
AN>
142 static operators::detail::tap_invalid_t<
AN...>
member(
const AN&...) {
145 static_assert(
sizeof...(
AN) == 10000,
"tap takes (MakeObserverArgN...)");
Definition: rx-operators.hpp:445
Definition: rx-all.hpp:26
typename std::decay< T >::type::value_type value_type_t
Definition: rx-util.hpp:35
Definition: rx-operators.hpp:69
auto AN
Definition: rx-finally.hpp:105
Definition: rx-operators.hpp:47
typename std::enable_if< all_true_type< BN... >::value >::type enable_if_all_true_type_t
Definition: rx-util.hpp:114
static operators::detail::tap_invalid_t< AN... > member(const AN &...)
Definition: rx-tap.hpp:142
static auto member(Observable &&o, MakeObserverArgN &&...an) -> decltype(o.template lift< SourceValue >(Tap(std::make_tuple(std::forward< MakeObserverArgN >(an)...))))
Definition: rx-tap.hpp:136
auto tap(AN &&...an) -> operator_factory< tap_tag, AN... >
inspect calls to on_next, on_error and on_completed.
Definition: rx-tap.hpp:121
Definition: rx-predef.hpp:177