liveBook · Manning

Variadic template

A variadic template is a C++ template that uses a parameter pack to accept a variable number of template arguments.

How 2 Manning books explain it

Learn C++ by Example

A variadic template is a template containing at least one parameter pack and therefore capable of accepting a variable number of template arguments.

How it is used
Deploys variable-arity functions, frequency counting, and grouped lambda visitors for variants.
How deep it goes
Explains declarations, expansions, folds, constraints, and selected overload behavior, but defers broader template internals.
Examples
Uses summation, frequency maps for slot-machine reels, and an Overload visitor combining lambdas.
What you can do after
Build variable-arity functions, expand packs into expressions or lists, and compose callable visitors for variants.

Read how Learn C++ by Example explains variadic template →

100 C++ Mistakes and How to Avoid Them

A variadic template is a C++ template that accepts a variable number of template arguments or function arguments.

How it is used
Handles variable numbers of template or function arguments for more generic and reusable code.
How deep it goes
Explains base and recursive cases, compiler expansion, and a C++17 fold-expression alternative.
Examples
Contrasts summing values from a vector with direct calls accepting two, three, or four arguments.
What you can do after
Build variable-length sum functions using a base case, recursive parameter pack, or C++17 fold expression.

Read how 100 C++ Mistakes and How to Avoid Them explains variadic template →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.