C++11 add this new type of reference called Rvalue reference. Rvalue references are references to rvalues only. It can be created using double ampersand (&&) as shown below:

int &&ref{5};
 
std::cout << ref << '\n';

Rvalue references make it possible to have references to literal values. Although we could do this using lvalue reference to const, but could not change the referenced value. With Rvalue references, we can also change the referenced value as shown below:

ref = 101;

Rvalue references in function parameters

If a function parameter is of type lvalue reference to const, we can pass both lvalue and rvalues. With rvalue references, we can directly make function parameter of this type.

For example:

void print(const int &lvalue)
{
    std::cout << "Called with lvalue" << '\n';
    std::cout << lvalue << '\n';
    std::cout << "--------------" << '\n';
}
 
void print(int &&rvalue)
{
    std::cout << "Called with rvalue" << '\n';
    std::cout << rvalue << '\n';
    std::cout << "--------------" << '\n';
}
 
print(value); // calls the one with lvalue reference
print(5);     // calls the one with rvalue reference

print(value) calls the function with lvalue reference as parameter as value is an lvalue. print(5) calls the function with rvalue reference as parameter. Even though we function with lvalue reference to const, rvalue reference parameter gets the priority.

Rvalue reference variables are lvalue

A rvalue reference variable is an lvalue. As type and value category are two independent property of an object, the rvalue reference variable type is rvalue but the value category is of type lvalue.

So, ref variable is of type int&& but it is an lvalue. So, when passed to the function:

print(ref);

It calls function with lvalue reference parameter.

References

  1. https://www.learncpp.com/cpp-tutorial/rvalue-references/