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.arg.nontype] Clarify the grammar meaning of template non-type argument #5457

Open
xmh0511 opened this issue May 10, 2022 · 0 comments
Open

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented May 10, 2022

Except for template non-type arguments, other kinds of template arguments are less or more to be given the corresponding grammar meaning. A template type argument is type-id, as per

A template-argument for a template-parameter which is a type shall be a type-id.

A template template argument is expresses as id-expression, as per

A template-argument for a template template-parameter shall be the name of a class template or an alias template, expressed as id-expression.

We just lack to specify the grammar meaning for non-type arguments. Maybe, we should give a similar rule that:

A template-argument for a non-type template-parameter shall be a converted constant expression ([expr.const]) of the type of the template-parameter, expressed as constant-expression.

which conforms to

template-argument

  • constant-expression
  • type-id
  • id-expression

The modification can also clarify the example in [expr.const] p14 by the way.

X<std::is_constant_evaluated()> x;                      // type X<true>

The actual reason is that std::is_constant_evaluated() is evaluated in the context of constant-expression

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