From 75031d7371e049c625a442504d8f7711221de3c7 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Sun, 27 Aug 2023 17:20:40 +0300 Subject: [PATCH] Minor defer fix (#414) --- src/rpp/rpp/sources/defer.hpp | 14 ++++++++++---- src/rpp/rpp/utils/function_traits.hpp | 4 ---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/rpp/rpp/sources/defer.hpp b/src/rpp/rpp/sources/defer.hpp index 6681e2d76..3ee6a51d3 100644 --- a/src/rpp/rpp/sources/defer.hpp +++ b/src/rpp/rpp/sources/defer.hpp @@ -9,6 +9,7 @@ #pragma once +#include #include #include @@ -19,8 +20,13 @@ struct defer_strategy { using ValueType = rpp::utils::extract_observable_type_t>; - Factory observable_factory; - void subscribe(auto&& obs) const { observable_factory().subscribe(std::forward(obs)); } + RPP_NO_UNIQUE_ADDRESS Factory observable_factory; + + template TObs> + void subscribe(TObs&& obs) const + { + observable_factory().subscribe(std::forward(obs)); + } }; } @@ -36,7 +42,7 @@ namespace rpp::source /** * @brief Creates rpp::observable that calls the specified observable factory to create an observable for each new observer that subscribes. * - * @tparam Factory the type of the observable factory + * @param observable_factory is function to create observable to subscribe on. * * @par Example: * @snippet defer.cpp defer from_iterable @@ -45,7 +51,7 @@ namespace rpp::source * @see https://reactivex.io/documentation/operators/defer.html */ template - requires(rpp::utils::is_no_argument_function && rpp::constraint::observable>) + requires rpp::constraint::observable> auto defer(Factory&& observable_factory) { return defer_observable>, Factory>{std::forward(observable_factory)}; diff --git a/src/rpp/rpp/utils/function_traits.hpp b/src/rpp/rpp/utils/function_traits.hpp index 5d82e372e..53016303d 100644 --- a/src/rpp/rpp/utils/function_traits.hpp +++ b/src/rpp/rpp/utils/function_traits.hpp @@ -10,7 +10,6 @@ #pragma once -#include #include #include @@ -34,9 +33,6 @@ struct is_not_template_callable_t : std::true_type{}; template concept is_not_template_callable = is_not_template_callable_t::value; -template -concept is_no_argument_function = std::invocable; - // Lambda template struct function_traits : function_traits {};