~/talk

Back to Basics: C++ Smart Pointers

Talkat CppCon 2022 · 2022-09-11..09-16· [rust]
links:none on file
slides:none on file

Covers concrete rules: use std::unique_ptr for single ownership (move‑only, noexcept, use release/reset/get), use std::shared_ptr for shared ownership (control block with atomic refcount, copyable, use_count unreliable for races), prefer make_unique/make_shared (one allocation for make_shared), watch double frees when creating separate control blocks from the same raw pointer, use weak_ptr for safe non‑owning references, custom deleters for C APIs (FILE* + fclose), and array support arriving in C++17/C++20 — aims to eliminate leaks.

AI-written summary · about

  1. 0:00Smart pointers intro
  2. 4:17Raw pointers problems
  3. 7:09Unique pointers ownership
  4. 11:30Unique pointers internals
  5. 15:44make_unique cleaner code
  6. 22:04Shared pointers ownership
  7. 25:35Shared pointers memory
  8. 31:13make_shared performance
  9. 33:21Thread safety shared pointers
  10. 36:52Unique vs shared pointers
  11. 37:13Advanced topics
  12. 37:35Weak pointers safe refs
  13. 39:42Custom deleters resources
  14. 43:15Advanced features
  15. 44:42When smart pointers fail
  16. 46:27Smart pointer guidelines
  17. 47:11Summary & Q&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.