ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
distinct_until_changed.hpp
1// ReactivePlusPlus library
2//
3// Copyright Aleksey Loginov 2022 - present.
4// Distributed under the Boost Software License, Version 1.0.
5// (See accompanying file LICENSE_1_0.txt or copy at
6// https://www.boost.org/LICENSE_1_0.txt)
7//
8// Project home: https://github.com/victimsnino/ReactivePlusPlus
9//
10
11#pragma once
12
13#include <rpp/observables/details/member_overload.hpp> // member_overload
14
15#include <concepts>
16#include <functional>
17
18namespace rpp::details
19{
20struct distinct_until_changed_tag;
21}
22
23namespace rpp::details
24{
25template<constraint::decayed_type Type, std::equivalence_relation<Type, Type> EqualityFn>
26struct distinct_until_changed_impl;
27
28template<constraint::decayed_type Type, typename SpecificObservable>
29struct member_overload<Type, SpecificObservable, distinct_until_changed_tag>
30{
64 template<std::equivalence_relation<Type, Type> EqualityFn = std::equal_to<Type>>
65 auto distinct_until_changed(EqualityFn&& equality_fn = EqualityFn{}) const & requires is_header_included<distinct_until_changed_tag, EqualityFn>
66 {
67 return static_cast<const SpecificObservable*>(this)->template lift<Type>(distinct_until_changed_impl<Type, std::decay_t<EqualityFn>>{std::forward<EqualityFn>(equality_fn)});
68 }
69
70 template<std::equivalence_relation<Type, Type> EqualityFn = std::equal_to<Type>>
71 auto distinct_until_changed(EqualityFn&& equality_fn = EqualityFn{}) && requires is_header_included<distinct_until_changed_tag, EqualityFn>
72 {
73 return std::move(*static_cast<SpecificObservable*>(this)).template lift<Type>(distinct_until_changed_impl <Type, std::decay_t<EqualityFn>>{std::forward<EqualityFn>(equality_fn)});
74 }
75};
76} // namespace rpp::details
Definition: distinct_until_changed.hpp:54
Definition: member_overload.hpp:19