C++ Logo

std-proposals

Advanced search

Re: [std-proposals] explicit this

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Mon, 3 Apr 2023 13:20:16 +0300
On Mon, 3 Apr 2023 at 13:11, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> On Mon, Apr 3, 2023 at 11:04 AM Bo Persson via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> >
> > You already have the option to mark global functions with the scope
> > resolution operator.
> >
> > void SomeClass::SomeFunc(void)
> > {
> > ::SomeOtherFunc();
> > }
> >
> > Then the rest must be members, right?
>
>
> The following doesn't compile:
>
> https://godbolt.org/z/McsfWds38
>
> Here is is copy-pasted:
>
> namespace Monkey {
>
> void Func(void) {}
>
> class Lizard {
> void Func(void) {}
>
> void Func2(void)
> {
> return ::Func();
> }
> };
> }

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.

Received on 2023-04-03 10:20:28