29 #if !defined(RXCPP_OPERATORS_RX_ANY_HPP) 30 #define RXCPP_OPERATORS_RX_ANY_HPP 32 #include "../rx-includes.hpp" 41 struct any_invalid_arguments {};
44 struct any_invalid :
public rxo::operator_base<any_invalid_arguments<AN...>> {
45 using type = observable<any_invalid_arguments<
AN...>, any_invalid<
AN...>>;
48 using any_invalid_t =
typename any_invalid<
AN...>::type;
50 template<
class T,
class Predicate>
53 typedef rxu::decay_t<T> source_value_type;
54 typedef bool value_type;
55 typedef rxu::decay_t<Predicate> test_type;
63 template<
class Subscriber>
66 typedef any_observer<Subscriber> this_type;
67 typedef source_value_type value_type;
68 typedef rxu::decay_t<Subscriber> dest_type;
69 typedef observer<value_type, this_type> observer_type;
74 any_observer(dest_type d, test_type t)
80 void on_next(source_value_type v)
const {
82 return !this->test(v); },
84 if (filtered.empty()) {
87 if (!filtered.get() && !done) {
93 void on_error(std::exception_ptr e)
const {
96 void on_completed()
const {
104 static subscriber<value_type, observer_type> make(dest_type d, test_type t) {
105 return make_subscriber<value_type>(d, this_type(d, std::move(t)));
109 template<
class Subscriber>
110 auto operator()(Subscriber dest)
const 111 -> decltype(any_observer<Subscriber>::make(std::move(dest), test)) {
112 return any_observer<Subscriber>::make(std::move(dest), test);
120 template<
class...
AN>
138 template<
class...
AN>
156 template<
class...
AN>
159 return operator_factory<contains_tag,
AN...>(std::make_tuple(std::forward<AN>(an)...));
167 template<
class Observable,
class Predicate,
171 class Any = rxo::detail::any<SourceValue, rxu::decay_t<Predicate>>,
173 static auto member(Observable&& o, Predicate&& p)
174 -> decltype(o.template lift<Value>(Any(std::forward<Predicate>(p)))) {
175 return o.template lift<Value>(Any(std::forward<Predicate>(p)));
178 template<
class...
AN>
179 static operators::detail::any_invalid_t<
AN...>
member(
const AN&...) {
182 static_assert(
sizeof...(
AN) == 10000,
"any takes (Predicate)");
192 template<
class...
AN>
193 static operators::detail::any_invalid_t<
AN...>
member(
const AN&...) {
196 static_assert(
sizeof...(
AN) == 10000,
"exists takes (Predicate)");
203 template<
class Observable,
class T,
206 is_observable<Observable>>,
207 class Predicate = std::function<bool(T)>,
208 class Any = rxo::detail::any<SourceValue, rxu::decay_t<Predicate>>,
210 static auto member(Observable&& o, T&& value)
211 -> decltype(o.template lift<Value>(Any(
nullptr))) {
212 return o.template lift<Value>(Any([value](T n) {
return n == value; }));
215 template<
class...
AN>
216 static operators::detail::any_invalid_t<
AN...>
member(
const AN&...) {
219 static_assert(
sizeof...(
AN) == 10000,
"contains takes (T)");
Definition: rx-operators.hpp:126
static auto member(Observable &&o, Predicate &&p) -> decltype(o.template lift< Value >(Any(std::forward< Predicate >(p))))
Definition: rx-any.hpp:173
auto any(AN &&...an) -> operator_factory< any_tag, AN... >
Returns an Observable that emits true if any item emitted by the source Observable satisfies a specif...
Definition: rx-any.hpp:121
auto contains(AN &&...an) -> operator_factory< contains_tag, AN... >
Returns an Observable that emits true if the source Observable emitted a specified item...
Definition: rx-any.hpp:157
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
static operators::detail::any_invalid_t< AN... > member(const AN &...)
Definition: rx-any.hpp:179
Definition: rx-operators.hpp:47
static operators::detail::any_invalid_t< AN... > member(const AN &...)
Definition: rx-any.hpp:193
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, T &&value) -> decltype(o.template lift< Value >(Any(nullptr)))
Definition: rx-any.hpp:210
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 exists(AN &&...an) -> operator_factory< exists_tag, AN... >
Returns an Observable that emits true if any item emitted by the source Observable satisfies a specif...
Definition: rx-any.hpp:139
Definition: rx-operators.hpp:119
Definition: rx-operators.hpp:127
static operators::detail::any_invalid_t< AN... > member(const AN &...)
Definition: rx-any.hpp:216
Definition: rx-predef.hpp:177