diff --git a/src/vt/runnable/make_runnable.h b/src/vt/runnable/make_runnable.h index 6f12f9bdf3..438a0db655 100644 --- a/src/vt/runnable/make_runnable.h +++ b/src/vt/runnable/make_runnable.h @@ -276,18 +276,10 @@ struct RunnableMaker { template auto runLambda(Callable&& c, Args&&... args) { setup(); - if constexpr(std::is_void_v>) { - std::invoke(std::forward(c), std::forward(args)...); - delete impl_; - impl_ = nullptr; - is_done_ = true; - } else { - decltype(auto) r{impl_->runLambda(std::forward(c), std::forward(args)...)}; - delete impl_; - impl_ = nullptr; - is_done_ = true; - return r; - } + auto local_impl = std::unique_ptr(impl_); + impl_ = nullptr; + is_done_ = true; + return local_impl->runLambda(std::forward(c), std::forward(args)...); } /**