cplusplus / cplusplus/draft

[temp.arg.nontype] Clarify the grammar meaning of template non-type argument

Open
#5,457 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the [temp.arg.nontype] wording and compare it with the grammar and discussion in [expr.const]. Clarify the grammar meaning of non-type template arguments, including whether the proposed constant-expression wording fits the existing template-argument alternatives and the is_constant_evaluated() example.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, tex
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.