What are the names of the new syntax objects added for variable templates?

C ++ 11 introduced variable templates

template <typename... Args> void foo(Args... params) { cout << sizeof...(Args) << endl; } 

What are the names of Args and params ? I know that one of them (at least?) Is called a variation package of templates, but what is it? What is called another?

+6
source share
1 answer

Partially citing FDIS, ยง14.5.3:

1 Template parameter package is a template parameter that takes zero or more template arguments.

2 Function parameter package is a function parameter that takes zero or more function arguments.

3 The package of parameters is either a package of template parameters or a package of function parameters.

4 A package extension consists of a template and an ellipsis, which creates zero or more template instances in the list.

So in your example

  • typename... Args is a template parameter package (and therefore also a parameter package)
  • Args... params - a package of function parameters (and, therefore, also a package of parameters)
  • sizeof...(Args) is a package extension in which Args is a template (identifier in this context).
+12
source

Source: https://habr.com/ru/post/900558/


All Articles