To Move or Not to Move - An Interactive Analysis
summary
Interactive code-driven analysis of when std::move helps or hurts, using small examples (custom traceable string, stack push/pop, max function, lambda capturing unique_ptr) and tooling demos (sanitizers, Compiler Explorer + clang-tidy). Shows std::move is a cast to rvalue, don't std::move local return values (NRVO/implicit move is cheaper), proves moving a const yields a copy, proves moving after pop_back yields undefined behavior, and explains why move constructors should be noexcept for vector reallocation safety.
AI-written summary · about
chapters (14)
- 0:00Introduction and speaker background
- 1:56Why we need move semantics
- 4:05Move semantics basics in C++11
- 6:34When to use std::move
- 12:17Dangers of moving L values
- 15:53Passing by value and move semantics
- 23:14Returning local variables
- 29:56Rvalue references vs forwarding references
- 37:23Implementing stack push and pop
- 44:17Dangling references after pop
- 47:50noexcept in move operations
- 50:20Rule of zero and move semantics
- 51:46Avoid moving the same resource twice
- 55:16Moving unique_ptr into a lambda
related talks
55mBack to Basics: Move Semantics (part 1 of 2)
54mBack to Basics: Move Semantics (part 2 of 2)
01h 02mUnderstanding C++ Value Categories: lvalue, rvalue, xvalue, std::move, std::forward & Best Practices
27mReturn Value Optimization: Harder Than It Looks
05mMoving an `int` Is Slow: Debug Performance Matters!
01h 19mThis is C++: Uncompromised Performance, Undefined Behavior, & Move Semantics
58mModern C++ Design (part 2 of 2)
01h 03mC++ Trivial Relocation Through Time
