What are rvalues, lvalues, xvalues, glvalues, and prvalues in C++?


  • An lvalue has an address that your program can access. Examples of lvalue expressions include variable names, including const variables, array elements, function calls that return an lvalue reference, bit-fields, unions, and class members.
  •  A xvalue expression has no address but can be used to initialize an rvalue reference, which provides access to the expression. Examples include function calls that return an rvalue reference, the array subscript, etc.
  •  A glvalue (“generalized” lvalue) is an lvalue or an xvalue.
  •  An rvalue (so-called, historically, because rvalues could appear on the right-hand side of an assignment expression) is an xvalue, a temporary object or subobject thereof, or a value that is not associated with an object.
  •  A prvalue expression has no address that is accessible by your program. Examples of prvalue expressions include literals, function calls that return a non-reference type

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 27-Feb-2020

400 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements