diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-27 01:02:23 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-27 01:02:23 +0000 |
commit | d122a22ef123e8d0e5ca05ff760645da71b248b0 (patch) | |
tree | 086f69f8370f86239963ce9f4d84aac61c09f33c /lib | |
parent | Fix lookup idx for otherObjects suitable for T (diff) | |
download | ilt-d122a22ef123e8d0e5ca05ff760645da71b248b0.tar.bz2 ilt-d122a22ef123e8d0e5ca05ff760645da71b248b0.tar.xz ilt-d122a22ef123e8d0e5ca05ff760645da71b248b0.zip |
applyToOthersType allows passing any params in, not just a T
Diffstat (limited to 'lib')
-rw-r--r-- | lib/collection.h | 11 |
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)...); } }(), ...); |