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) {
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>
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,
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)");