Re: enums that are really just sets of constants



On 22 April 2017 at 05:57, Dr. Diether Knof wrote:
Hello,

for the integer wraps used for flags I have a third proposition, a working example is attached:
* "enum class DisplayOption" for the individual flags
* "class DisplayOptions" with an implicit converter DisplayOption -> DisplayOptions
So we get an enum for the single options and avoid the old enum-style.

Why not have the constants declared inside the class, so you only have
one name to remember, not DisplayOption and DisplayOptions?

You can overload operator| and operator& for enums, so the only
benefit to this seems to be the implicit conversion to bool (why not
explciit?)


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