liveBook · Manning

Lvalue

As explained in Learn C++ by Example

An lvalue is a C++ expression category associated with an identifiable object that has a persistent location.

An lvalue is a named expression associated with an identifiable object and its persistent location. In `int x = 42`, `x` is an lvalue, while `42` is an rvalue. section 2.2.3

The distinction matters when vectors receive data. A named vector such as `data` is copied through `push_back(const T&)`; an unnamed temporary from `get_next_row` can use `push_back(T&&)` and move its elements instead. section 2.2.3

void push_back( T&& value ); 

Compare the rvalue-reference overload with the const-reference overload to see how value categories influence vector insertion. section 2.2.3

How Learn C++ by Example covers it

How deep it goes
Defines lvalues and contrasts them with rvalues, while deferring the remaining value categories and full specification details.
Examples
Uses `int x = 42`, named vectors, `get_next_row`, and `push_back` overloads to contrast lvalues with temporaries.
What it assumes
Assumes basic C++ expressions, variables, vectors, and function calls while introducing value-category terminology.
What you can do after
Evaluate/understand when C++ treats an expression as named data or a temporary during vector insertion.
How it connects
Connects lvalues with rvalues, references, move semantics, perfect forwarding, and vector insertion.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn C++ by Example. The section links point to the parts of the book it draws on.