This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Ready status.
Section: 26.10.16 [numeric.ops.midpoint] Status: Ready Submitter: Jan Schultke Opened: 2026-08-16 Last modified: 2026-09-11
Priority: 3
View all other issues in [numeric.ops.midpoint].
View all issues with Ready status.
Discussion:
While std::midpoint accepts operands of floating-point type, it is unclear what the midpoint
is if any operand is an infinity, if both operands are differently signed infinities, if any
operand is a NaN, etc. The specification merely says:
Returns: Half the sum of
aandb. IfTis an integer type and the sum is odd, the result is rounded towardsa.
Not only is there no description of the result, there is also no description of error handling
because the blanket wording in 16.2 [library.c] does not apply to <numeric>,
only to <cmath> functions.
[2026-08-27; Reflector poll.]
Set priority to P3 after reflector poll.
"lerp handles such corner cases, just call lerp to get it right."
[2026-09-11; LWG telecon. Status changed: New → Ready.]
Proposed resolution:
This wording is relative to N5054.
Modify 26.10.16 [numeric.ops.midpoint] as indicated:
template<class T> constexpr T midpoint(T a, T b) noexcept;-1- Constraints:
-2-Tis an arithmetic type other than cvbool.ReturnsEffects:Half the sum ofIfaandb. IfTis an integer type and the sum is odd, the result is rounded towardsaTis a floating-point type, equivalent toreturn lerp(a, b, T(0.5));(29.7.4 [c.math.lerp]). Otherwise, returns half the sum ofaandb; if the sum is odd, the result is rounded towardsa. -3- Remarks: No overflow occurs. IfTis a floating-point type, at most one inexact operation occurs.