I am unsure of what the proper name is, so far I comprehend the notion of using variadic template arguments (e.g., in comparison to std::initializer_list
).
So let's assume there is an arbitrary number of classes k
and an arbitrary number of parameters i
which is dependant on each class k
constructor.
I know that I may construct any class k
using a variadic template:
template <typename T, typename... Args>
void make_class(Args... args)
{
auto k = T(args...);
}
However I want to allow creation of multiple classes which are not of the same type and most likely have different Args
.
Furthermore, I want to iterate the classes k
being constructed.
Something along the lines:
template <typename T, typename... Classes, typename Args>
void make_classes(Classes... classes)
{
for (auto type : classes) {
make_class<T>(args...); //???
}
}
- Is this possible?
- If not possible, are there any potential work-arounds?
- Is there a name for such a pattern/approach? Is this a
parameter_pack
?
Apologies if this is a duplicate.