~/talk

Destructor Case Studies: Best Practices for Safe and Efficient Teardown

Talkat CppCon 2019 · 2019-09-15..09-20· [software-architecture]
slides:none on file

Destructors must be minimal and correct: prefer best destructor is no destructor by using RAII (unique_ptr, scoped handles) so ownership is explicit, avoid redundant clears and resets, and never declare a trivial destructor because that can suppress move operations. Always join threads before destruction, avoid calling virtual functions from constructors/destructors, catch and swallow exceptions so destructors never throw, and let vector implementations skip individual destroys when T is is_trivially_destructible.

AI-written summary · about

  1. 0:00Introduction to destructors
  2. 1:36Why destructors matter
  3. 3:47C++17 baseline and resources
  4. 5:34Destructor definition and properties
  5. 8:06When destructors are called
  6. 9:34Standard library destructors
  7. 12:47Avoid explicit destructors
  8. 16:26Trivial destructors explained
  9. 18:59Simplifying destructors
  10. 22:11Avoid public functions in destructors
  11. 25:03Raw resources and scoped handles
  12. 27:15RAII and memory leaks
  13. 29:03Raw pointers and ownership
  14. 31:10Thread destructors and joining
  15. 35:11Virtual destructors explained
  16. 37:29Order of destruction
  17. 40:02Avoid virtual functions in destructors
  18. 44:30Exception safety in destructors
  19. 48:49Explicit destructors and placement new
  20. 51:26Custom allocators
  21. 52:09Vector destructors
  22. 54:15Destructor traits in C++14
  23. 56:26Best practices summary
  24. 59:02Q&A
~/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.