r/cpp • Meeting C++ | C++ Evangelist • Jul 19 '26

A better bitset for enum flags

https://www.elbeno.com/blog/?p=1836
41 Upvotes

32 comments sorted by

View all comments

Show parent comment

2

u/SyntheticDuckFlavour Jul 19 '26

What if you want the underlying layout/bit pattern like bitset? Sometimes you want to map I/O ports that way.

3

u/TheVoidInMe Jul 19 '26

I don’t believe you can get at that at all. Java is probably too high level for stuff like that anyway. In C++ I would expect a method like `to_int()` (maybe returning the enum’s `underlying_type_t`…)