~/talk

Safe and Sane C++ Types

Talkat ACCU 2019 · 2019-04-10..04-13· [c-and-cpp, software-architecture]
slides:none on file

Argues that raw pointers and C-style arrays are obsolete: use unique_ptr and RAII to eliminate leaks and double-free, with code shown on GitHub for a unique_resource helper (works but needs cross-compiler fixes). Demonstrates concrete bugs: NaN collapses a std::set to size 1, unsigned size()-1 makes an infinite loop, and string_view easily dangles. Recommends strong primitive wrappers to prevent swapped-argument bugs, using empty-type mixins and empty-base optimization to keep wrappers zero-overhead, and applies the Rule of Desdemona (delete move-assignment when defining a destructor).

AI-written summary · about

  1. 0:00Introduction and audience
  2. 1:09Modern C++ safety improvements
  3. 3:49Safety critical systems and regulation
  4. 7:01Value types in C++
  5. 8:48Empty types and their uses
  6. 9:33Deterministic lifetime model
  7. 10:17Avoiding dynamic polymorphism
  8. 11:01Potentially dangling types
  9. 12:46Regular and semi-regular types
  10. 15:22C++20 and future changes
  11. 16:28Rule of Des to mover
  12. 17:11Type categories and usage
  13. 19:23Primitive types safety issues
  14. 23:29Double type pitfalls
  15. 28:38Built-in type problems
  16. 34:24Primitive type wrappers
  17. 37:20Strong typing and domain modeling
  18. 43:55Wrapping value types
  19. 46:23Assign spaces and unit types
  20. 49:56Empty classes and their uses
  21. 53:35Compile-time computation with empty types
  22. 56:00Empty base class optimization
  23. 1:00:21Unique pointers and memory management
  24. 1:02:07Adaptors and inheriting constructors
  25. 1:03:34Potentially dangling object types
  26. 1:07:14Iterators and dangling references
  27. 1:11:05Pointer alternatives and guidelines
  28. 1:13:15Smart pointers and heap allocation
  29. 1:14:41Views and spans
  30. 1:17:17Discipline with pointer types
  31. 1:18:19Managing and pointing types
  32. 1:22:16Unique resource implementation
  33. 1:23:02Dynamic polymorphism pitfalls
  34. 1:25:19Rule of Des to mover recap
  35. 1:26:50Type erasure and value semantics
  36. 1:28:15Aggregate and value classes
  37. 1:30:43Key takeaways and conclusion
~/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.