C++ Logo

std-proposals

Advanced search

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

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Sun, 25 Sep 2022 14:57:01 -0400
On Sat, Sep 24, 2022 at 6:46 AM George Tokmaji via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> 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?
>

I think you're probably right that it's an oversight. Sounds to me like a
suitable topic for an LWG defect report.
(I can assist in submitting such a defect report; let me know if you want
that.)

my $.02,
Arthur

Received on 2022-09-25 18:57:13