Open zygoloid opened 3 months ago
CWG2869
I don't understand why this change is needed. The current wording says "... shall not appear within the declaration of either a static member function or an explicit object member function of the current class".
At the point where this
appears, the current class is B
, so the fact that we're inside a static member function of A
is irrelevant as it should be: A
is not the current class.
Hm. Maybe we just need clarification that the sentence is to be parsed as "shall not appear within the declaration of (either a static member function or an explicit object member function) of the current class" rather than as "shall not appear within the declaration of either (a static member function) or (an explicit object member function of the current class)"?
For example:
shall not appear within the declaration of
eithera staticmember functionoranexplicit object member function of the current class
... though it doesn't feel nice to split up the term "static member function" like that.
For what it's worth, I think the suggested change would still be an improvement, because it is correct by construction rather than by case analysis -- in particular, with the rule as written, we need to check whether (for example) we have problems with a friend declaration that redeclares a member of the current class in a nested scope. (I think that case is fine, but the point is that we need to be careful about such things, including when adding other features to the language in the future.)
Reference (section label): [expr.prim.this]
Issue description: [expr.prim.this]/3 says, in part:
... which disallows:
... because
this
ing()
appears within the declaration ofA::f
, which is a static member function.Suggested resolution:
Change in [expr.prim.this]/3:
(See also editorial issue https://github.com/cplusplus/draft/issues/6855.)