~/talk

Remove This Idiom

Talkat ACCU 2022 · 2022-04-06..04-09· [c-and-cpp]
slides:none on file

Upgrading to an MSVC STL revision that marks over 3,000 functions with [[nodiscard]] uncovers silent bugs where code calls remove without erasing, or omits the crucial v.end and accidentally deletes one element. The concrete fix is to replace the fragile erase-remove idiom with C++20’s std::erase/std::erase_if for vector and list, which combine move and erase safely. Recommended tooling: run regexes or an clang AST matcher to find erase+remove patterns and automated-replace to std::erase_if.

AI-written summary · about

  1. 0:00Removing idioms in C++
  2. 1:49Compiler upgrade case study
  3. 4:55Misuse of STL remove
  4. 8:11How remove and erase work
  5. 12:47Erase-remove pitfalls
  6. 15:58C++20 erase_if alternatives
  7. 17:21Finding erase-remove patterns
  8. 20:55Q&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.