Title
const_cast to rvalue reference from objectless rvalue
Status
cd2
Section
7.6.1.11 [expr.const.cast]
Submitter
Steve Adamczyk

Created on 2009-05-08.00:00:00 last changed 178 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting.]

Date: 2010-02-15.00:00:00

Proposed resolution (February, 2010):

Change 7.6.1.11 [expr.const.cast] paragraph 4 as follows:

An lvalue of type T1 can be explicitly converted to an lvalue of type T2 using the cast const_cast<T2&> (where T1 and T2 are object types) if a pointer to T1 can be explicitly converted to the type “pointer to T2” using a const_cast. Similarly, for two object types T1 and T2, an expression lvalue of type T1 or, if T1 is a class type, an expression of type T1, can be explicitly converted to an rvalue of type T2 using the cast const_cast<T2&&> if a pointer to T1 can be explicitly converted to the type “pointer to T2” using a const_cast. The result of a reference const_cast refers to the original object.
Date: 2009-07-15.00:00:00

Notes from the July, 2009 meeting:

The coresponding cast to an lvalue reference to const is ill-formed: in such cases, the operand must be an lvalue. The consensus of the CWG was that a cast to an rvalue reference should only accept an rvalue that is an rvalue reference (i.e., an object).

Date: 2009-05-08.00:00:00

7.6.1.11 [expr.const.cast] paragraph 4 says,

...Similarly, for two effective object types T1 and T2, an expression of type T1 can be explicitly converted to an rvalue of type T2 using the cast const_cast<T2&&> if a pointer to T1 can be explicitly converted to the type “pointer to T2” using a const_cast. The result of a reference const_cast refers to the original object.

However, in some rvalue-reference const_casts there is no “original object,” e.g.,

    const_cast<int&&>(2)
History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2677
2010-03-29 00:00:00adminsetstatus: tentatively ready -> cd2
2010-02-16 00:00:00adminsetmessages: + msg2496
2010-02-16 00:00:00adminsetstatus: drafting -> tentatively ready
2009-11-08 00:00:00adminsetstatus: open -> drafting
2009-08-03 00:00:00adminsetmessages: + msg2216
2009-05-08 00:00:00admincreate