Nothing is better than copy or move
summary
C++17 makes what used to be “copy elision” mandatory in many cases so temporary materialization conversions must construct objects directly with no copy or move and code that relies on side effects to detect copies is unreliable; using std::move disables NRVO and can force an extra move where none is needed; small trivially copyable structs may be passed in registers but ABIs differ; avoid unnecessary special-member functions, prefer by-value parameters when it simplifies moves, and don’t take shared_ptr by value unless ownership transfer is intended.
AI-written summary · about
chapters (18)
- 0:00Intro
- 1:04How did we get here?
- 9:03How does this magic work?
- 16:45Early days of C++
- 23:22Another C++98 example...
- 25:01A third C++98 example...
- 31:33Can actually break C++03 code
- 36:11Temporary Materialization
- 42:20A simplification
- 43:30Don't be too clever!
- 45:19Another example...
- 46:16One bad object poisons the move
- 48:05Special Members
- 50:29What are the rules?
- 50:56Comparison of copy and move
- 56:24MSVC x86/x64 convention
- 58:50Passing arguments to functions
- 59:15Returning or passing a reference?
related talks
36mInterfaces Matter
58mModern C++ Design (part 2 of 2)
01h 23mRethink Polymorphism in C++
55mBreaking Dependencies: Type Erasure - The Implementation Details
01h 23mThis is C++ - How to Use the C++ Superpower to Write Better C++ Code
39mTemporal Dynamics - Exploring the Intricacies of Object Lifetimes in Modern C++
54mWriting C++ to Be Read
05mMy Temporary Materialization Misconception
