13#include <rpp/observables/details/member_overload.hpp>
23template<
typename Fn,
typename Result,
typename Type>
24concept reduce_accumulator = std::is_invocable_r_v<std::decay_t<Result>, Fn, std::decay_t<Result>, std::decay_t<Type>>;
29 { t + t } -> std::convertible_to<T>;
32template<
typename T,
typename CastBeforeDrop>
38template<constra
int::decayed_type Type, constra
int::decayed_type Seed, reduce_accumulator<Seed, Type> AccumulatorFn, std::invocable<Seed&&> ResultSelectorFn>
41template<constra
int::decayed_type CastBeforeDiv
ide, constra
int::observable TObs>
42auto average_impl(TObs&& observable);
44template<constra
int::observable TObs>
45auto sum_impl(TObs&& observable);
47template<constra
int::observable TObs>
48auto count_impl(TObs&& observable);
50template<constra
int::observable TObs,
typename Comparator>
51auto min_impl(TObs&& observable, Comparator&& comparator);
53template<constra
int::observable TObs,
typename Comparator>
54auto max_impl(TObs&& observable, Comparator&& comparator);
56template<constra
int::decayed_type Type,
typename SpecificObservable>
93 template<
typename Seed, reduce_accumulator<Seed, Type> AccumulatorFn, std::invocable<Seed&&> ResultSelectorFn = std::
identity>
94 auto reduce(Seed&& initial_seed, AccumulatorFn&& accumulator, ResultSelectorFn&& result_selector = {})
const &
requires is_header_included<reduce_tag, Seed, AccumulatorFn, ResultSelectorFn>
96 return static_cast<const SpecificObservable*
>(
this)->
template lift<utils::decayed_invoke_result_t<ResultSelectorFn, std::decay_t<Seed>>>(
97 reduce_impl<Type, std::decay_t<Seed>, std::decay_t<AccumulatorFn>, std::decay_t<ResultSelectorFn>>{
98 std::forward<Seed>(initial_seed),
99 std::forward<AccumulatorFn>(accumulator),
100 std::forward<ResultSelectorFn>(result_selector)});
103 template<
typename Seed, reduce_accumulator<Seed, Type> AccumulatorFn, std::invocable<Seed&&> ResultSelectorFn = std::
identity>
104 auto reduce(Seed&& initial_seed, AccumulatorFn&& accumulator, ResultSelectorFn&& result_selector = {}) &&
requires is_header_included<reduce_tag, Seed, AccumulatorFn, ResultSelectorFn>
106 return std::move(*
static_cast<SpecificObservable*
>(
this)).template lift<utils::decayed_invoke_result_t<ResultSelectorFn, std::decay_t<Seed>>>(
108 std::forward<Seed>(initial_seed),
109 std::forward<AccumulatorFn>(accumulator),
110 std::forward<ResultSelectorFn>(result_selector)});
134 template<
typename CastBeforeDivide = Type,
typename ...Args>
137 return average_impl<CastBeforeDivide>(*
static_cast<const SpecificObservable*
>(
this));
140 template<
typename CastBeforeDivide = Type,
typename ...Args>
143 return average_impl<CastBeforeDivide>(std::move(*
static_cast<SpecificObservable*
>(
this)));
167 template<
typename ...Args>
170 return sum_impl(*
static_cast<const SpecificObservable*
>(
this));
173 template<
typename ...Args>
176 return sum_impl(std::move(*
static_cast<SpecificObservable*
>(
this)));
197 template<
typename ...Args>
198 auto count()
const &
requires is_header_included<reduce_tag, Args...>
200 return count_impl(*
static_cast<const SpecificObservable*
>(
this));
203 template<
typename ...Args>
204 auto count() &&
requires is_header_included<reduce_tag, Args...>
206 return count_impl(std::move(*
static_cast<SpecificObservable*
>(
this)));
230 template<std::strict_weak_order<Type, Type> Comparator = std::less<Type>,
typename ...Args>
231 auto min(Comparator&& comparator = {})
const &
requires is_header_included<reduce_tag, Comparator, Args...>
233 return min_impl(*
static_cast<const SpecificObservable*
>(
this), std::forward<Comparator>(comparator));
236 template<std::strict_weak_order<Type, Type> Comparator = std::less<Type>,
typename ...Args>
237 auto min(Comparator&& comparator = {}) &&
requires is_header_included<reduce_tag, Comparator, Args...>
239 return min_impl(std::move(*
static_cast<SpecificObservable*
>(
this)), std::forward<Comparator>(comparator));
263 template<std::strict_weak_order<Type, Type> Comparator = std::less<Type>,
typename ...Args>
264 auto max(Comparator&& comparator = {})
const &
requires is_header_included<reduce_tag, Comparator, Args...>
266 return max_impl(*
static_cast<const SpecificObservable*
>(
this), std::forward<Comparator>(comparator));
269 template<std::strict_weak_order<Type, Type> Comparator = std::less<Type>,
typename ...Args>
270 auto max(Comparator&& comparator = {}) &&
requires is_header_included<reduce_tag, Comparator, Args...>
272 return max_impl(std::move(*
static_cast<SpecificObservable*
>(
this)), std::forward<Comparator>(comparator));
Definition: reduce.hpp:33
Definition: reduce.hpp:27
Definition: reduce.hpp:24
Definition: member_overload.hpp:19
Definition: reduce.hpp:67