December 2018
Intermediate to advanced
702 pages
20h 9m
English
A variadic template is when there is a variable number of template parameters. The syntax is similar to variable arguments to a function; you use ellipses, but you use them on the left of the argument in the parameter list, which declares it a parameter pack:
template<typename T, typename... Arguments> void func(T t, Arguments... args);
The Arguments template parameter is zero or more types, which are the types of the corresponding number of arguments, args, of the function. In this example, the function has at least one parameter, of type T, but you can have any number of fixed parameters, including none at all.
Within the function, you need to unpack the parameter pack to get access to the parameters passed by the caller. ...
Read now
Unlock full access