From 0cee264b3a901716d07fdc2cef1b8bed3718674f Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 27 Oct 2020 12:12:11 +0100 Subject: [PATCH] Don't use pointers or references to functions from std library Task-number: QTBUG-87719 Change-Id: I7331b7a0095fd41261173d309215f897542669ed Reviewed-by: Sona Kurazyan --- .../qtconcurrentstoredfunctioncall.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/concurrent/qtconcurrentstoredfunctioncall.h b/src/concurrent/qtconcurrentstoredfunctioncall.h index f52b6e2efc..98ce28f6dc 100644 --- a/src/concurrent/qtconcurrentstoredfunctioncall.h +++ b/src/concurrent/qtconcurrentstoredfunctioncall.h @@ -66,9 +66,10 @@ struct NonMemberFunctionResolver static_assert(std::is_void_v, QPromise &, std::decay_t...>>, "The function must return void type."); - static constexpr auto invokePointer() + static constexpr void invoke(std::decay_t function, QPromise &promise, + std::decay_t... args) { - return &std::invoke, QPromise &, std::decay_t...>; + std::invoke(function, promise, args...); } static Type initData(Function &&f, QPromise &promise, Args &&...args) { @@ -88,9 +89,10 @@ struct MemberFunctionResolver static_assert(std::is_void_v, std::decay_t, QPromise &, std::decay_t...>>, "The function must return void type."); - static constexpr auto invokePointer() + static constexpr void invoke(std::decay_t function, std::decay_t object, + QPromise &promise, std::decay_t... args) { - return &std::invoke, std::decay_t, QPromise &, std::decay_t...>; + std::invoke(function, object, promise, args...); } static Type initData(Function &&f, QPromise &promise, Arg &&fa, Args &&...args) { @@ -145,8 +147,10 @@ struct StoredFunctionCall : public RunFunctionTask, - std::decay_t...>; + constexpr auto invoke = [] (std::decay_t function, + std::decay_t... args) -> auto { + return std::invoke(function, args...); + }; if constexpr (std::is_void_v>) std::apply(invoke, std::move(data)); @@ -177,7 +181,7 @@ struct StoredFunctionCallWithPromise : public RunFunctionTaskBase protected: void runFunctor() override { - std::apply(Resolver::invokePointer(), std::move(data)); + std::apply(Resolver::invoke, std::move(data)); } private: