Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[temp.variadic] Use consistent utterances associated with pack expansion #5317

Open
xmh0511 opened this issue Feb 24, 2022 · 0 comments
Open

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Feb 24, 2022

[temp.variadic] p5 and [temp.variadic] p8 states

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).

The instantiation of a pack expansion considers items...

Such two rules explicitly state that productions are produced from the instantiation of a pack expansion. However, in [temp.variadic] p8.2, we use a different utterance. [temp.variadic] p8.2 says:

if the pack is a function parameter pack, the element is an id-expression designating the ith function parameter that resulted from instantiation of the function parameter pack declaration;

[dcl.fct] p25 explicit defines that

When it is part of a parameter-declaration-clause, the parameter-declaration declares a function parameter pack ([temp.variadic]).

A function parameter pack is a pack expansion ([temp.variadic]).

From the above, we can get the following conclusion that

  • the particular parameter-declaration declares a function parameter pack
  • a function parameter pack is a pack expansion

Hence, we shouldn't say the instantiation of the function parameter pack declaration(i.e., the parameter-declaration is not a pack expansion). We should consistently say

if the pack is a function parameter pack, the element is an id-expression designating the ith function parameter that resulted from instantiation of the function parameter pack declaration;

#5165 has a similar issue.


[temp.variadic] p5.1

Pack expansions can occur in the following contexts:

This bullet is a bit different from other bullets after it. The other context all refers to the grammar component that contains the ellipsis. In the initial of p5, we have emphasized that a pack expansion consists of a pattern and an ellipsis. That is, the grammar component that contains the ellipsis conforms to the definition of a pack expansion. Not only from this point but also from [temp.param] p17, they all expose that the definition in [dcl.fct] p25 is contradictory.

From [temp.param] p17

If a template-parameter is a type-parameter with an ellipsis prior to its optional identifier or is a parameter-declaration that declares a pack ([dcl.fct]), then the template-parameter is a template parameter pack.

we can get a conclusion that

  • if a template-parameter that is a parameter-declaration that declares a pack, then the template-parameter is a template parameter pack,
  • since template-parameter is the parameter-declaration, the parameter-declaration is a template parameter pack.

Conversely, [dcl.fct] p25 says

Otherwise, the parameter-declaration is part of a template-parameter-list and declares a template parameter pack; see [temp.param].

This rule uses "declares" not "is". we may read the contradiction from such two formal rules. Moreover, [temp.variadic] p5.1 is uncoordinated. I think we may change [dcl.fct] p25

A declarator-id or abstract-declarator containing an ellipsis shall only be used in a parameter-declaration. When it is part of a parameter-declaration-clause, the parameter-declaration declares a function parameter pack ([temp.variadic]). Otherwise, the parameter-declaration is part of a template-parameter-list and declares a template parameter pack; see [temp.param]. Such parameter-declaration is a pack expansion ([temp.variadic]).

change [temp.param] p17 to

If a template-parameter is a type-parameter with an ellipsis prior to its optional identifier or is a parameter-declaration that declares a pack ([dcl.fct]), then the template-parameter is declares a template parameter pack. A parameter-declaration declaring a template parameter pack whose type contains one or more unexpanded packs is a pack expansion. Similarly, a type-parameter, with a template-parameter-list containing one or more unexpanded packs, that declares a template parameter pack is a pack expansion. A type-parameter with a type-constraint that contains an unexpanded parameter pack is a pack expansion. A template-parameter that is a pack expansion shall not expand a template parameter pack declared in the same template-parameter-list.

change [temp.variadic] p5.1 and p5.3 to

Pack expansions can occur in the following contexts:

  • In a parameter-declaration that declares a function parameter pack; the pattern is the parameter-declaration without the ellipsis.
  • [...]
  • In a template-parameter that is a pack expansion ([temp.param]):
  • if the template-parameter is a parameter-declaration; the pattern is the parameter-declaration without the ellipsis;
  • if the template-parameter is a type-parameter; the pattern is the corresponding type-parameter without the ellipsis.
@xmh0511 xmh0511 changed the title Use consistent utterances regarding the instantiation of a pack expansion. Use inconsistent utterances regarding the instantiation of a pack expansion Feb 24, 2022
@xmh0511 xmh0511 changed the title Use inconsistent utterances regarding the instantiation of a pack expansion [temp.variadic] Use consistent utterances associated with pack expansion Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant