C++ Logo

std-proposals

Advanced search

Re: [std-proposals] explicit this

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Mon, 3 Apr 2023 15:27:19 -0500
On Mon, 3 Apr 2023 at 15:02, Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Mon, Apr 3, 2023 at 11:02 AM Ville Voutilainen wrote:
> >
> > void SomeFunc(this SomeClass& self)
> > {
> > //SomeOtherFunc(); /* compiler error */
> > self.SomeOtherFunc(); // OK
> > }
>
>
>
> None of the compilers up on Godbolt can compile this. When will we
> have this new feature?
>

Try MSVC 19.32 or later (with /std:c++latest).
https://msvc.godbolt.org/z/YebM3EEe4

On Mon, Apr 3, 2023 at 1:05 PM Andrew Tomazos wrote:
> >
> > To be fair to the OP, even though he doesn't know about explicit object
> parameters yet,
> > they were not designed for his use case. I think he wants to force
> people to put `this->`
> > in front of member names, because he thinks it makes the code more
> readable (by making
> > member names visually distinct from non-member names). The solution of
> always using
> > explicit object parameters sort of achieves this goal, but requires
> additional syntax of
> > declaring the explicit object parameter in every function, and declaring
> a new and
> > potentially-unique name for it in every member function. 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->`
>
>
> You hit the nail on the head, this is exactly what I was on about.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

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