C++ Logo

std-proposals

Advanced search

Re: [std-proposals] explicit this

From: Andrew Tomazos <andrewtomazos_at_[hidden]>
Date: Mon, 3 Apr 2023 19:43:41 +1000
I think this belongs as a project-specific coding guideline (dont use
implicit member name lookup), and then enforced with a linting tool and IDE
modifications. It would be a strange use case to select this guideline on
a per-class basis with syntax. This would be a project-wide decision.

On Mon, Apr 3, 2023 at 6:32 PM Frederick Virchanza Gotham via Std-Proposals
<std-proposals_at_[hidden]> wrote:

> Sometimes when I'm reading through another person's implementation of
> a class, I see function calls inside member functions:
>
> void SomeClass::SomeFunc(void)
> {
> SomeOtherFunc();
> }
>
> When I first see this code, I don't know if SomeOtherFunc is a member
> function, or whether it's a member datum (i.e. a function pointer), or
> whether it's a global function.
>
> When I write the implementation of my own classes, I tend to like to
> be specific:
>
> void SomeClass::SomeFunc(void)
> {
> this->SomeOtherFunc();
> }
>
> I was thinking it would be good if we could mark a class, or perhaps
> mark a member function, as "explicit this", as follows:
>
> class SomeClass : explicit this {
>
> void (*SomeOtherFunc)(void);
>
> void SomeFunc(void)
> {
> SomeOtherFunc(); /* compiler error */
> }
> };
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-04-03 09:43:54