Make future::get return the object by value
This commit is contained in:
parent
497b90ee7a
commit
5eb5174472
1 changed files with 3 additions and 14 deletions
|
|
@ -14,17 +14,6 @@ namespace psemek::async
|
|||
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
struct get_return_type
|
||||
{
|
||||
using type = T &;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct get_return_type<void>
|
||||
{
|
||||
using type = void;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct task_value_container
|
||||
|
|
@ -41,7 +30,7 @@ namespace psemek::async
|
|||
template <typename T>
|
||||
struct then_function
|
||||
{
|
||||
using type = util::function<void(T &)>;
|
||||
using type = util::function<void(T)>;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
|
@ -142,7 +131,7 @@ namespace psemek::async
|
|||
return has_value_unsafe();
|
||||
}
|
||||
|
||||
detail::get_return_type<T>::type get()
|
||||
T get()
|
||||
{
|
||||
if (!state_)
|
||||
throw empty_future_error{};
|
||||
|
|
@ -154,7 +143,7 @@ namespace psemek::async
|
|||
if constexpr (std::is_same_v<T, void>)
|
||||
return;
|
||||
else
|
||||
return *(state_->value);
|
||||
return std::move(*(state_->value));
|
||||
}
|
||||
else
|
||||
std::rethrow_exception(state_->exception);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue