diff --git a/src/rpp/rpp/observables/details/disposable_strategy.hpp b/src/rpp/rpp/observables/details/disposable_strategy.hpp index 36edb2565..4dcb5167f 100644 --- a/src/rpp/rpp/observables/details/disposable_strategy.hpp +++ b/src/rpp/rpp/observables/details/disposable_strategy.hpp @@ -74,19 +74,25 @@ using atomic_bool_disposable_strategy_selector = fixed_disposable_strategy_selec namespace details { + template + concept has_expected_disposable_strategy = requires { typename T::expected_disposable_strategy; }; + template auto* deduce_disposable_strategy() { - if constexpr (requires { typename T::expected_disposable_strategy; }) + if constexpr (has_expected_disposable_strategy) return static_cast(nullptr); else return static_cast(nullptr); } + template + concept has_updated_disposable_strategy = requires { typename T::template updated_disposable_strategy; }; + template auto* deduce_updated_disposable_strategy() { - if constexpr (requires { typename T::template updated_disposable_strategy; }) + if constexpr(has_updated_disposable_strategy) return static_cast*>(nullptr); else return static_cast(nullptr); diff --git a/src/rpp/rpp/observables/observable.hpp b/src/rpp/rpp/observables/observable.hpp index 0fcf0dcc8..334a50809 100644 --- a/src/rpp/rpp/observables/observable.hpp +++ b/src/rpp/rpp/observables/observable.hpp @@ -77,7 +77,7 @@ class observable requires (!constraint::observer) void subscribe(ObserverStrategy&& observer_strategy) const { - if constexpr (details::observers::has_disposable_strategy_v) + if constexpr (details::observers::has_disposable_strategy) subscribe(rpp::observer>{std::forward(observer_strategy)}); else subscribe(rpp::observer, typename expected_disposable_strategy::disposable_strategy>>{std::forward(observer_strategy)}); diff --git a/src/rpp/rpp/observers/details/fwd.hpp b/src/rpp/rpp/observers/details/fwd.hpp index af38c150c..29930c825 100644 --- a/src/rpp/rpp/observers/details/fwd.hpp +++ b/src/rpp/rpp/observers/details/fwd.hpp @@ -63,14 +63,14 @@ namespace constraint } template -static constexpr bool has_disposable_strategy_v = requires { typename T::preferred_disposable_strategy; }; +concept has_disposable_strategy = requires { typename T::preferred_disposable_strategy; }; namespace details { template auto* deduce_disposable_strategy() { - if constexpr (has_disposable_strategy_v) + if constexpr (has_disposable_strategy) return static_cast(nullptr); else return static_cast*>(nullptr); diff --git a/src/rpp/rpp/observers/fwd.hpp b/src/rpp/rpp/observers/fwd.hpp index 9660ec7f6..a51030a1d 100644 --- a/src/rpp/rpp/observers/fwd.hpp +++ b/src/rpp/rpp/observers/fwd.hpp @@ -212,6 +212,8 @@ namespace rpp::details { struct fake_strategy { + using preferred_disposable_strategy = rpp::details::observers::none_disposable_strategy; + static void on_next(const auto&) noexcept {} static void on_error(const std::exception_ptr&) noexcept {} diff --git a/src/rpp/rpp/operators/scan.hpp b/src/rpp/rpp/operators/scan.hpp index dbfde317e..b89667bbf 100644 --- a/src/rpp/rpp/operators/scan.hpp +++ b/src/rpp/rpp/operators/scan.hpp @@ -69,6 +69,8 @@ struct scan_t : public operators::details::operator_observable_strategy struct scan_no_seed_observer_strategy { + using preferred_disposable_strategy = rpp::details::observers::none_disposable_strategy; + RPP_NO_UNIQUE_ADDRESS TObserver observer; RPP_NO_UNIQUE_ADDRESS Fn fn; mutable std::optional seed{};