Skip to content

Commit

Permalink
Make future_then_result instantiation lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
aurianer committed Mar 17, 2020
1 parent ab245a4 commit 0aefb09
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions hpx/lcos/future.hpp
Expand Up @@ -950,7 +950,10 @@ namespace hpx { namespace lcos
using base_type::has_exception;

template <typename F>
typename hpx::traits::future_then_result<future, F>::type
typename util::lazy_enable_if<
hpx::traits::is_invocable<F, future&&>::value,
hpx::traits::future_then_result<future, F>
>::type
then(F && f, error_code& ec = throws)
{
invalidate on_exit(*this);
Expand All @@ -959,7 +962,12 @@ namespace hpx { namespace lcos
}

template <typename T0, typename F>
decltype(auto) then(T0 && t0, F && f, error_code& ec = throws)
typename util::lazy_enable_if<
!hpx::traits::is_invocable<T0, future&&>::value &&
hpx::traits::is_invocable<F, future&&>::value,
hpx::traits::future_then_result<future, F>
>::type
then(T0 && t0, F && f, error_code& ec = throws)
{
invalidate on_exit(*this);
return base_type::then(std::move(*this),
Expand Down Expand Up @@ -1242,15 +1250,22 @@ namespace hpx { namespace lcos
using base_type::has_exception;

template <typename F>
typename hpx::traits::future_then_result<shared_future, F>::type
typename util::lazy_enable_if<
hpx::traits::is_invocable<F, shared_future&&>::value,
hpx::traits::future_then_result<shared_future, F>
>::type
then(F && f, error_code& ec = throws) const
{
return base_type::then(shared_future(*this),
std::forward<F>(f), ec);
}

template <typename T0, typename F>
decltype(auto) then(T0 && t0, F && f, error_code& ec = throws) const
typename util::lazy_enable_if<
!hpx::traits::is_invocable<T0, shared_future&&>::value,
hpx::traits::future_then_result<shared_future, F>
>::type
then(T0 && t0, F && f, error_code& ec = throws) const
{
return base_type::then(shared_future(*this),
std::forward<T0>(t0), std::forward<F>(f), ec);
Expand Down

0 comments on commit 0aefb09

Please sign in to comment.