Rvalue References


Before understanding about this new feature “Rvalue references” of C++11(Introduction to C++11), we should first understand what is lvalue and rvalue in C++.

Typically Lvalue is an expression which returns a permanent memory address which can be assigned to any variables. For ex:

int x = 10;
int y;
y = 20;

Here both x and y are lvalues. In some cases, we can have functions also as lvalue as shown in below example:

int x;  // global variable

// Returning reference to global variable x
int& getXRef()
{
    return x;
}

getXRef() = 30;

Now this function can act as lvalue too as shown above.

(more…)

Rvalue References Read More