Back to Basics: Understanding Value Categories
summary
Explains why lvalues, prvalues and xvalues matter for code generation and errors, shows that class prvalues need storage while scalar prvalues often don’t, and proves when the compiler creates temporaries (the temporary materialization conversion). Demonstrates pitfalls with ++ and overloaded operators, why references require addressable objects, and how move semantics work (use std::move to produce an xvalue). Notes that return statements commonly convert named objects to xvalues and that swap benefits from explicit moves.
AI-written summary · about
chapters (19)
- 0:00Intro
- 0:27Value Categories
- 1:15Lvalues and Rvalues Have Evolved
- 5:23Data Storage for Rvalues
- 7:43Literals
- 9:48What About the Result?
- 11:38Data Storage for Expressions
- 13:12Rvalues of Class Type
- 16:09Non-Modifiable Lvalues
- 18:48Reference Types
- 20:41References and Overloaded Operators
- 25:37"Reference to Const" Parameters
- 27:18Why Use "Reference to Const"?
- 27:51References and Temporaries
- 32:41Two kinds of Rvalues
- 35:10Mimicking Built-In Operators
- 40:49Move Operations
- 43:58Rvalue References as Lvalues
- 45:50Lvalues as Xvalues
related talks
01h 02mUnderstanding C++ Value Categories: lvalue, rvalue, xvalue, std::move, std::forward & Best Practices
27mReturn Value Optimization: Harder Than It Looks
58mModern C++ Design (part 2 of 2)
01h 20mWhat Classes We Design and How
01h 19mThis is C++: Uncompromised Performance, Undefined Behavior, & Move Semantics
57mSome Things C++ Does Right
53mC++ Features You Might Not Know
01h 01mFunctional C++
