~/talk

The Nightmare of Move Semantics for Trivial C++ Classes

Talkat NDC TechTown 2018 · 2018-09-27..09-30· [compilers-and-language-design]
slides:none on file

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

  1. 0:00Start
  2. 4:07Implicit Type Conversion
  3. 12:38Perfect Forwarding
  4. 34:13Alternatives
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.