summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-03-27 01:02:23 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2025-03-27 01:02:23 +0000
commitd122a22ef123e8d0e5ca05ff760645da71b248b0 (patch)
tree086f69f8370f86239963ce9f4d84aac61c09f33c
parentFix lookup idx for otherObjects suitable for T (diff)
downloadilt-d122a22ef123e8d0e5ca05ff760645da71b248b0.tar.bz2
ilt-d122a22ef123e8d0e5ca05ff760645da71b248b0.tar.xz
ilt-d122a22ef123e8d0e5ca05ff760645da71b248b0.zip
applyToOthersType allows passing any params in, not just a T
-rw-r--r--lib/collection.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/collection.h b/lib/collection.h
index b7d7d81..853b982 100644
--- a/lib/collection.h
+++ b/lib/collection.h
@@ -195,10 +195,10 @@ protected:
obj);
}
- template<typename T>
+ template<typename T, typename... Params>
requires(sizeof...(Others) == 0)
void
- applyToOthersType(const auto &, T *)
+ applyToOthersType(const auto &, Params...)
{
}
@@ -208,15 +208,16 @@ protected:
{
}
- template<typename T>
+ template<typename T, typename... Params>
requires(sizeof...(Others) > 0)
void
- applyToOthersType(const auto & func, T * obj)
+ applyToOthersType(const auto & func, Params &&... params)
{
(
[&]() {
if constexpr (std::is_convertible_v<T *, Others *>) {
- std::invoke(func, std::get<OtherObjects<Others>>(otherObjects), obj);
+ std::invoke(
+ func, std::get<OtherObjects<Others>>(otherObjects), std::forward<Params>(params)...);
}
}(),
...);