Skip to content

Commit

Permalink
Add a std::tuple constructor in unwrapping to release earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
aurianer committed Jul 31, 2023
1 parent e6ad81f commit d44a043
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion include/dlaf/common/unwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/// @file

#include <functional>
#include <type_traits>

#include <pika/async_rw_mutex.hpp>
#include <pika/execution.hpp>
Expand Down Expand Up @@ -58,7 +59,18 @@ struct Unwrapping {
template <typename... Ts>
auto operator()(Ts&&... ts)
-> decltype(std::move(f)(Unwrapper<std::decay_t<Ts>>::unwrap(std::forward<Ts>(ts))...)) {
return std::move(f)(Unwrapper<std::decay_t<Ts>>::unwrap(std::forward<Ts>(ts))...);
using result_type = decltype(std::move(f)(Unwrapper<std::decay_t<Ts>>::unwrap(std::forward<Ts>(ts))...));
if constexpr(std::is_void_v<result_type>)
{
std::move(f)(Unwrapper<std::decay_t<Ts>>::unwrap(std::forward<Ts>(ts))...);
std::tuple<Ts...>(std::forward<Ts>(ts)...);
}
else
{
auto r = std::move(f)(Unwrapper<std::decay_t<Ts>>::unwrap(std::forward<Ts>(ts))...);
std::tuple<Ts...>(std::forward<Ts>(ts)...);
return r;
}
}
};

Expand Down

0 comments on commit d44a043

Please sign in to comment.