Title
Xvalues vs lvalues in conditional expressions
Status
cd5
Section
7.6.16 [expr.cond]
Submitter
Richard Smith

Created on 2016-02-01.00:00:00 last changed 40 months ago

Messages

Date: 2017-11-15.00:00:00

Proposed resolution (November, 2017)

Change 7.6.16 [expr.cond] bullet 4.1 as follows:

Attempts are made to form an implicit conversion sequence from an operand expression E1 of type T1 to a target type related to the type T2 of the operand expression E2 as follows:

  • If E2 is an lvalue, the target type is “lvalue reference to T2”, subject to the constraint that in the conversion the reference must bind directly (9.4.4 [dcl.init.ref]) to an lvalue a glvalue.

  • ...

Date: 2018-03-15.00:00:00

[Accepted as a DR at the March, 2018 (Jacksonville) meeting.]

In the following example,

   const T a;
   T b;
   false ? a : std::move(b);

the most appropriate result would seem to be that the expression is an lvalue of type const T that refers to either a or b. However, because 7.6.16 [expr.cond] bullet 4.1 requires that the conversion bind directly to an lvalue, while std::move(b) is an xvalue, the result is a const T temporary copy-initialized from std::move(b).

History
Date User Action Args
2020-12-15 00:00:00adminsetstatus: dr -> cd5
2018-04-11 00:00:00adminsetstatus: tentatively ready -> dr
2018-02-27 00:00:00adminsetmessages: + msg5854
2018-02-27 00:00:00adminsetstatus: open -> tentatively ready
2016-02-01 00:00:00admincreate