C++ Logo


Advanced search

Re: [std-proposals] explicit this

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Mon, 3 Apr 2023 23:17:20 +0300
On Mon, 3 Apr 2023 at 23:09, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> On Mon, Apr 3, 2023 at 1:05 PM Andrew Tomazos via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > While, granted, conventionally you could always call it `self`, it's still not as good as using the long-standing and familiar syntax of `this->`.
> I realise that 'this' is a keyword, but nonetheless it would be nice
> if they allowed the following:
> void SomeClass::SomeMemberFunc(this SomeClass &self)
> {
> SomeClass *const this = &self;
> }
> Am I too late to ask for this to be added to the 'explicit this' proposal?

Yes, you are. A lambda may have an implicit 'this' if it captured one,
so mixing up that and the explicit
this parameter was considered a bad idea, because a lambda can in fact
have both. For consistency,
non-lambda functions don't mix them up either.

Received on 2023-04-03 20:17:32