C++ Logo

std-discussion

Advanced search

Re: Does an enum type have the same size, alignment, and value representation as its underlying type?

From: William Linkmeyer <wlink10_at_[hidden]>
Date: Sun, 1 May 2022 21:39:36 -0400
Judging by the existence of this: https://en.cppreference.com/w/cpp/utility/to_underlying

I’d say you’re right.

Still, enumerations are described as ‘distinct types’ (I don’t know if this overlaps with fundamental types).

There are differences between ‘enumerations’ and ‘enumerators’; the first being the enumeration over a types, the second being the underlying enumerated type.

Curious.

WL

> On May 1, 2022, at 8:06 PM, Brian Bi via Std-Discussion <std-discussion_at_[hidden]> wrote:
>
> 
> A fundamental type that has an underlying type is required to have the same size, alignment, and value representation as its underlying type ([basic.fundamental]/6). There doesn't seem to be such a requirement for enum types. Is that intentional?
>
> --
> Brian Bi
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

Received on 2022-05-02 01:39:38