This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4265. std::midpoint should not accept const bool

Section: 26.10.16 [numeric.ops.midpoint] Status: New Submitter: Jan Schultke Opened: 2025-05-21 Last modified: 2025-05-24

Priority: Not Prioritized

View all other issues in [numeric.ops.midpoint].

View all issues with New status.

Discussion:

The constraints of the first overload of std::midpoint are as follows:

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

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

It does not appear intentional that const bool is supported considering that 26.10.14 [numeric.ops.gcd] excludes cv bool.

More generally, it is questionable that cv-qualified arithmetic types aren't excluded in general, considering that 26.10.17 [numeric.sat] excludes them with the "signed or unsigned integer type" constraint. However, tightening the constraints for these other functions seems evolutionary, not like fixing an obvious oversight, and so it likely requires a separate issue.

Proposed resolution:

This wording is relative to N5008.

  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.