diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index 1e953f29b6c..8bb2c7c3f01 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -58,18 +58,17 @@ namespace QtPrivate { struct FunctorCallBase { template - static void call_internal(void **args, Lambda &&fn) noexcept(noexcept(fn())) + static void call_internal([[maybe_unused]] void **args, Lambda &&fn) + noexcept(std::is_nothrow_invocable_v) { - using SlotRet = decltype(fn()); - if constexpr (std::is_void_v || std::is_void_v) { - Q_UNUSED(args); + if constexpr (std::is_void_v || std::is_void_v>) { + std::forward(fn)(); } else { - if (args[0]) { - *reinterpret_cast(args[0]) = fn(); - return; - } + if (args[0]) + *reinterpret_cast(args[0]) = std::forward(fn)(); + else + [[maybe_unused]] auto r = std::forward(fn)(); } - fn(); } };