Chapter 3, Variadic Templates
Question 1
What are variadic templates and why are they useful?
Answer
Variadic templates are templates with a variable number of arguments. They allow us to write not only functions with variable number of arguments but also class templates, variable templates, and alias templates. Unlike other approaches, such as the use of the va_
macros, they are type-safe, do not require macros, and do not require us to explicitly specify the number of arguments.
Question 2
What is a parameter pack?
Answer
There are two kinds of parameter packs: template parameter packs and function parameter packs. The former are template parameters that accept zero, one, or more template arguments. The latter are function parameters that accept zero, one, or more function arguments.
Question 3
What are the contexts where parameter packs can be expanded?
Answer
Parameter packs can be expanded in a multitude of contexts, as follows: template parameter...