C++ Logo

std-proposals

Advanced search

Re: [std-proposals] explicit modifier for R-value references

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Wed, 21 Jun 2023 10:29:09 +0100
On Wed, Jun 21, 2023 at 10:13 AM Frederick Virchanza Gotham
<cauldwell.thomas_at_[hidden]> wrote:
>
> Or maybe something like:
> use( !&&arg );
>
> The "!&&" would be globbed as one token and mean "Turn this R-value
> ref into an L-value ref", basically meaning "std::nomove(arg)".


Just realising that this would break code that has the boolean
negation operator followed by two addresof operators, as in:

    ! &&some_object

This won't compile for an intrinsic type, because the first '&' yields
an Rvalue, and so the second '&' can't be applied to an Rvalue.

But for a user-defined class, if the '&' operator returns an Lvalue,
then "! &&" could make sense. There might no be code anywhere that
does that though.

Received on 2023-06-21 09:29:22