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
Improve certain definitions in [class.mem.general] #5223
Comments
ad 1) "a" is not a member of "X", so it can't be a direct member. "A direct member of a class X is a member of X that (further restriction)." Something that is not a member can't be a direct member. ad 2) Yes, we probably have quite a bit of confusion around direct member vs. member. ad 3) No, the injected-class-name is not a member; it's just a name with special semantics bound in the scope of the class. Just for the narrow purpose of access checking is it considered a public member. The injected-class-name thus is not in scope for the "shall have a name different from T" rules. |
@jensmaurer For the first issue. [class.mem.general] p1 states
The member-specification that comprises the member-declaration
It may eliminate the above confusion: what the extent For the third issue. Since we admit there is a declaration associated with the nested-class-name, as per [basic.scope.pdecl] p8. And we also admit that: The class-name is also bound in the scope of the class (template) itself;. Based on these premises, and what [basic.scope.scope] p2 states
Since we never specify the otherwise rules for the declaration of an injected-class-name, [basic.scope.scope] p2 should be default applied to that declaration. I cannot figure out any declaration that can have these functions except a member-declaration. |
First issue: I don't think your change is an improvement at all. I do agree that the topic of "members of a class" could use a larger rephrasing along the lines of "the direct members of a class are those entities introduced by declarations in the member-specification whose target scope is the class; the members of a class are the direct members of a class plus all members of all direct base classes". Third issue: The implicit declaration of an injected-class-name is a "declaration" per basic.pre p5.14. The declaration of the injected-class-name is not lexically part of the member-specification of a class, so it is not a member. Yet, the name is bound to the class scope and is visible to member name lookup. I think this reading has the right semantic outcome. |
For the first issue, I think your proposal wording is good and consistent with the approach of P1989(i.e., phrase the things by using the target scope).
An implicitly-declared constructor is also not a lexically part of the member-specification of a class, but it is a member. Since we admit that the injected-class-name does have a corresponding declaration, if we don't give an extra regulation, [basic.scope.scope] p2 can be applied to the declaration. Maybe, we can explicitly clarify the hazy.
According to [basic.scope.scope] p2.2 and [basic.scope.scope] p2.5, the above sentence might clarify two things:
|
NO.4
Since injected-class-name is a name, instead, and a
|
ad 4) If the class-name is a simple-template-id, we bind the template-name of the simple-template-id. |
Since [class.pre] p1 states
In [temp.expl.spec], p4 says
In [temp.spec.partial], p7 says
Hence, only the class or primary class template whose class-name is an identifier introduces a name, and it is reasonable that such a name is also the injected-class-name, I think. |
NO.5class-name and injected-class-name are introduced by different declarations. Assume the class-specifier is a declaration C while the implicit declaration of injected-class-name is
Hence, we can get two conclusions:
Whereas, [class.pre] p2 says
This is contradictory since these two names are bound to their respective declarations, class-name ≠ injected-class-name. Based on this, we cannot say that class-name ... is known as the injected-class-name. |
NO.1
Since the class-specifier of
Nested
is within the member-specification ofX
, thus every member-specification withinNested
is also within the member-specification ofX
and also first be declared. That is not intent of the rule, any intervening class-specifier should abort the application of the definition. So, the improvement for this rule is that:NO.2
[class.mem.general] p21
Since [class.derived.general] p2 says
Obviously, the intent of the above bullets should refer to the direct member of class
T
.NO.3
Consider the third bullet in the above list
How about
injected-class-name
?[basic.scope.pdecl] p8
[class.mem.general] p1
So, the injected-class-name is a member, and the declaration associated with it has a locus, which admits it should have a declaration. Furthermore,
no member can be added elsewhere
, thus, it should act as a member declaration, as it is a member. Hence, the third bullet should exclude this special case. Moreover, an additional improvement to the third bullet is thatSince we have a clear definition regarding
denote an entity
in [basic.pre] p5The improvement will cover two cases that either the member declaration itself introduces a type or the member declaration itself introduces a
typedef-name
to denote the type instead of introducing a new type.The text was updated successfully, but these errors were encountered: