What kind of type-specifier within decl-specifier-seq grammar tree can denote the type-specifier when it's a template parameter pack

Viewed 101
template<typename...T>
void func(T...){
}

Consider the above code , it's a case what the standard mentioned:

There is a syntactic ambiguity when an ellipsis occurs at the end of a parameter-declaration-clause without a preceding comma. In this case, the ellipsis is parsed as part of the abstract-declarator if the type of the parameter either names a template parameter pack that has not been expanded or contains auto; otherwise, it is parsed as part of the parameter-declaration-clause.

So, the parameter-declaration is the form of the following:
dcl.fct#3

parameter-declaration:

attribute-specifier-seq(opt) decl-specifier-seq abstract-declarator(opt)

Thereof, the abstract-declarator denotes ..., However, I couldn't find a type-specifer within decl-specifier-seq's grammar tree can denote T.

dcl.spec#1

decl-specifier:

decl-specifier-seq:

  • decl-specifier attribute-specifier-seq (opt)
  • decl-specifier decl-specifier-seq

Because T here is an unexpanded template parameter type. So T is not typedef-name, because of this:
temp.param#3

A type-parameter whose identifier does not follow an ellipsis defines its identifier to be a typedef-name (if declared without template) or template-name (if declared with template) in the scope of the template declaration. [ Note: A template argument may be a class template or alias template.

So, I wonder what something within the decl-specifier-seq grammar tree can denote the template parameter pack T which has not been expanded? As far as now, I have not found a type-specifier associated with T. If I miss anything, Please correct me.

UPDATE

For this question, I'm digging in the further into temp.variadic#5 section, and I found something that says:

For the purpose of determining whether a parameter pack satisfies a rule regarding entities other than parameter packs, the parameter pack is considered to be the entity that would result from an instantiation of the pattern in which it appears.

My reading about this sentence is, the parameter pack is required to satisfy the rule about a parameter-declaration, hence when invoke the function like func(0,0.1), the instantiation of the pattern of the pack expansion are int,double, respectively, due to:

temp.variadic#4

A pack expansion consists of a pattern and an ellipsis, the instantiation of which produces zero or more instantiations of the pattern in a list (described below)

  • In a function parameter pack ([dcl.fct]); the pattern is the parameter-declaration without the ellipsis.

So, the results from these instantiations are used to be the type-specifier. It means int,double will be the type-specifier for these parameter-declarations of this case func(0,0.1), However it's my reading, I'm not sure it is a relevant rule for this questions.

And it will result in another question, for template<typename...T> void func(T...);, the parameter pack is not a function parameter pack, due to this rule:

A declarator-id or abstract-declarator containing an ellipsis shall only be used in a parameter-declaration. Such a parameter-declaration is a parameter pack. When it is part of a parameter-declaration-clause, the parameter pack is a function parameter pack. [ Note: Otherwise, the parameter-declaration is part of a template-parameter-list and the parameter pack is a template parameter pack; see [temp.param].  — end note ]

In my question, the parameter pack is parsed as a part of the abstract-declarator, not the part of a parameter-declaration-clause because the first quote said that. hence, the parameter pack is not considered to be a function parameter pack at all? Now, I think this question has became more complex. I'm looking forward to an answers for this question.

0 Answers
Related