diff --git a/include/dlaf/common/consume_rvalues.h b/include/dlaf/common/consume_rvalues.h index 38c15b01f2..3dea417354 100644 --- a/include/dlaf/common/consume_rvalues.h +++ b/include/dlaf/common/consume_rvalues.h @@ -16,6 +16,17 @@ #include namespace dlaf::common::internal { + +template +T consume_rvalue(T&& x) { + return std::move(x); +} + +template +T& consume_rvalue(T& x) { + return x; +} + /// ConsumeRvalues is a callable object wrapper that consumes rvalues passed as arguments /// after calling the wrapped callable. template @@ -23,17 +34,8 @@ struct ConsumeRvalues { std::decay_t f; template - auto operator()(Ts&&... ts) -> decltype(std::move(f)(std::forward(ts)...)) { - using result_type = decltype(std::move(f)(std::forward(ts)...)); - if constexpr (std::is_void_v) { - std::move(f)(std::forward(ts)...); - std::tuple(std::forward(ts)...); - } - else { - auto r = std::move(f)(std::forward(ts)...); - std::tuple(std::forward(ts)...); - return r; - } + auto operator()(Ts&&... ts) -> decltype(std::move(f)(consume_rvalue(std::forward(ts))...)) { + return std::move(f)(consume_rvalue(std::forward(ts))...); } };