~/talk

Rethink Polymorphism in C++

Talkat C++ on Sea 2025 · 2025-06-23..06-25· [c-and-cpp, software-architecture]
slides:none on file

Argues that runtime inheritance plus heap pointers is error-prone and slow, and demonstrates alternatives using std::variant, variadic templates and move semantics to get value semantics and heterogeneous containers without new/delete. Benchmarks show copying shared_ptr pays heavy atomic costs (microbenchmarks report up to ~10,000× slowdown in his reproduction), unique_ptr avoids that but disallows copying, and a variant-based picture often gives much faster destruction and downcast times (roughly 5–10× improvement in his tests).

AI-written summary · about

  1. 0:00C++ polymorphism intro
  2. 1:54Runtime polymorphism with virtual
  3. 6:32Raw pointers in collections problems
  4. 10:00RAII and smart pointers for safety
  5. 23:28Shared pointers and threading overhead
  6. 37:35Atomic reference counting impact
  7. 43:40Virtual table overhead in runtime poly
  8. 46:51Compile-time polymorphism with templates
  9. 51:30Variant-based polymorphism without inheritance
  10. 1:01:50Performance comparison of poly approaches
  11. 1:12:33Teaching polymorphism basics
  12. 1:18:16Q&A on variant visitors
~/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.