Back to Basics: Move Semantics (part 2 of 2)
summary
Explains that forwarding references (T&& in a deducing context) become lvalue references for lvalue args and rvalue references for rvalues via reference collapsing, so use std::forward vs std::move to conditionally cast; unguarded std::move from a forwarding parameter is a bug. Shows make_unique and overload pitfalls where a template forwarding constructor wins unexpectedly, demonstrates ambiguous overload resolution with six reference overloads, warns that moving a named return disables RVO, and advises avoid overloading on forwarding references and remove reference qualifiers for type traits.
AI-written summary · about
chapters (8)
- 0:00Introduction to move semantics
- 7:22What are forwarding references
- 13:12Perfect forwarding with std::forward
- 21:16Overloading pitfalls with forwarding
- 30:20Common forwarding mistakes
- 40:13Return value optimization
- 47:35Anti-patterns and core guidelines
- 51:18Q&A session
related talks
58mModern C++ Design (part 2 of 2)
58mTo Move or Not to Move - An Interactive Analysis
27mReturn Value Optimization: Harder Than It Looks
01h 02mUnderstanding C++ Value Categories: lvalue, rvalue, xvalue, std::move, std::forward & Best Practices
12mTraits Go Mainstream...
57m“The Nightmare of Move Semantics for Trivial Classes”
01h 19mThis is C++: Uncompromised Performance, Undefined Behavior, & Move Semantics
51mNew features in C++
