Back to Basics: Move Semantics (part 1 of 2)
summary
Explains why and how to implement move semantics: rvalue references and std::move are the mechanism, std::forward for perfect forwarding, and move ctor/assign must do memberwise moves plus explicit handling of owning raw pointers (or prefer unique_ptr so phase two disappears). Covers rule of zero/five, when the compiler generates special members, using std::exchange, swap-vs-explicit implementation tradeoffs, self-move behavior, and shows that default move does memberwise moves and that std::move yields an rvalue reference and noexcept on move yields large speedups (measured ~60% in his vector example).
AI-written summary · about
chapters (10)
- 0:00Introduction
- 2:22Real basics
- 8:00Technical terms
- 20:08Move constructor
- 26:46Move operations no except
- 33:43Move assignment operator
- 49:27Special member functions
- 50:12When does the compiler generate these functions
- 52:24The Rule of Five
- 53:27References
related talks
58mTo Move or Not to Move - An Interactive Analysis
01h 02mUnderstanding C++ Value Categories: lvalue, rvalue, xvalue, std::move, std::forward & Best Practices
58mModern C++ Design (part 2 of 2)
01h 19mThis is C++: Uncompromised Performance, Undefined Behavior, & Move Semantics
27mReturn Value Optimization: Harder Than It Looks
51mNew features in C++
03mRule of DesDeMovA
01h 23mThis is C++ - How to Use the C++ Superpower to Write Better C++ Code
