I have a variadic function like this:
template <class... PickComponents, size_t... PickComponentIndices>
void iterateEntitiesInternal(
const std::function<void(Entity, const PickComponents &...)> &iterFn,
std::index_sequence<PickComponentIndices...> sequence
);
template <class... PickComponents>
void iterateEntities(const std::function<void(Entity, const PickComponents &...)> &iterFn) {
iterateEntitiesInternal(iterFn, std::index_sequence_for<PickComponents...>{});
}
I want to be able to call the function like this:
iterateEntities<A, B, C>([](Entity entity, const auto &c1, const auto &c2, const auto &c3) {
// ...
});
Is there a way I can make this work? I tried creating a template structure like:
template <typename T> struct IterFnType { typedef T type; };
and using it like this:
template <class... PickComponents>
void iterateEntities(const typename IterFnType<std::function<void(Entity, const PickComponents &...)>>::type &iterFn);
But it gives me a compiler error in GCC:
error: ‘typename liquid::EntityStorageSparseSet::IterFnType’ names ‘template<class ... ComponentTypes> template struct liquid::EntityStorageSparseSet::IterFnType’, which is not a type
What is the correct way of passing lambdas to variadic functions?