13#include <rpp/operators/fwd.hpp>
15#include <rpp/defs.hpp>
16#include <rpp/operators/details/strategy.hpp>
20namespace rpp::operators::details
22 template<rpp::constra
int::decayed_type Type, rpp::constra
int::observer TObserver, rpp::constra
int::decayed_type EqualityFn>
25 static constexpr auto preferred_disposables_mode = rpp::details::observers::disposables_mode::None;
27 RPP_NO_UNIQUE_ADDRESS TObserver observer;
28 RPP_NO_UNIQUE_ADDRESS EqualityFn comparator;
29 mutable std::optional<Type> last_value{};
32 void on_next(T&& v)
const
34 if (last_value.has_value() && comparator(utils::as_const(last_value.value()), rpp::utils::as_const(v)))
37 last_value.emplace(std::forward<T>(v));
38 observer.on_next(utils::as_const(last_value.value()));
41 void on_error(
const std::exception_ptr& err)
const { observer.on_error(err); }
43 void on_completed()
const { observer.on_completed(); }
47 bool is_disposed()
const {
return observer.is_disposed(); }
50 template<rpp::constra
int::decayed_type EqualityFn>
55 template<rpp::constra
int::decayed_type T>
60 using result_type = T;
62 template<rpp::constra
int::observer_of_type<result_type> TObserver>
66 template<rpp::details::observables::constra
int::disposables_strategy Prev>
67 using updated_optimal_disposables_strategy = Prev;
71namespace rpp::operators
99 template<
typename EqualityFn>
Definition strategy.hpp:28
Definition constraints.hpp:50
Definition function_traits.hpp:45
disposable_wrapper_impl< interface_disposable > disposable_wrapper
Wrapper to keep "simple" disposable. Specialization of rpp::disposable_wrapper_impl.
Definition fwd.hpp:34
auto distinct_until_changed(EqualityFn &&equality_fn)
Suppress consecutive duplicates of emissions from original observable.
Definition distinct_until_changed.hpp:97
Definition distinct_until_changed.hpp:24
Definition distinct_until_changed.hpp:57
Definition distinct_until_changed.hpp:52