...

/

Rvalue and Lvalue References

Rvalue and Lvalue References

In this lesson, we will discuss rvalue and lvalue references.

Rvalues and Lvalues

Rvalues are

  • Temporary objects
  • Objects without a name
  • Objects from which we can not get the address

If one of these characteristics holds for an object, it is an rvalue. On the other hand, values with a name and an address are lvalues.

  • Lvalues can be on the left side of an assignment operator.
  • Rvalues can only be on the right side of an assignment operator.

A few examples of rvalues:

int five= 5;
std::string a= std::string("Rvalue");
std::string b= std::string("R") + 
...