Subject: Re: [std-proposals] Operator for reference casting
From: Arthur O'Dwyer (arthur.j.odwyer_at_[hidden])
Date: 2021-01-16 16:32:57
On Sat, Jan 16, 2021 at 5:25 PM Magnus Fromreide via Std-Proposals <
> 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
> > 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
> > 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
STD-PROPOSALS list run by firstname.lastname@example.org
Standard Proposals Archives on Google Groups