Title
Example binding an rvalue reference to an lvalue
Status
cd2
Section
Clause [7] [expr]
Submitter
Daniel Krügler

Created on 2009-04-06.00:00:00 last changed 143 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting as part of document N3055.]

Date: 2009-07-15.00:00:00

Proposed resolution (July, 2009):

Change the example in Clause 7 [expr] paragraph 6 as follows:

[Example:

  struct A { };
  A&& operator+(A, A);
  A&& f();

  A a;
  A&& ar = static_cast<A&&>(a);

The expressions f() and a + a are rvalues of type A. The expression ar is an lvalue of type A. —end example]

Date: 2020-12-15.00:00:00

The adoption of paper N2844 made it ill-formed to attempt to bind an rvalue reference to an lvalue, but the example in Clause 7 [expr] paragraph 6 was overlooked in making this change:

    struct A { };
    A&& operator+(A, A);
    A&& f();

    A a;
    A&& ar = a;

The last line should be changed to use something like static_cast<A&&>(a).

(See also issue 847.)

History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2667
2010-03-29 00:00:00adminsetstatus: review -> cd2
2009-08-03 00:00:00adminsetmessages: + msg2184
2009-08-03 00:00:00adminsetstatus: open -> review
2009-04-06 00:00:00admincreate