Understanding C++ Value Categories: lvalue, rvalue, xvalue, std::move, std::forward & Best Practices
summary
Clear, example-driven breakdown of why C++ has five value categories (lvalue, xvalue, prvalue, glvalue, rvalue), how rvalue references plus std::move enable move semantics, and when std::forward (universal/forwarding references, reference collapsing) preserves value category. Shows concrete surprises: const temporaries defeat moves (so std::move can trigger a copy), C++17 mandates guaranteed elision, and move ops should be noexcept. Uses short quizzes and code examples to prove behavior and recommend fixes.
AI-written summary · about
chapters (9)
- 0:00Introduction and motivation
- 2:02Understanding expressions
- 9:17Historical context and categories
- 16:44The five value categories
- 23:16Categorization and examples
- 36:07Rvalue references
- 37:47Move semantics in practice
- 42:21Universal references and templates
- 50:14Perfect forwarding and best practices
related talks
54mBack to Basics: Understanding Value Categories
55mBack to Basics: Move Semantics (part 1 of 2)
54mBack to Basics: Move Semantics (part 2 of 2)
58mModern C++ Design (part 2 of 2)
58mTo Move or Not to Move - An Interactive Analysis
27mReturn Value Optimization: Harder Than It Looks
01h 20mWhat Classes We Design and How
01h 19mThis is C++: Uncompromised Performance, Undefined Behavior, & Move Semantics
