diff --git a/stlab/concurrency/config.hpp b/stlab/concurrency/config.hpp index 80bbdf445..7049639f8 100644 --- a/stlab/concurrency/config.hpp +++ b/stlab/concurrency/config.hpp @@ -62,7 +62,7 @@ #endif #ifndef STLAB_CPP_VERSION -#define STLAB_CPP_VERSION 14 +#define STLAB_CPP_VERSION 17 #endif #ifndef STLAB_FUTURE_COROUTINES diff --git a/stlab/concurrency/future.hpp b/stlab/concurrency/future.hpp index 20660d994..3ffc215ab 100755 --- a/stlab/concurrency/future.hpp +++ b/stlab/concurrency/future.hpp @@ -1683,16 +1683,18 @@ struct value_> { template static void set(shared_base>& sb, F& f, Args&&... args) { - sb._result = f(std::forward(args)...) - .recover([_p = sb.shared_from_this()](future f) { - if (f.error()) { - _p->_error = std::move(*f.error()); - value_::proceed(*_p); - throw future_error(future_error_codes::reduction_failed); - } - return; - }) - .then([_p = sb.shared_from_this()]() { proceed(*_p); }); + sb._result = f(std::forward(args)...); + sb._reduction_helper.value = + (*sb._result) + .recover([_p = sb.shared_from_this()](future f) { + if (f.error()) { + _p->_error = std::move(*f.error()); + value_::proceed(*_p); + throw future_error(future_error_codes::reduction_failed); + } + return; + }) + .then([_p = sb.shared_from_this()]() { proceed(*_p); }); } }; @@ -1810,13 +1812,13 @@ auto shared_base>::reduce(future>&& r) -> fut template auto shared_base>::reduce(future>&& r) -> future { - return std::move(r).then([](auto&&){}); + return std::move(r).then([](auto){}); } template template auto shared_base>::reduce(future>&& r) -> future { - return std::move(r).then([](auto&& f) { return *std::forward>(f).get_try(); }); + return std::move(r).then([](auto&& f) { return *std::move(f).get_try(); }); } /**************************************************************************************************/