~/talk

The Dark Corner of STL in Cpp: MinMax Algorithms

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

Shows that calling std::min/std::max leads to dangling references when overloads return const references, and that C++14 initializer_list overloads fix lifetimes by returning by value but force initializer_list copies and prohibit moves. Demonstrates const correctness issues that sometimes tempt const_cast and undefined behavior, and builds alternative overload sets and a cleaner C++20 solution that decouples argument types, uses common_reference and perfect forwarding so rvalues move and lvalues don’t — it works but remains ergonomically sharp.

AI-written summary · about

  1. 0:00STL min-max intro
  2. 1:48Why min-max is tricky
  3. 3:56Dangling references in min-max
  4. 8:35C++20 vs C++14 min-max
  5. 12:33Const correctness issues
  6. 15:22Fixes for min-max problems
  7. 19:20Custom min-max simplified
  8. 24:00Optimized custom min-max
  9. 25:03Summary and cautions
~/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.