The Nightmare of Move Semantics for Trivial C++ Classes
summary
Examines a trivial class with multiple std::string members and measures how common constructor patterns produce surprising extra allocations and copies (several heap allocations for simple literal+string combinations, sometimes four down to two). Uses live coding to compare const& parameters, pass-by-value then std::move, and perfect forwarding with universal references plus SFINAE/enable_if hacks; shows pass-by-value-then-move gives the simplest best performance, perfect forwarding is brittle (hijacks copy ctor, needs enable_if or C++20 requires), and std::string_view can make things worse.
AI-written summary · about
chapters (4)
related talks
59mBack to Basics: Move Semantics
01h 03mC++ Trivial Relocation Through Time
01h 03mOLD VERSION: Understanding The constexpr 2-Step
01h 39m“Thoughts on a more powerful and simpler C++ (5 of N)”
01h 04m“Constant Fun"
01h 41mC++ Type Erasure Demystified
01h 00mType punning in modern C++
57mIntroduction to C++ Template Metaprogramming
