~/talk

Casts in C++: To lie... and hopefully - to lie usefully

Talkat Meeting C++ 2025 · 2025-11-06..11-08· [rust]
links:none on file
slides:none on file

Concrete rules and runnable examples: which cast is zero-cost and static_cast is the go‑to, when to use dynamic_cast for runtime checks, when const_cast is the only way to interoperate with bad APIs, and why reinterpret_cast and C‑style casts invite UB. Slides link includes working links and compile‑time checks, a facet‑based manager demo that stores heterogenous objects and retrieves them with safe downcasts, plus std::bit_cast, any_cast and smart‑pointer cast recipes.

AI-written summary · about

  1. 0:00Casting and lies in C++
  2. 3:34Why lie with casts
  3. 8:32C++ cast types overview
  4. 10:16Static cast for safe conversions
  5. 14:29Static cast in class hierarchies
  6. 21:15Static cast with void pointers
  7. 24:07Static cast in constexpr
  8. 27:40Const cast for const removal
  9. 37:39Dynamic cast for downcasts
  10. 44:27Const cast use cases
  11. 51:53Reinterpret cast for low-level work
  12. 59:41C-style casts dangers
  13. 1:02:32Modern C++ casts
  14. 1:06:06Custom cast-like functions
  15. 1:08:40Why cast and ethics
~/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.