C++ Logo

std-proposals

Advanced search

Re: This deduction and access control

From: Matthew Woehlke <mwoehlke.floss_at_[hidden]>
Date: Mon, 20 Jul 2020 15:54:26 -0400
On 20/07/2020 08.43, Magnus Fromreide via Std-Proposals wrote:
> When calling a deduced this member
>
> instance.deduced_this_member(a, b);
>
> then that is interpreted as
>
> deduced_this_member(instance, a, b);
>
> This looks exactly like what N4165 proposed albeit restricted to only
> deduced this members and that is why I asked. It could very well be that
> limiting it to only deduced this members solves all the problems.

Er... yes and no. The difference is, what you wrote is how C++ has
*always* worked, with the caveat that you don't "see" the 'instance'
argument in a member function (except as `this`).

The difference you are possibly overlooking is that
`deduced_this_member` is still a *member* function, with all the
limitations and other attributes thereof. UFCS is about being able to
substitute *free* functions. P0847, OTOH, is just making the previously
implicit `this` argument more exposed (a bit like Python), with
additional fiddly-bits to make said exposure more useful.

Really, though, it's that "still a member function" that's important. A
lot of the issues with UFCS deal with knowing whether you're calling a
member or a free function, and the ability to arbitrarily introduce
matching free functions. So, yes, "limiting it to only deduced this
members solves all the problems" is probably (at least mostly) accurate.

-- 
Matthew

Received on 2020-07-20 14:57:45