C++ Logo

std-proposals

Advanced search

Re: [std-proposals] explicit this

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Mon, 3 Apr 2023 16:06:31 +0300
On Mon, 3 Apr 2023 at 13:40, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> On Mon, Apr 3, 2023 at 11:20 AM Ville Voutilainen
> <ville.voutilainen_at_[hidden]> wrote:
> >
> > Looks like you're failing to see the point. When you write it
> > correctly, that is,
> >
> > return ::Monkey::Func();
> >
> > you know that's a non-member function because it has a :: in the very
> > beginning, so it can't
> > be a member function of the current class or of a base class.
>
>
> I understood the point. The counter-point I was making was that you
> sometimes needed to prepend something more complicated than "::".
>
> By the way "::Monkey" won't work if Monkey is inside another namespace:

Of course it doesn't work. The point is, you have a syntax that allows you
to unambiguously say that you're calling a non-member function, but that
syntax comes with a trade-off that you need to fully-qualify the complete
namespaced name, it can't be partial. Luckily, when you use that syntax,
the compiler will tell you whether you got it right.

Deduced this then gives you a syntax that allows you to make sure you're calling
a member function, and that comes with a trade-off that you need to declare
your function as a deducedthis function.

Both solutions are close enough that it ostensibly requires a very
strong rationale
to add something else.

Received on 2023-04-03 13:06:44