Skip to content
0:00 / 0:00

#std::midpoint#c++20#undefinedbehavior

CppCon 2019: Marshall Clow “std::midpoint? How Hard Could it Be?”

CppCon

189K subscribers • 123 videos on Hallway • Conference channel

YouTube
  • Recommended by 2 people: 2 in engineering communities.
  • Presented by Marshall Clow, C++ Alliance Engineer
  • Linked in the descriptionCppCon/CppCon2019

Intermediate. Assumes working knowledge.

26K views7 years ago2 recommendations

Programming languagesSystems programmingC++Performance and optimization

Marshall Clow explores the surprisingly subtle challenges of computing the midpoint between two values in C++ without triggering undefined behavior.

CppCon.org — Discussion & Comments: reddit.com/r/cpp/ — Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2019 — The standards committee adopted "P0811: Well-behaved interpolation for numbers and pointers" for C++20. It includes a new library call `std::midpoint`. The paper says "The simple problem of computing a value between two other values is surprisingly subtle in general." In this talk, I will explore this simple call, provide a history of the development in libc++, and show some of the pitfalls. Undefined behavior will rear its ugly head, along with numeric representations, and the arcane C promotion rules. Along the way, we'll talk about testing, and why writing extensive tests helps everyone. — Marshall Clow C++ Alliance Engineer Marshall has been programming professionally for 35 yearsHe is the author of Boost.Algorithm, and has been a contributor to Boost for more than 15 years. He is the chairman of the Library working group of the C++ standard committee. He is the lead developer for libc++, the C++ standard library for LLVM. — Videos Filmed & Edited by Bash Films: BashFilms.com Work at Hudson River Trading (HRT): tinyurl.com/safxfctf

Why it's here

2 people recommend this

What people say. Recommended as an interesting talk on the complexities of writing a midpoint function and dealing with integer promotions.

u/foonathanin r/programming • Recommends

On “On finding the average of two unsigned integers without overflow”

For a solution, watch this 1h talk which only discusses that function: link to this video

u/keyboard_operatorin r/C_Programming • Recommends

On “According to me the 4th print statement should print -1 but why it is not hapenning?”

Here is an interesting video about writing midpoint function. It's to do with C++, but I believe all those "integer promotions" are applicable to pure C as well. Anyway, worth to watch...  link to this video