Subject: Re: [std-proposals] This deduction and access control
From: Matthew Woehlke (mwoehlke.floss_at_[hidden])
Date: 2020-07-20 14:54:26
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.
STD-PROPOSALS list run by herb.sutter at gmail.com
Standard Proposals Archives on Google Groups