The rvalue Reference

The traditional C++ reference, now called an lvalue reference, binds an identifier to an lvalue. An lvalue is an expression, such as a variable name or a dereferenced pointer, that represents data for which the program can obtain an address. Originally, an lvalue was one that could appear on the left side of an assignment statement, but the advent of the const modifier allowed for constructs that cannot be assigned to but which are still addressable:

int n;int * pt = new int;const int b = 101;  // can't assign to b, but &b is validint & rn = n;       // n identifies datum at address &nint & rt = *pt;     // *pt identifies datum at address ptconst int & rb = b; // b identifies const datum at address &b

C++11 adds the rvalue ...

Get C++ Primer Plus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.