C++ Logo

std-proposals

Advanced search

Re: [std-proposals] explicit this

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Mon, 3 Apr 2023 10:35:59 +0200
Already added:
```
class Foo
{
    void SomeFunc(this Foo&)
    {
        this; //error!
    }
};
```

pon., 3 kwi 2023 o 10:32 Frederick Virchanza Gotham via Std-Proposals
<std-proposals_at_[hidden]> napisaƂ(a):
>
> 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 08:36:10