...

/

Understanding Parameter Packs Expansion

Understanding Parameter Packs Expansion

Expand your knowledge of parameter packs by exploring their various ways of expansion.

We'll cover the following...

Parameter packs can appear in a multitude of contexts. The form of their expansion may depend on this context. These possible contexts are listed ahead along with examples.

Lists

  • Template parameter list: The template parameter list is used when we specify parameters for a template:

Press + to interact
template <typename... T>
struct outer
{
template <T... args>
struct inner {};
};
outer<int, double, char[5]> a;
  • Template argument list: The template argument list is used when we specify arguments for a template:

Press + to interact
template <typename... T>
struct tag {};
template <typename T, typename U, typename ... Args>
void tagger()
{
tag<T, U, Args...> t1;
tag<T, Args..., U> t2;
tag<Args..., T, U> t3;
tag<U, T, Args...> t4;
}
  • Function parameter list: The function parameter ...