From 5eb5174472cf345eb978c917626cb263ee35286c Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 27 Apr 2021 23:12:59 +0300 Subject: [PATCH] Make future::get return the object by value --- libs/async/include/psemek/async/future.hpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/libs/async/include/psemek/async/future.hpp b/libs/async/include/psemek/async/future.hpp index dd545f0d..d80e992f 100644 --- a/libs/async/include/psemek/async/future.hpp +++ b/libs/async/include/psemek/async/future.hpp @@ -14,17 +14,6 @@ namespace psemek::async namespace detail { - template - struct get_return_type - { - using type = T &; - }; - - template <> - struct get_return_type - { - using type = void; - }; template struct task_value_container @@ -41,7 +30,7 @@ namespace psemek::async template struct then_function { - using type = util::function; + using type = util::function; }; template <> @@ -142,7 +131,7 @@ namespace psemek::async return has_value_unsafe(); } - detail::get_return_type::type get() + T get() { if (!state_) throw empty_future_error{}; @@ -154,7 +143,7 @@ namespace psemek::async if constexpr (std::is_same_v) return; else - return *(state_->value); + return std::move(*(state_->value)); } else std::rethrow_exception(state_->exception);