on-internet
← Community

Expand a tuple to explicitly instantiate multiple function templates

Stack Overflow ·

In C++, I want to instantiate a given template for N types with a type list template<class... Ts> struct typelist{}; using types = typelist<int,long,std::string>; template<class T> void f(){} // how to variadically expand this for those 3 types? template void f<types>()...; // I want it to be equal to template void f<int>(); template void f<long>(); template void f<std::string>(); For classes, I found an answer already but it doesn't seem clear to me how to do it for free functions. Please do not mention using a preprocessor solution as the tuple will be generated using metaprogramming and wou

Comments

Sign in or sign up to comment and upvote.

No comments yet.