20 #if !defined(RXCPP_OPERATORS_RX_PAIRWISE_HPP) 21 #define RXCPP_OPERATORS_RX_PAIRWISE_HPP 23 #include "../rx-includes.hpp" 32 struct pairwise_invalid_arguments {};
35 struct pairwise_invalid :
public rxo::operator_base<pairwise_invalid_arguments<AN...>> {
36 using type = observable<pairwise_invalid_arguments<
AN...>, pairwise_invalid<
AN...>>;
39 using pairwise_invalid_t =
typename pairwise_invalid<
AN...>::type;
44 typedef rxu::decay_t<T> source_value_type;
45 typedef std::tuple<source_value_type, source_value_type> value_type;
47 template<
class Subscriber>
48 struct pairwise_observer
50 typedef pairwise_observer<Subscriber> this_type;
51 typedef std::tuple<source_value_type, source_value_type> value_type;
52 typedef rxu::decay_t<Subscriber> dest_type;
53 typedef observer<T, this_type> observer_type;
55 mutable rxu::detail::maybe<source_value_type> remembered;
57 pairwise_observer(dest_type d)
61 void on_next(source_value_type v)
const {
62 if (remembered.empty()) {
67 dest.on_next(std::make_tuple(remembered.get(), v));
70 void on_error(std::exception_ptr e)
const {
73 void on_completed()
const {
77 static subscriber<T, observer_type> make(dest_type d) {
78 auto cs = d.get_subscription();
79 return make_subscriber<T>(std::move(cs), observer_type(this_type(std::move(d))));
83 template<
class Subscriber>
84 auto operator()(Subscriber dest)
const 85 -> decltype(pairwise_observer<Subscriber>::make(std::move(dest))) {
86 return pairwise_observer<Subscriber>::make(std::move(dest));
97 return operator_factory<pairwise_tag,
AN...>(std::make_tuple(std::forward<AN>(an)...));
105 template<
class Observable,
109 class Pairwise = rxo::detail::pairwise<SourceValue>,
112 -> decltype(o.template lift<Value>(Pairwise())) {
113 return o.template lift<Value>(Pairwise());
116 template<
class...
AN>
117 static operators::detail::pairwise_invalid_t<
AN...>
member(
AN...) {
120 static_assert(
sizeof...(
AN) == 10000,
"pairwise takes no arguments");
static operators::detail::pairwise_invalid_t< AN... > member(AN...)
Definition: rx-pairwise.hpp:117
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
Definition: rx-operators.hpp:310
typename std::enable_if< all_true_type< BN... >::value >::type enable_if_all_true_type_t
Definition: rx-util.hpp:114
static auto member(Observable &&o) -> decltype(o.template lift< Value >(Pairwise()))
Definition: rx-pairwise.hpp:111
auto pairwise(AN &&...an) -> operator_factory< pairwise_tag, AN... >
Take values pairwise from this observable.
Definition: rx-pairwise.hpp:95
Definition: rx-predef.hpp:177