Subject: Re: [std-proposals] Operator for reference casting
From: Magnus Fromreide (magfr_at_[hidden])
Date: 2021-01-16 18:37:29
On Sat, Jan 16, 2021 at 05:32:57PM -0500, Arthur O'Dwyer wrote:
> On Sat, Jan 16, 2021 at 5:25 PM Magnus Fromreide via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
> > On Sat, Jan 16, 2021 at 05:38:52PM +0100, Bengt Gustafsson via
> > Std-Proposals wrote:
> > > Given that a language feature has more wiggle room we could define two
> > > different operators with limitations in applicability that can't be
> > enforced
> > > for a library feature such as std::forward / std::move.
> > >
> > > prefix -> is a forwarding operator which can only be applied to universal
> > > references, i.e. parameters declared with deduced template type and a &&
> > > modifier.
> > >
> > > prefix => is a move operator which can only be applied to by value
> > variables
> > > and rvalue references (excluding universal references!).
> > So, x <=> y means operator<(x, =>y), right?
> (Serious answer to a tongue-in-cheek question)
> No, the Maximal Munch Rule <https://en.wikipedia.org/wiki/Maximal_munch>
> invariably applies. `x<=>y` lexes as four tokens in C++17 (x, <=, >, y)
> and as three tokens in C++20 (x, <=>, y).
> C++ has plenty of places where maximal-munch does the "wrong" thing; the
> ones I run into most often are
> template<enable_if_t<x>*=0> void f(); // oops
> template<enable_if_t<x,void*>=0> void f(); // yeesh, still oops
Yes, what I really wanted to say was that the proposed change messes in a part
of the syntax space that already is pretty crowded.
STD-PROPOSALS list run by firstname.lastname@example.org
Standard Proposals Archives on Google Groups