The variadic template feature of C++ was designed by Douglas Gregor and Jaakko Järvi [1][2] and was later standardized in C++11.
C++11 allows template definitions to take an arbitrary number of arguments of any type.
Therefore, the typical mechanism for defining something like a C++11 variadic printf replacement would be as follows: This is a recursive template.
An initializer list requires a non-void return type, but the comma operator can be used to yield 1 for each expansion element.
When combined with universal references (see above), this allows for perfect forwarding: This unpacks the argument list into the constructor of TypeToConstruct.
The std::forward
Operations are interpreted at compile time, which means operands can't be runtime value (such as function parameters).
Outputs: Variadic templates are often used to create a sequence of aliases, named AliasSeq.
The definition of an AliasSeq is actually very straightforward: This structure allows one to manipulate a list of variadic arguments that will auto-expand.
This allows any operation you would expect: For articles on variadic constructs other than templates