cplusplus / cplusplus/draft

[basic.scope.temp] p2 Clarify the scope where D should have inhabited

Open
#5,471 0 comments 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

[basic.scope.temp] p2 says

Each template-declaration D introduces a template parameter scope that extends from the beginning of its template-parameter-list to the end of the template-declaration. Any declaration outside the template-parameter-list that would inhabit that scope instead inhabits the same scope as D.

Since we have said that the template-declaration D introduced a template scope that is extended to the end of D before we state the second sentence. According to [basic.scope.scope] p2

A declaration inhabits the immediate scope at its locus

Consider this example

template<class T>
struct X{};

The locus of the class-specifier is immediately after X, that is, the locus of the class specifier is contained by the template parameter scope. This makes what scope D inhabits ambiguous. The intent is to say that D inhabits the global scope. The improvement might be:

Each template-declaration D introduces a template parameter scope P that extends from the beginning of its template-parameter-list to the end of the template-declaration. Any declaration outside the template-parameter-list that would inhabit the scope P instead inhabits the same scope as that D would inhabit if the scope P were ignored.

Or, we can just say

Each template-declaration D introduces a template parameter scope P that extends from the beginning of its template-parameter-list to the end of the template-declaration. D inhabits the scope S after ignoring P. Any declaration outside the template-parameter-list that would inhabit the scope P instead inhabits S.

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 with [basic.scope.temp] p2 and compare its wording with [basic.scope.scope] p2, using the template struct X{} example as the test case. Done means the rule unambiguously places D and declarations outside the template-parameter-list in the intended scope, without changing the stated template parameter scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.