This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Tentatively Ready status.
std::midpoint should not accept const boolSection: 26.10.16 [numeric.ops.midpoint] Status: Tentatively Ready Submitter: Jan Schultke Opened: 2025-05-21 Last modified: 2025-10-21
Priority: Not Prioritized
View all other issues in [numeric.ops.midpoint].
View all issues with Tentatively Ready 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:
Tis an arithmetic type other thanbool.
It does not appear intentional that const bool is supported considering that
26.10.14 [numeric.ops.gcd] excludes cv bool.
[2025-10-21; Reflector poll.]
Set status to Tentatively Ready after seven votes in favour during reflector poll.
This requires template argument to be explicty specified, i.e.
midpoint<const bool>.
I would prefer to address all cv-qualified types at once, e.g.
Constraints:
remove_cv_t<T> is an arithmetic type other than bool."
"This is locally consistent with gcd and lcm which only exclude cv bool.
[algorithms.requirement] p15 makes it unspecified to use an explicit
template argument list here, so midpoint<const bool>
and midpoint<const int> are already unspecified,
this issue just ensures that const bool is explicitly rejected, like bool."
Proposed resolution:
This wording is relative to N5008.
Modify 26.10.16 [numeric.ops.midpoint] as indicated:
template<class T> constexpr T midpoint(T a, T b) noexcept;-1- Constraints:
Tis an arithmetic type other than cvbool.