Created on 2026-09-11.00:00:00 last changed 2 days ago
Proposed resolution:
This wording is relative to N5054 on top of LWG 4614.
Modify [numeric.ops.overview] as indicated:
[…] // [numeric.ops.midpoint], midpoint template<classintegral T> constexpr T midpoint(T a, T b) noexcept; template<floating_point T> constexpr T midpoint(T a, T b) noexcept; // freestanding-deleted template<class T> constexpr T* midpoint(T* a, T* b); […]
Modify [numeric.ops.midpoint] as indicated:
template<classintegral T> constexpr T midpoint(T a, T b) noexcept;-1- Constraints: `T` is
-2-an arithmetic type other thannot cv `bool`.Effects: If `T` is a floating-point type, equivalent to `return lerp(a, b, T(0.5));` ([c.math.lerp]). Otherwise, returns half
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.template<floating_point T> constexpr T midpoint(T a, T b) noexcept;-?- Effects: Equivalent to: `return lerp(a, b, T(0.5));` ([c.math.lerp])
-?- Remarks: At most one inexact operation occurs.
The standard library typically does not provide freestanding floating-point numerics, but floating-point `std::midpoint` is freestanding, presumably by accident. LWG 4614 makes this pre-existing issue readily apparent by making floating-point `std::midpoint` (freestanding) equivalent to `std::lerp(a, b, T(0.5))` (not freestanding).
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2026-09-19 16:13:04 | admin | set | messages: + msg16616 |
| 2026-09-11 00:00:00 | admin | create | |