Open xmh0511 opened 1 year ago
See CWG2448 and CWG2689. Although the issue is a bit more complicated for class and enumeration types, because scopes and intruducing declarations are involved.
See CWG2448 and CWG2689. Although the issue is a bit more complicated for class and enumeration types, because scopes and intruducing declarations are involved.
The concise way is, we say "class type" or "enumeration type" are these types introduced by the corresponding declaration, which are cv-unqualified types. This thought conforms with name lookup rules:
Qualified name lookup in a class, namespace, or enumeration performs a search of the scope associated with it ([class.member.lookup]) except as specified below.
The "a class" is the type introduced by the class declaration, which introduces a cv-unqualified type, hence the associated scope of "a class" is the scope introduced by the class declaration.
The standard is certainly imprecise about when we mean "cv T" (i.e. possibly cv-qualified type) and when we don't. I agree that the outcome of a class definition is a cv-unqualified type, so we need to drop cv-qualifiers somewhere along the name lookup process.
Full name of submitter (unless configured in github; will be published with the issue): Jim X
[basic.type.qualifier] says:
So, when we use "class type or enumeration type", do we intend to mean all related types or just the cv-unqualified version? There are many wordings in the document use "class type or enumeration type" with different meanings.
For example [over.match.oper] p1
In this context, "class or enumeration" should mention all versions of that type.
[dcl.init.general] p16.6
In this context, "class type" only refers to the cv-unqualified version.
As mentioned in https://github.com/cplusplus/draft/issues/5351,
[basic.lookup.qual.general] p2
The type can be
cv T
where T is a class type. [basic.lookup.qual.general] p3 saysThe "a class" should refer to the cv-unqualified class type since [basic.scope.class] p1 says
A class-specifier introduces a class type, which is a cv-unqualified type.
Suggested resolution
We should uniform the meaning of the text "class type" and "enumeration type". The text is reasonable to only name the cv-unqualified version type that is introduced by the class or enumeration declaration. In everywhere, we want to mentioned all related types, we should say: (possibly cv-qualified) that type