C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Contradiction about this parameter in the C++ standard

From: Jens Maurer <Jens.Maurer_at_[hidden]>
Date: Tue, 19 Apr 2022 13:16:19 +0200
On 19/04/2022 11.57, Edward Catmur via Std-Proposals wrote:
> On Tue, 19 Apr 2022 at 09:46, <language.lawyer_at_[hidden] <mailto:language.lawyer_at_[hidden]>> wrote:
>
> On 19/04/2022 11:24, Edward Catmur wrote:

> > Yes, I think that's where the connection is made. So that's possibly a
> > derived class object, and it's worth explaining where the this pointer with
> > type pointer to base gets its value from.
>
> IDK, why/when having «the object for which function is invoked» meaning «the result of the object expression» and overloading the definition of `this` with «or to its base class subobject» is useful?
>
>
> What else could "the object for which function the is invoked" mean other than "the result of the object expression"?

Consider this example:

  x.f();

If f is a member function of a base class, you need to convert
"x" to the base class type. In most implementations, if the base
class is not the first one in your base-specifier, this means
adjusting the address that "x" represents by the offset of the
base subobject inside the "x".

This is what the standard wants to capture, and that's why
the value of "this" is not just the value of the object
expression.

Jens

Received on 2022-04-19 11:16:23