C++ Logo


Advanced search

Subject: [std-proposals] Operator for reference casting
From: Bengt Gustafsson (bengt.gustafsson_at_[hidden])
Date: 2021-01-16 10:38:52

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!).

In line with what I wrote before this means that the two operators would
have disjunct areas of applicability (you never have a choice as to
which one to apply, in each instance one or the other will be a
compilation error). So do we add or reduce confusion by having two
distinct spellings? I don't know, what do you think?

There is a possible tactical advantage with this definition in that it
is not possible to implement it in the library. The motivation for
introducing it as a language feature could thus be higher. This relies
on an urge to reduce the risks with the status quo, which if you as me
is not really the problem we're actually trying to solve; it is the
verbosity of std::forward.


STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups