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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access