This is basically noise and you can ignore that warning. It comes from how Qt wraps your functor. The code around the error location looks as follows:
template <typename, typename, typename, typename> struct FunctorCall;
template <int... II, typename... SignalArgs, typename R, typename Function>
struct FunctorCall<IndexesList<II...>, List<SignalArgs...>, R, Function> {
static void call(Function &f, void **arg) {
f((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[II+1]))...), ApplyReturnValue<R>(arg[0]);
}
};
The compiler is complaining that the ApplyReturnValue<R>(arg[0])
expression won't be executed. It's a valid complaint, but that code does not have to run, so there's nothing to worry about, because in your case ApplyReturnValue<R>
is really ApplyReturnValue<void>
since the lambda has no return value, and thus the overridden operator,
does nothing:
template<typename T>
void operator,(T, const ApplyReturnValue<void> &) {}
So you can selectively disable that warning for that bit of code only, ie.:
try
{
// some code here
}
catch(std::exception& e)
{
#pragma warning(push)
#pragma warning(disable : 4702)
QTimer::singleShot(0,[e](){ throw e;});
#pragma warning(pop)
}
And also, if you know that the thread you're running on is the main thread, you could use QMetaObject::invokeMethod(qApp, [e]{ throw e; }, Qt::QueuedConnection);
instead of the zero timer, although admittedly it's more text, so I guess it's up to one's preference without a clearly better syntax.