Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/rpp/rpp/disposables/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#pragma once

#include <rpp/utils/constraints.hpp>
#include <rpp/utils/function_traits.hpp>

namespace rpp::details
{
Expand Down
2 changes: 1 addition & 1 deletion src/rpp/rpp/operators/combine_latest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace rpp::operators
* @see https://reactivex.io/documentation/operators/combinelatest.html
*/
template<typename TSelector, rpp::constraint::observable TObservable, rpp::constraint::observable... TObservables>
requires (!rpp::constraint::observable<TSelector> && (!utils::is_not_template_callable<TSelector> || std::invocable<TSelector, rpp::utils::convertible_to_any, utils::extract_observable_type_t<TObservable>, utils::extract_observable_type_t<TObservables>...>))
requires (!rpp::constraint::observable<TSelector> && (constraint::template_callable_or_invocable<TSelector, rpp::utils::convertible_to_any, utils::extract_observable_type_t<TObservable>, utils::extract_observable_type_t<TObservables>...>))
auto combine_latest(TSelector&& selector, TObservable&& observable, TObservables&&... observables)
{
return details::combine_latest_t<std::decay_t<TSelector>, std::decay_t<TObservable>, std::decay_t<TObservables>...>{
Expand Down
4 changes: 2 additions & 2 deletions src/rpp/rpp/operators/distinct_until_changed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace rpp::operators::details
template<rpp::constraint::decayed_type T>
struct operator_traits
{
static_assert(rpp::constraint::invocable_r_v<bool, EqualityFn, T, T>, "EqualityFn is not invocable with T and T returning bool");
static_assert(rpp::constraint::invocable_ret<bool, EqualityFn, T, T>, "EqualityFn is not invocable with T and T returning bool");

using result_type = T;

Expand Down Expand Up @@ -97,9 +97,9 @@ namespace rpp::operators
* @see https://reactivex.io/documentation/operators/distinct.html
*/
template<typename EqualityFn>
requires (!utils::is_not_template_callable<EqualityFn> || std::same_as<bool, std::invoke_result_t<EqualityFn, rpp::utils::convertible_to_any, rpp::utils::convertible_to_any>>)
auto distinct_until_changed(EqualityFn&& equality_fn)
{
static_assert(constraint::template_callable_or_invocable_ret<bool, EqualityFn, rpp::utils::convertible_to_any, rpp::utils::convertible_to_any>, "EqualityFn is not invocable with T and T returning bool");
return details::distinct_until_changed_t<std::decay_t<EqualityFn>>{std::forward<EqualityFn>(equality_fn)};
}
} // namespace rpp::operators
2 changes: 1 addition & 1 deletion src/rpp/rpp/operators/filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ namespace rpp::operators
* @see https://reactivex.io/documentation/operators/filter.html
*/
template<typename Fn>
requires (!utils::is_not_template_callable<Fn> || std::same_as<bool, std::invoke_result_t<Fn, rpp::utils::convertible_to_any>>)
auto filter(Fn&& predicate)
{
static_assert(constraint::template_callable_or_invocable_ret<bool, Fn, rpp::utils::convertible_to_any>, "Fn is not invocable with T returning bool");
return details::filter_t<std::decay_t<Fn>>{std::forward<Fn>(predicate)};
}
} // namespace rpp::operators
2 changes: 1 addition & 1 deletion src/rpp/rpp/operators/flat_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ namespace rpp::operators
* @see https://reactivex.io/documentation/operators/flatmap.html
*/
template<typename Fn>
requires (!utils::is_not_template_callable<Fn> || rpp::constraint::observable<std::invoke_result_t<Fn, rpp::utils::convertible_to_any>>)
auto flat_map(Fn&& callable)
{
static_assert(!constraint::is_not_template_callable<Fn> || rpp::constraint::observable<std::invoke_result_t<Fn, rpp::utils::convertible_to_any>>, "Fn is not invocable with T returning observable");
return details::flat_map_t<std::decay_t<Fn>>{std::forward<Fn>(callable)};
}

Expand Down
35 changes: 9 additions & 26 deletions src/rpp/rpp/operators/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace rpp::operators
auto concat();

template<typename TSelector, rpp::constraint::observable TObservable, rpp::constraint::observable... TObservables>
requires (!rpp::constraint::observable<TSelector> && (!utils::is_not_template_callable<TSelector> || std::invocable<TSelector, rpp::utils::convertible_to_any, utils::extract_observable_type_t<TObservable>, utils::extract_observable_type_t<TObservables>...>))
requires (!rpp::constraint::observable<TSelector> && (constraint::template_callable_or_invocable<TSelector, rpp::utils::convertible_to_any, utils::extract_observable_type_t<TObservable>, utils::extract_observable_type_t<TObservables>...>))
auto combine_latest(TSelector&& selector, TObservable&& observable, TObservables&&... observables);

template<rpp::constraint::observable TObservable, rpp::constraint::observable... TObservables>
Expand All @@ -42,35 +42,27 @@ namespace rpp::operators
auto distinct();

template<typename EqualityFn = rpp::utils::equal_to>
requires (!utils::is_not_template_callable<EqualityFn> || std::same_as<bool, std::invoke_result_t<EqualityFn, rpp::utils::convertible_to_any, rpp::utils::convertible_to_any>>)
auto distinct_until_changed(EqualityFn&& equality_fn = {});

auto element_at(size_t index);

auto first();

template<typename Fn>
requires (!utils::is_not_template_callable<Fn> || std::same_as<bool, std::invoke_result_t<Fn, rpp::utils::convertible_to_any>>)
auto filter(Fn&& predicate);

template<std::invocable<> LastFn>
auto finally(LastFn&& lastFn);

template<typename Fn>
requires (!utils::is_not_template_callable<Fn> || rpp::constraint::observable<std::invoke_result_t<Fn, rpp::utils::convertible_to_any>>)
auto flat_map(Fn&& callable);

template<typename KeySelector,
typename ValueSelector = std::identity,
typename KeyComparator = rpp::utils::less>
requires (
(!utils::is_not_template_callable<KeySelector> || !std::same_as<void, std::invoke_result_t<KeySelector, rpp::utils::convertible_to_any>>) && (!utils::is_not_template_callable<ValueSelector> || !std::same_as<void, std::invoke_result_t<ValueSelector, rpp::utils::convertible_to_any>>) && (!utils::is_not_template_callable<KeyComparator> || std::strict_weak_order<KeyComparator, rpp::utils::convertible_to_any, rpp::utils::convertible_to_any>))
template<typename KeySelector, typename ValueSelector = std::identity, typename KeyComparator = rpp::utils::less>
auto group_by(KeySelector&& key_selector, ValueSelector&& value_selector = {}, KeyComparator&& comparator = {});

auto last();

template<typename Fn>
requires (!utils::is_not_template_callable<Fn> || !std::same_as<void, std::invoke_result_t<Fn, rpp::utils::convertible_to_any>>)
auto map(Fn&& callable);

template<rpp::constraint::subject Subject>
Expand All @@ -79,13 +71,9 @@ namespace rpp::operators
template<template<typename> typename Subject = rpp::subjects::publish_subject>
auto multicast();

template<typename Fn>
requires (!utils::is_not_template_callable<Fn> || rpp::constraint::observable<std::invoke_result_t<Fn, rpp::utils::convertible_to_any>>)
auto flat_map(Fn&& callable);

template<rpp::constraint::observable TObservable, rpp::constraint::observable... TObservables>
requires constraint::observables_of_same_type<std::decay_t<TObservable>, std::decay_t<TObservables>...>
auto merge_with(TObservable&& observable, TObservables&&... observables);

auto merge();

template<rpp::schedulers::constraint::scheduler Scheduler>
Expand All @@ -94,7 +82,6 @@ namespace rpp::operators
auto publish();

template<typename Seed, typename Accumulator>
requires (!utils::is_not_template_callable<Accumulator> || std::same_as<std::decay_t<Seed>, std::invoke_result_t<Accumulator, std::decay_t<Seed> &&, rpp::utils::convertible_to_any>>)
auto reduce(Seed&& seed, Accumulator&& accumulator);

template<typename Accumulator>
Expand All @@ -110,9 +97,8 @@ namespace rpp::operators

auto retry();

template<typename InitialValue, typename Fn>
requires (!utils::is_not_template_callable<Fn> || std::same_as<std::decay_t<InitialValue>, std::invoke_result_t<Fn, std::decay_t<InitialValue> &&, rpp::utils::convertible_to_any>>)
auto scan(InitialValue&& initial_value, Fn&& accumulator);
template<typename Seed, typename Fn>
auto scan(Seed&& seed, Fn&& accumulator);

template<typename Fn>
auto scan(Fn&& accumulator);
Expand Down Expand Up @@ -149,14 +135,13 @@ namespace rpp::operators
auto take_last(size_t count);

template<typename Fn>
requires (!utils::is_not_template_callable<Fn> || std::same_as<bool, std::invoke_result_t<Fn, rpp::utils::convertible_to_any>>)
auto take_while(Fn&& predicate);

template<rpp::constraint::observable TObservable>
auto take_until(TObservable&& until_observable);

template<std::invocable<const std::exception_ptr&> OnError = rpp::utils::empty_function_t<std::exception_ptr>>
requires utils::is_not_template_callable<OnError>
requires (constraint::is_not_template_callable<OnError>)
auto tap(OnError&& on_error);

template<std::invocable<> OnCompleted = rpp::utils::empty_function_t<>>
Expand All @@ -170,7 +155,7 @@ namespace rpp::operators
template<typename OnNext = rpp::utils::empty_function_any_t,
std::invocable<const std::exception_ptr&> OnError = rpp::utils::empty_function_t<std::exception_ptr>,
std::invocable<> OnCompleted = rpp::utils::empty_function_t<>>
requires utils::is_not_template_callable<OnError>
requires (constraint::is_not_template_callable<OnError>)
auto tap(OnNext&& on_next = {},
OnError&& on_error = {},
OnCompleted&& on_completed = {});
Expand All @@ -185,15 +170,13 @@ namespace rpp::operators
auto throttle(rpp::schedulers::duration period);

template<typename Selector>
requires rpp::constraint::observable<std::invoke_result_t<Selector, std::exception_ptr>>
auto on_error_resume_next(Selector&& selector);

template<typename Notifier>
requires rpp::constraint::observable<std::invoke_result_t<Notifier, std::exception_ptr>>
auto retry_when(Notifier&& notifier);

template<typename TSelector, rpp::constraint::observable TObservable, rpp::constraint::observable... TObservables>
requires (!rpp::constraint::observable<TSelector> && (!utils::is_not_template_callable<TSelector> || std::invocable<TSelector, rpp::utils::convertible_to_any, utils::extract_observable_type_t<TObservable>, utils::extract_observable_type_t<TObservables>...>))
requires (!rpp::constraint::observable<TSelector> && (constraint::template_callable_or_invocable<TSelector, rpp::utils::convertible_to_any, utils::extract_observable_type_t<TObservable>, utils::extract_observable_type_t<TObservables>...>))
auto with_latest_from(TSelector&& selector, TObservable&& observable, TObservables&&... observables);

template<rpp::constraint::observable TObservable, rpp::constraint::observable... TObservables>
Expand All @@ -206,7 +189,7 @@ namespace rpp::operators
auto window_toggle(TOpeningsObservable&& openings, TClosingsSelectorFn&& closings_selector);

template<typename TSelector, rpp::constraint::observable TObservable, rpp::constraint::observable... TObservables>
requires (!rpp::constraint::observable<TSelector> && (!utils::is_not_template_callable<TSelector> || std::invocable<TSelector, rpp::utils::convertible_to_any, utils::extract_observable_type_t<TObservable>, utils::extract_observable_type_t<TObservables>...>))
requires (!rpp::constraint::observable<TSelector> && (constraint::template_callable_or_invocable<TSelector, rpp::utils::convertible_to_any, utils::extract_observable_type_t<TObservable>, utils::extract_observable_type_t<TObservables>...>))
auto zip(TSelector&& selector, TObservable&& observable, TObservables&&... observables);

template<rpp::constraint::observable TObservable, rpp::constraint::observable... TObservables>
Expand Down
6 changes: 4 additions & 2 deletions src/rpp/rpp/operators/group_by.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,12 @@ namespace rpp::operators
template<typename KeySelector,
typename ValueSelector,
typename KeyComparator>
requires (
(!utils::is_not_template_callable<KeySelector> || !std::same_as<void, std::invoke_result_t<KeySelector, rpp::utils::convertible_to_any>>) && (!utils::is_not_template_callable<ValueSelector> || !std::same_as<void, std::invoke_result_t<ValueSelector, rpp::utils::convertible_to_any>>) && (!utils::is_not_template_callable<KeyComparator> || std::strict_weak_order<KeyComparator, rpp::utils::convertible_to_any, rpp::utils::convertible_to_any>))
auto group_by(KeySelector&& key_selector, ValueSelector&& value_selector, KeyComparator&& comparator)
{
static_assert(constraint::template_callable_or_invocable_ret_non_void<KeySelector, rpp::utils::convertible_to_any>, "KeySelector is not invocable with T returning non-void");
static_assert(constraint::template_callable_or_invocable_ret_non_void<ValueSelector, rpp::utils::convertible_to_any>, "ValueSelector is not invocable with T returning non-void");
static_assert(!constraint::is_not_template_callable<KeyComparator> || std::strict_weak_order<KeyComparator, rpp::utils::convertible_to_any, rpp::utils::convertible_to_any>, "KeyComparator is not invocable with (result of KeySelector, result of KeySelector) returning bool");

return details::group_by_t<std::decay_t<KeySelector>, std::decay_t<ValueSelector>, std::decay_t<KeyComparator>>{
std::forward<KeySelector>(key_selector),
std::forward<ValueSelector>(value_selector),
Expand Down
2 changes: 1 addition & 1 deletion src/rpp/rpp/operators/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ namespace rpp::operators
* @see https://reactivex.io/documentation/operators/map.html
*/
template<typename Fn>
requires (!utils::is_not_template_callable<Fn> || !std::same_as<void, std::invoke_result_t<Fn, rpp::utils::convertible_to_any>>)
auto map(Fn&& callable)
{
static_assert(constraint::template_callable_or_invocable_ret_non_void<Fn, rpp::utils::convertible_to_any>, "Fn is not invocable with T returning non-void");
return details::map_t<std::decay_t<Fn>>{std::forward<Fn>(callable)};
}
} // namespace rpp::operators
2 changes: 1 addition & 1 deletion src/rpp/rpp/operators/merge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ namespace rpp::operators
* @see https://reactivex.io/documentation/operators/merge.html
*/
template<rpp::constraint::observable TObservable, rpp::constraint::observable... TObservables>
requires constraint::observables_of_same_type<std::decay_t<TObservable>, std::decay_t<TObservables>...>
auto merge_with(TObservable&& observable, TObservables&&... observables)
{
static_assert(constraint::observables_of_same_type<std::decay_t<TObservable>, std::decay_t<TObservables>...>, "observables should be of same type");
return details::merge_with_t<std::decay_t<TObservable>, std::decay_t<TObservables>...>{
rpp::utils::tuple{std::forward<TObservable>(observable), std::forward<TObservables>(observables)...}};
}
Expand Down
2 changes: 1 addition & 1 deletion src/rpp/rpp/operators/on_error_resume_next.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ namespace rpp::operators
* @see https://reactivex.io/documentation/operators/catch.html
*/
template<typename Selector>
requires rpp::constraint::observable<std::invoke_result_t<Selector, std::exception_ptr>>
auto on_error_resume_next(Selector&& selector)
{
static_assert(rpp::constraint::observable<std::invoke_result_t<Selector, std::exception_ptr>>, "Selector is not invocable with std::exception_ptr returning new observable");
return details::on_error_resume_next_t<std::decay_t<Selector>>{std::forward<Selector>(selector)};
}
} // namespace rpp::operators
5 changes: 2 additions & 3 deletions src/rpp/rpp/operators/reduce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ namespace rpp::operators
operator "reduce: s=10, (s,x)=>s+x" : +------16|
}
*
* @param initial_value initial value for seed
* @param seed initial value for seed
* @param accumulator function which accepts seed value and new value from observable and return new value of seed. Can accept seed by move-reference.
*
* @warning #include <rpp/operators/reduce.hpp>
Expand All @@ -143,9 +143,9 @@ namespace rpp::operators
* @see https://reactivex.io/documentation/operators/reduce.html
*/
template<typename Seed, typename Accumulator>
requires (!utils::is_not_template_callable<Accumulator> || std::same_as<std::decay_t<Seed>, std::invoke_result_t<Accumulator, std::decay_t<Seed> &&, rpp::utils::convertible_to_any>>)
auto reduce(Seed&& seed, Accumulator&& accumulator)
{
static_assert(constraint::template_callable_or_invocable_ret<std::decay_t<Seed>, std::invoke_result_t<Accumulator, std::decay_t<Seed>&&, rpp::utils::convertible_to_any>>, "Accumulator is not invocable with Seed&& and T returning Seed");
return details::reduce_t<std::decay_t<Seed>, std::decay_t<Accumulator>>{std::forward<Seed>(seed), std::forward<Accumulator>(accumulator)};
}

Expand All @@ -160,7 +160,6 @@ namespace rpp::operators
*
* @details There is no initial value for seed, so, first value would be used as seed value and forwarded as is.
*
* @param initial_value initial value for seed
* @param accumulator function which accepts seed value and new value from observable and return new value of seed. Can accept seed by move-reference.
*
* @warning #include <rpp/operators/reduce.hpp>
Expand Down
2 changes: 1 addition & 1 deletion src/rpp/rpp/operators/retry_when.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ namespace rpp::operators
* @see https://reactivex.io/documentation/operators/retry.html
*/
template<typename TNotifier>
requires rpp::constraint::observable<std::invoke_result_t<TNotifier, std::exception_ptr>>
auto retry_when(TNotifier&& notifier)
{
static_assert(rpp::constraint::observable<std::invoke_result_t<TNotifier, std::exception_ptr>>, "Notifier is not invocable with std::exception_ptr returning new observable");
return details::retry_when_t<std::decay_t<TNotifier>>{std::forward<TNotifier>(notifier)};
}
} // namespace rpp::operators
10 changes: 5 additions & 5 deletions src/rpp/rpp/operators/scan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace rpp::operators
* - No any heap allocations at all
* - Keep actual seed/cache inside observable and updating it every emission
*
* @param initial_value initial value for seed which would be sent during subscription and applied for first value from observable. Then it will be replaced with result and etc.
* @param seed initial value for seed which would be sent during subscription and applied for first value from observable. Then it will be replaced with result and etc.
* @param accumulator function which accepts seed value and new value from observable and return new value of seed. Can accept seed by move-reference.
*
* @warning #include <rpp/operators/scan.hpp>
Expand All @@ -150,11 +150,11 @@ namespace rpp::operators
* @ingroup transforming_operators
* @see https://reactivex.io/documentation/operators/scan.html
*/
template<typename InitialValue, typename Fn>
requires (!utils::is_not_template_callable<Fn> || std::same_as<std::decay_t<InitialValue>, std::invoke_result_t<Fn, std::decay_t<InitialValue> &&, rpp::utils::convertible_to_any>>)
auto scan(InitialValue&& initial_value, Fn&& accumulator)
template<typename Seed, typename Fn>
auto scan(Seed&& seed, Fn&& accumulator)
{
return details::scan_t<std::decay_t<InitialValue>, std::decay_t<Fn>>{std::forward<InitialValue>(initial_value), std::forward<Fn>(accumulator)};
static_assert(constraint::template_callable_or_invocable_ret<std::decay_t<Seed>, std::invoke_result_t<Fn, std::decay_t<Seed>&&, rpp::utils::convertible_to_any>>, "Accumulator is not invocable with Seed and T returning seed");
return details::scan_t<std::decay_t<Seed>, std::decay_t<Fn>>{std::forward<Seed>(seed), std::forward<Fn>(accumulator)};
}

/**
Expand Down
Loading