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.

4614. §[numeric.ops.midpoint] No handling of non-finite floats

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 a and b. If T is an integer type and the sum is odd, the result is rounded towards a.

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.

  1. Modify 26.10.16 [numeric.ops.midpoint] as indicated:

    template<class T>
      constexpr T midpoint(T a, T b) noexcept;
    

    -1- Constraints: T is an arithmetic type other than cv bool.

    -2- ReturnsEffects: Half the sum of a and b. If T is an integer type and the sum is odd, the result is rounded towards aIf T is a floating-point type, equivalent to return lerp(a, b, T(0.5)); (29.7.4 [c.math.lerp]). Otherwise, returns half the sum of a and b; if the sum is odd, the result is rounded towards a.

    -3- Remarks: No overflow occurs. If T is a floating-point type, at most one inexact operation occurs.