Re: enums that are really just sets of constants



On 6 May 2017 at 18:23, Nicklas Karlsson <nicklas karlsson17 gmail com> wrote:
I think C-style enums lack possibility to specify how many bits should be used for storage which is useful then decoding from some kind of raw data.

No, the underlying type can also be specified for plain enums too. Try it: enum MyPlainEnum: unsigned char

And there's my next point: it's hard to think of a case where this is really useful for 'decoding from raw data', given the very limited allowances that C++ makes for type-punning and other shenanigans. To me it's only useful for conveying numerical semantics and saving space in class layouts, not much else.



 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]