- Examples
In this lesson, we will look at some examples of variadic templates.
We'll cover the following...
We'll cover the following...
Example 1 #
Explanation #
-
In the above example, we used a
printSizefunction, which prints the number of elements (of any type) passed as arguments. It detects the number of elements on compile-time using thesizeofoperator. In the case of an empty argument list, the function returns 0. -
There is a
structdefined asMult, which takes arguments of integer type and return their product. If no argument is passed, it returns 1, which is the neutral element for multiplication. -
The result is stored in the
value, in ...