June 2025
Intermediate to advanced
1093 pages
33h 24m
English
You can create templates with any number of arguments for both functions and classes. These are called variadic templates. The syntax looks a bit unusual because the type list uses three dots ... (an ellipsis). They serve here as a kind of operator.
In practice, the implementation of such variadic templates is particularly interesting for those involved in creating libraries. However, if you want to create a template that can take a variable number of types, I would first recommend the sequential std::tuple data type (see Chapter 28, Section 28.1). Instead of writing a variadic template yourself, I recommend using a tuple as a parameter instead.
In this context, with ... the parameters ...
Read now
Unlock full access