Description
Reference (section label): [expr.prim.this]
Issue description: [expr.prim.this]/3 says, in part:
[
this
] shall not appear within the declaration of either a static member function or an explicit object member function of the current class (although its type and value category are defined within such member functions as they are within an implicit object member function).
... which disallows:
struct A {
static void f() {
struct B {
void *g() { return this; }
};
}
};
... because this
in g()
appears within the declaration of A::f
, which is a static member function.
Suggested resolution:
Change in [expr.prim.this]/3:
If a declaration declares a member function or member function template of a class
X
, the expressionthis
is a prvalue of type “pointer to cv-qualifier-seqX
” whereverX
is the current class between the optional cv-qualifier-seq and the end of the function-definition, member-declarator, or declarator.It shall not appear withinThe declarationof eitherthat determines the type ofthis
shall declare neither a static member functionornor an explicit object member function of the current class (although its type and value category are defined within such member functions as they are within an implicit object member function).
(See also editorial issue cplusplus/draft#6855.)