Solutions: Get rid of [=] lambda captures

Change-Id: I806353e2e0f0163a03ff17edf8c25fdf6c1f8c65
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2023-12-07 16:26:25 +01:00
parent 723ba0fc48
commit 6f155f44f9

View File

@@ -271,7 +271,7 @@ private:
static_assert(isS || isV, static_assert(isS || isV,
"Group setup handler needs to take no arguments and has to return void or SetupResult. " "Group setup handler needs to take no arguments and has to return void or SetupResult. "
"The passed handler doesn't fulfill these requirements."); "The passed handler doesn't fulfill these requirements.");
return [=] { return [handler] {
if constexpr (isS) if constexpr (isS)
return std::invoke(handler); return std::invoke(handler);
std::invoke(handler); std::invoke(handler);
@@ -289,7 +289,7 @@ private:
static_assert(isDW || isD || isVW || isV, static_assert(isDW || isD || isVW || isV,
"Group done handler needs to take (DoneWith) or (void) as an argument and has to " "Group done handler needs to take (DoneWith) or (void) as an argument and has to "
"return void or DoneResult. The passed handler doesn't fulfill these requirements."); "return void or DoneResult. The passed handler doesn't fulfill these requirements.");
return [=](DoneWith result) { return [handler](DoneWith result) {
if constexpr (isDW) if constexpr (isDW)
return std::invoke(handler, result); return std::invoke(handler, result);
if constexpr (isD) if constexpr (isD)
@@ -347,7 +347,7 @@ private:
static_assert(isB || isV, static_assert(isB || isV,
"Sync handler needs to take no arguments and has to return void or DoneResult. " "Sync handler needs to take no arguments and has to return void or DoneResult. "
"The passed handler doesn't fulfill these requirements."); "The passed handler doesn't fulfill these requirements.");
return [=] { return [handler] {
if constexpr (isB) { if constexpr (isB) {
return std::invoke(handler) == DoneResult::Success ? SetupResult::StopWithSuccess return std::invoke(handler) == DoneResult::Success ? SetupResult::StopWithSuccess
: SetupResult::StopWithError; : SetupResult::StopWithError;
@@ -410,7 +410,7 @@ private:
static_assert(isS || isV, static_assert(isS || isV,
"Task setup handler needs to take (Task &) as an argument and has to return void or " "Task setup handler needs to take (Task &) as an argument and has to return void or "
"SetupResult. The passed handler doesn't fulfill these requirements."); "SetupResult. The passed handler doesn't fulfill these requirements.");
return [=](TaskInterface &taskInterface) { return [handler](TaskInterface &taskInterface) {
Adapter &adapter = static_cast<Adapter &>(taskInterface); Adapter &adapter = static_cast<Adapter &>(taskInterface);
if constexpr (isS) if constexpr (isS)
return std::invoke(handler, *adapter.task()); return std::invoke(handler, *adapter.task());
@@ -436,7 +436,7 @@ private:
"Task done handler needs to take (const Task &, DoneWith), (const Task &), " "Task done handler needs to take (const Task &, DoneWith), (const Task &), "
"(DoneWith) or (void) as arguments and has to return void or DoneResult. " "(DoneWith) or (void) as arguments and has to return void or DoneResult. "
"The passed handler doesn't fulfill these requirements."); "The passed handler doesn't fulfill these requirements.");
return [=](const TaskInterface &taskInterface, DoneWith result) { return [handler](const TaskInterface &taskInterface, DoneWith result) {
const Adapter &adapter = static_cast<const Adapter &>(taskInterface); const Adapter &adapter = static_cast<const Adapter &>(taskInterface);
if constexpr (isDTW) if constexpr (isDTW)
return std::invoke(handler, *adapter.task(), result); return std::invoke(handler, *adapter.task(), result);
@@ -516,7 +516,7 @@ private:
StorageBase::StorageHandler doneHandler); StorageBase::StorageHandler doneHandler);
template <typename StorageStruct, typename Handler> template <typename StorageStruct, typename Handler>
StorageBase::StorageHandler wrapHandler(Handler &&handler) { StorageBase::StorageHandler wrapHandler(Handler &&handler) {
return [=](void *voidStruct) { return [handler](void *voidStruct) {
auto *storageStruct = static_cast<StorageStruct *>(voidStruct); auto *storageStruct = static_cast<StorageStruct *>(voidStruct);
std::invoke(handler, *storageStruct); std::invoke(handler, *storageStruct);
}; };