Back to Basics: Iterators in C++
Talkat CppCon 2023 · on Tuesday, 2023-10-03· at 14:00· Cottonwood 8/9, 6700 North Gaylord Rockies Boulevard·
summary
Covers concrete iterator design decisions: iterator categories (input, forward, bidirectional, random‑access, continuous), why algorithms like sort require random access, and why performance drove the API. Demonstrates concrete failures: vector reallocation invalidates iterators (use erase/refresh or avoid holding iterators), transform needs destination sized or use back_inserter, remove returns a new end, and C++20 filter views cache begin so modifying elements that break the predicate yields undefined behavior. Mentions C++98→20 history and real code fixes.
AI-written summary · about
chapters (21)
- 0:00Iterators in C++ intro
- 1:06Pointers to iterator abstraction
- 6:49Why iterators matter
- 11:06Basic iterator usage
- 17:40Const iterators and categories
- 21:40Input iterators explained
- 25:38Safe iteration beyond random access
- 27:48Iterators glue algorithms
- 32:51Raw arrays as iterators
- 34:16Generic vs OO design
- 35:20Iterator invalidation in vectors
- 40:20Writing to iterators UB
- 43:37Why remove doesn't remove
- 46:28Iterators C++98 to C++20
- 47:12Ranges and views C++20
- 51:54How filter views work
- 53:24Generic print with views
- 55:31Views design flaws UB
- 58:25Iterators in ranges still matter
- 59:33Summary on iterators
- 1:00:37Q&A: Custom iterators C++20
related talks
01h 02mWhy iterators got it all wrong
01h 02mBack to Basics: Almost Always Vector
01h 01mBack to Basics: C++ API Design
58mUnderstanding and Mastering C++'s Complexity
59mBetter Algorithm Intuition
58mFrom Iterators to Ranges: The Upcoming Evolution Of the STL
01h 30m50 shades of C++
01h 00mSTL Features And Implementation Techniques
