TaskTree: Add static asserts to onStorage{Setup,Done} handlers

Require const reference for onStorageDone() handler.

Change-Id: Iad333c04a78962a3361635900027bd4d41abc319
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2023-08-31 19:25:59 +02:00
parent aac9990180
commit 10430d36ff
2 changed files with 15 additions and 3 deletions

View File

@@ -413,11 +413,21 @@ public:
template <typename StorageStruct, typename StorageHandler>
void onStorageSetup(const TreeStorage<StorageStruct> &storage, StorageHandler &&handler) {
constexpr bool isInvokable = std::is_invocable_v<std::decay_t<StorageHandler>,
StorageStruct &>;
static_assert(isInvokable,
"Storage setup handler needs to take (Storage &) as an argument. "
"The passed handler doesn't fulfill these requirements.");
setupStorageHandler(storage,
wrapHandler<StorageStruct>(std::forward<StorageHandler>(handler)), {});
}
template <typename StorageStruct, typename StorageHandler>
void onStorageDone(const TreeStorage<StorageStruct> &storage, StorageHandler &&handler) {
constexpr bool isInvokable = std::is_invocable_v<std::decay_t<StorageHandler>,
const StorageStruct &>;
static_assert(isInvokable,
"Storage done handler needs to take (const Storage &) as an argument. "
"The passed handler doesn't fulfill these requirements.");
setupStorageHandler(storage,
{}, wrapHandler<StorageStruct>(std::forward<StorageHandler>(handler)));
}