StoredFunctionCall: simplify runFunctor implementation

Task-number: QTBUG-82383
Change-Id: Ib8e196106c80e8f3aba1ff7d0c8b76a547c648da
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Vitaly Fanaskov 2020-03-31 16:24:29 +02:00
parent 23be07c2d0
commit 8365322d3d

View File

@ -80,20 +80,13 @@ struct StoredFunctionCall : public RunFunctionTask<InvokeResultType<Function, Ar
void runFunctor() override
{
using Indexes =
std::make_index_sequence<
std::tuple_size<DecayedTuple<Function, Args...>>::value>;
constexpr auto invoke = &std::invoke<std::decay_t<Function>,
std::decay_t<Args>...>;
invoke(Indexes());
}
template <std::size_t... I>
void invoke(std::index_sequence<I...>)
{
if constexpr (std::is_void_v<InvokeResultType<Function, Args...>>)
std::invoke(std::get<I>(std::move(data))...);
std::apply(invoke, std::move(data));
else
this->result = std::invoke(std::get<I>(std::move(data))...);
this->result = std::apply(invoke, std::move(data));
}
DecayedTuple<Function, Args...> data;