Daily bit(e) of C++ | std::midpoint
Daily bit(e) of C++ #194, The C++20 utility for calculating the midpoint between two arithmetic types or pointers: std::midpoint.
Calculating the midpoint value between two arithmetic types or pointers might seem trivial; however, when the values are close to numerical limits or not in order, trivial implementations can easily run into undefined behaviour.
C++20 introduced std::midpoint, which provides a safe implementation.
Any chance that the header file import statement should be ‘ #include <limits>’ instead?
"How hard could it be? "