The keyword this names a pointer to the object for which an implicit object member
function ([class.mfct.non.static]) is invoked or a non-static data member's
initializer ([class.mem]) is evaluated.
If the expression this
appears within the predicate of a contract assertion ([basic.contract.general])
(including as the result of an implicit transformation ([expr.prim.id.general])
and including in the bodies of nested lambda-expressions)
and the current class
encloses the contract assertion,
const is combined with the cv-qualifier-seq
used to generate the resulting type (see below).
It shall not appear within
the declaration of
a static or 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).
Otherwise, if a member-declarator declares a non-static data
member ([class.mem]) of a class X, the expression this is
a prvalue of type “pointer to X”
wherever X is the current class
within the
optional default member initializer ([class.mem]).
The expression this shall not appear in any other context.
[Example 2: class Outer {int a[sizeof(*this)]; // error: not inside a member functionunsignedint sz =sizeof(*this); // OK, in default member initializervoid f(){int b[sizeof(*this)]; // OKstruct Inner {int c[sizeof(*this)]; // error: not inside a member function of Inner};
}};
— end example]