~/talk

std::midpoint? How Hard Could it Be?

Talkat CppCon 2019 · 2019-09-15..09-20· [compilers-and-language-design]
links:none on file
slides:none on file

P0811 adds std::midpoint to C++20 and the actual work is careful engineering: integer midpoint uses make_unsigned, swap-if-a> b and unsigned difference to avoid signed overflow, then produces a branchless unsigned arithmetic sequence; early libc++ revisions hit an LLVM codegen branch bug that gets fixed. Char signedness and promotions bite implementations, pointer overloads misselect on literal 0/null-pointer ambiguity, and floating-point handling must guard denormals, infinities and call nextafter (tests even uncover a PowerPC nextafter bug). libc++ reaches a correct, tested implementation after several revisions.

AI-written summary · about

  1. 0:00Introduction
  2. 1:13Standard library additions
  3. 4:42Introducing std::midpoint
  4. 8:40Numeric types vs math
  5. 12:51Integral types explained
  6. 17:40First midpoint implementation
  7. 21:47Howard Hinnant’s version
  8. 22:29The char type problem
  9. 28:48Midpoint four and codegen
  10. 31:58Pointer midpoint implementation
  11. 37:10Pointer subtraction issues
  12. 46:21Floating-point midpoint
  13. 51:05Testing floating-point equality
  14. 55:23Testing on PowerPC long double
  15. 57:35Branch prediction hints
  16. 58:36Why not use same algorithm for floats
  17. 1:00:15Order sensitivity of midpoint
  18. 1:01:54Q&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.