~/talk

Back to Basics: Almost Always Vector

Talkat CppCon 2024 · on Monday, 2024-09-16· at 14:00· Maple 3/4/5, 6700 North Gaylord Rockies Boulevard· [rust]
slides:none on file

Argues that std::vector is the right default for most C++ work and demonstrates why with concrete code: push_back and reallocation behavior, capacity vs size, reserve to avoid reallocations, iterator invalidation rules and pointer-like arithmetic, use of data() for C interop and at() throwing, lambdas and find_if, and a real workload (nlohmann JSON → vector of credit‑card records) that runs 10k and 100k items (100k costs about 2× the time). Slides and runnable code live on the GitHub link.

AI-written summary · about

  1. 0:00Welcome to Almost Always Vector
  2. 1:07Why C++ devs avoid std::vector
  3. 7:30Static arrays limitations
  4. 10:04std::vector basics and creation
  5. 17:52Stack vs heap memory
  6. 23:25Vector size vs capacity
  7. 27:14Memory allocation with reserve
  8. 31:49Iterators in std::vector
  9. 37:02Iterator invalidation pitfalls
  10. 41:14STL algorithms with std::vector
  11. 46:14Credit card data example
  12. 51:34std::vector vs other containers
  13. 54:24Why std::vector is default
  14. 56:31Q&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.