An rvalue is an expression category for a value that is usually temporary and suitable for moving. Unlike a named lvalue, it has no lasting name; using it can avoid copying data. section 2.2.3
Recognize rvalues through their role in container operations:
- A literal such as 42 is an rvalue, while a named variable such as x is an lvalue. section 2.2.3
- A temporary vector returned by get_next_row can bind to push_back(T&&) and be moved instead of copied. section 2.2.3
- emplace_back can construct the container element directly from the temporary. section 2.2.3
Moving temporary triangle rows
generate_triangle builds each row with get_next_row(triangle.back()) and passes that temporary directly to triangle.push_back, avoiding a separate copy. section 2.2.3
A move-constructed vector can take ownership of an rvalue's elements rather than duplicating them. section 2.2.3
