C++ Logo

std-proposals

Advanced search

[std-proposals] Missing constexpr for std::intmax_t math functions

From: George Tokmaji <tokmajigeorge_at_[hidden]>
Date: Sat, 24 Sep 2022 12:45:59 +0200
 P0533R9 <https://wg21.link/P0533R9> added constexpr to <cmath> and
<cstdlib>, which includes std::abs and std::div. This however missed the
overloads for std::intmax_t as they are defined in <cinttypes>, meaning
that in C++23,

- std::intmax_t abs(std::intmax_t, std::intmax_t);
- std::intmax_t imaxabs(std::intmax_t, std::intmax_t);
- std::intmax_t div(std::intmax_t, std::intmax_t);
- std::intmax_t imaxdiv(std::intmax_t, std::intmax_t)

are not marked as constexpr.

While those functions are technically not part of the proposal since
they're in a different header, this seems like an oversight in the standard
and requires unnecessary casting. Does it count as a standard library
defect or is it supposed to be this way?

Regards,
George

Received on 2022-09-24 10:46:38