Search code examples
c++templatesc++17variadic-templatestemplate-meta-programming

What does it mean that function parameter packs are always pack expansions, so their declared types must include at least one parameter pack?


In this snippet

template<typename... Types>
void f(Types ... args);

Types is the template parameter pack and args is a function parameter pack.

Concerning the two technical terms, C++ Templates - The Complete Guide 2nd Edition reads

Unlike template parameter packs, function parameter packs are always pack expansions, so their declared types must include at least one parameter pack.

What does that mean? What is the example of non-at least one, i.e. zero in the context of that sentence?


Solution

  • It says that a function parameter pack can only be created using another parameter pack, rather than from scratch.

    What is the example of non-at least one, i.e. zero in the context of that sentence?

    E.g. int ...params is illegal, because it doesn't contain any existing packs.