20 #if !defined(RXCPP_OPERATORS_RX_MAP_HPP) 21 #define RXCPP_OPERATORS_RX_MAP_HPP 23 #include "../rx-includes.hpp" 32 struct map_invalid_arguments {};
35 struct map_invalid :
public rxo::operator_base<map_invalid_arguments<AN...>> {
36 using type = observable<map_invalid_arguments<
AN...>, map_invalid<
AN...>>;
39 using map_invalid_t =
typename map_invalid<
AN...>::type;
41 template<
class T,
class Selector>
44 typedef rxu::decay_t<T> source_value_type;
45 typedef rxu::decay_t<Selector> select_type;
46 typedef decltype((*(select_type*)
nullptr)(*(source_value_type*)
nullptr)) value_type;
50 : selector(std::move(s))
54 template<
class Subscriber>
57 typedef map_observer<Subscriber> this_type;
58 typedef decltype((*(select_type*)
nullptr)(*(source_value_type*)
nullptr)) value_type;
59 typedef rxu::decay_t<Subscriber> dest_type;
60 typedef observer<source_value_type, this_type> observer_type;
62 mutable select_type selector;
64 map_observer(dest_type d, select_type s)
66 , selector(std::move(s))
70 void on_next(Value&& v)
const {
73 return this->selector(std::forward<Value>(v));},
75 if (selected.empty()) {
78 dest.on_next(std::move(selected.get()));
80 void on_error(std::exception_ptr e)
const {
83 void on_completed()
const {
87 static subscriber<source_value_type, observer_type> make(dest_type d, select_type s) {
88 auto cs = d.get_subscription();
89 return make_subscriber<source_value_type>(std::move(cs), observer_type(this_type(std::move(d), std::move(s))));
93 template<
class Subscriber>
94 auto operator()(Subscriber dest)
const 95 -> decltype(map_observer<Subscriber>::make(std::move(dest), selector)) {
96 return map_observer<Subscriber>::make(std::move(dest), selector);
104 template<
class...
AN>
112 template<
class...
AN>
123 template<
class Observable,
class Selector,
128 class Map = rxo::detail::map<SourceValue, ResolvedSelector>,
130 static auto member(Observable&& o, Selector&& s)
131 -> decltype(o.template lift<Value>(Map(std::forward<Selector>(s)))) {
132 return o.template lift<Value>(Map(std::forward<Selector>(s)));
135 template<
class...
AN>
136 static operators::detail::map_invalid_t<
AN...>
member(
const AN...) {
139 static_assert(
sizeof...(
AN) == 10000,
"map takes Selector");
Definition: rx-operators.hpp:248
Definition: rx-all.hpp:26
typename std::decay< T >::type::value_type value_type_t
Definition: rx-util.hpp:35
auto map(AN &&...an) -> operator_factory< map_tag, AN... >
For each item from this observable use Selector to produce an item to emit from the new observable th...
Definition: rx-map.hpp:105
Definition: rx-operators.hpp:69
auto AN
Definition: rx-finally.hpp:105
typename std::decay< T >::type decay_t
Definition: rx-util.hpp:36
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::map_invalid_t< AN... > member(const AN...)
Definition: rx-map.hpp:136
auto on_exception(const F &f, const OnError &c) -> typename std::enable_if< detail::is_on_error< OnError >::value, typename detail::maybe_from_result< F >::type >::type
Definition: rx-observer.hpp:639
auto transform(AN &&...an) -> operator_factory< map_tag, AN... >
For each item from this observable use Selector to produce an item to emit from the new observable th...
Definition: rx-map.hpp:113
Definition: rx-predef.hpp:177
static auto member(Observable &&o, Selector &&s) -> decltype(o.template lift< Value >(Map(std::forward< Selector >(s))))
Definition: rx-map.hpp:130