~/talk

Why Iterators Got It All Wrong

Talkat CppNorth 2022 · 2022-07-18..07-20· [c-and-cpp]
links:none on file
slides:none on file

Argues that C++ iterators conflate two distinct concepts — elements vs borders — and that ranges/views/adapters (transform, filter, reverse) expose ambiguous semantics when you call base or mix searches with upper/lower bounds. Tests against ~1M LOC show concrete patterns: find yields 201 unique-match uses, find_if 67 single matches, lower_bound 89 predicate checks, upper_bound 17 border uses (7 decremented). Proposes typed nullable elements, distinct border APIs and refinements like find_unique, element_before/after and return-specifiers to make code correct and clearer.

AI-written summary · about

  1. 0:00Introduction to iterators
  2. 1:49Containers vs views in C++20
  3. 3:13Problems with iterator pairs
  4. 5:22Transform adapter for projections
  5. 8:53Base iterator semantics
  6. 10:18Borders vs elements in reverse
  7. 13:08Filter adapter ambiguity
  8. 16:59Why reverse adapter fails
  9. 19:29General adapter problems
  10. 21:57Need for border and element types
  11. 23:00Analysis of real-world code
  12. 26:09Symmetry in borders and elements
  13. 27:13Nullability of elements
  14. 28:14Element and border functions
  15. 30:20Nullable elements and find
  16. 31:22Find unique and trimming
  17. 32:45Advanced range utilities
  18. 35:11Implementation details
  19. 35:52Why iterators are flawed
  20. 36:35Library improvements needed
  21. 37:00Q&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.