C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::enum_max and std::enum_min

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Mon, 10 Jul 2023 09:02:53 +0100
On Mon, 10 Jul 2023, 08:15 Frederick Virchanza Gotham via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> Given the following enum:
>
> enum MyEnum : int {
> eInvalid = 1,
> eFrog = 2,
> eGoat = 4,
> eFish = 8,
> eMonkey = 16,
> };
>
> I propose that:
>
> std::enum_max<MyEnum>
>
> would evaluate to 16, and that:
>
> std::enum_min<MyEnum>
>
> would evaluate to 1.
>

Why?

This is perfectly valid:
auto e = (MyEnum)INT_MAX;
And similarly for INT_MIN and 0 etc.

So you need to give some actual rationale for your proposal.

Received on 2023-07-10 08:03:08