C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Support std::numeric_limits for enums

From: Magnus Fromreide <magfr_at_[hidden]>
Date: Sun, 2 Oct 2022 15:47:42 +0200
On Sat, Oct 01, 2022 at 07:53:56PM -0400, Jason McKesson via Std-Proposals wrote:
> On Sat, Oct 1, 2022 at 7:13 PM connor horman via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > Keep in mind also that the max value of any enumerator may not be the maximum (or minimum) value the enum takes on. For example, an enum that is already a bitfield, or a type like std::byte.
>
> And what about enums that are treated as exactly what they are: a
> value that can take on a fixed number of valid values?
>
> That's kind of the point of this. C++ has tools for treating enums as
> bitfields or for treating enums as a hack for strong typedefs as
> integers.

Maybe that is the problem - the compiler is able to generate better code
and diagnostics when it is told what the code is intended to do but here we
have a single piece of code that can have multiple intents, should there be
some way to tell the compiler what the intent is?

/MF

Received on 2022-10-02 13:47:46