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

[class.pre] p2 what is the locus of a injected-class-name? #5220

Closed
xmh0511 opened this issue Jan 21, 2022 · 2 comments
Closed

[class.pre] p2 what is the locus of a injected-class-name? #5220

xmh0511 opened this issue Jan 21, 2022 · 2 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jan 21, 2022

[class.pre] p2 states

The class-name is also bound in the scope of the class (template) itself; this is known as the injected-class-name. For purposes of access checking, the injected-class-name is treated as if it were a public member name.

However, we never regulate a corresponding rule for how a lookup can find the injected-class-name from a point P. Since [basic.lookup.general] p3 states that

A single search in a scope S for a name N from a program point P finds all declarations that precede P to which any name that is the same as N ([basic.pre]) is bound in S.

So, what is the locus of the injected-class-name? we can determine whether the name can be found only if we know whether the declaration of that name precedes a point where we start to find the name. This point is unclear in the current draft(also, never be clear in the earlier versions). This should be clarified.

There are two ways to clarify this point.

  • For purposes of lookup and access checking, the injected-class-name is treated as if it were introduced by a public member declaration of that name whose locus is immediately after the enclosing { of the class-specifier.

However, it seems it may conflict with [class.mem.general] p21

If T is the name of a class, then each of the following shall have a name different from T:

  • [...]
  • every member of class T that is itself a type;

The second one is

  • The class-name is also bound in the scope of the class (template) itself; this is known as the injected-class-name. A search in the scope of the class(template) from any point after the enclosing { of the class-specifier can find a hypothetical declaration associated with the name. For purposes of access checking, the injected-class-name is treated as if it were a public member name.

This is a minimum modification and wouldn't impact the current wording.

@jensmaurer
Copy link
Member

[basic.scope.pdecl] p8 says

The locus of an injected-class-name declaration (11.1) is immediately following the opening brace of the class definition.

I'm not seeing any defect here.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Jan 21, 2022

Oops... This is correct.

@xmh0511 xmh0511 closed this as completed Jan 21, 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

2 participants