C++ Logo

std-proposals

Advanced search

Re: Make 'this' a reference

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Thu, 5 Mar 2020 11:22:10 +0200
On Thu, 5 Mar 2020 at 10:59, Jake Arkinstall via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> I'd choose a different new keyword rather than add a new rule on 'this' which is bound to have some confusing edge cases (especially when passing this to template functions - does it resolve as a pointer? A reference? A special object that tries to behave as both?).
>
> I'd personally go with self ≡ *this, such that self.member = this->member.

And then we'd just decide that a local self shadows the special
meaning, since using such a name is fairly
widespread in existing code. Seems like a complication not worth its benefit.

Received on 2020-03-05 03:25:07