diff options
| author | Linus Jahn <lnj@kaidan.im> | 2023-01-22 17:43:49 +0100 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2023-01-22 17:43:49 +0100 |
| commit | df37c35aa443e6ca7e3baad5f1bbeb379063df55 (patch) | |
| tree | 14a68be8e07436ebcf1dda36c0d8f67e4a872086 /src/base | |
| parent | 381f83764d84ffff73ba05e07498e0dafd8844f5 (diff) | |
| download | qxmpp-df37c35aa443e6ca7e3baad5f1bbeb379063df55.tar.gz | |
Task: Add static assert for then function
Diffstat (limited to 'src/base')
| -rw-r--r-- | src/base/QXmppTask.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/base/QXmppTask.h b/src/base/QXmppTask.h index c11557ac..141cf10e 100644 --- a/src/base/QXmppTask.h +++ b/src/base/QXmppTask.h @@ -104,10 +104,11 @@ public: #endif void then(QObject *context, Continuation continuation) { - static_assert( - std::is_void_v<T> && std::is_invocable_v<Continuation> || - !std::is_void_v<T> /* && invocable with T && causes forming ref to void error */, - "Function needs to be invocable with T && or without params for T=void."); + if constexpr (!std::is_void_v<T>) { + static_assert(std::is_invocable_v<Continuation, T &&>, "Function needs to be invocable with T &&."); + } else { + static_assert(std::is_invocable_v<Continuation>, "Function needs to be invocable without arguments."); + } using namespace QXmpp::Private; if (d.isFinished()) { |
