Re: enums that are really just sets of constants



Hello,

I welcome the change to enum classes. I have made this transition recently in my project and want to share my 
experience:

A conversion to bool from enum class is possible via
  bool operator!(ResponseType i) { return (i != ResponesType::NONE); }
  ResponseType i = f();
  if (!i) ;
  if (!!i) ; // it is not possible to use 'if (i)'

A comparison is also possible:
  bool operator<(BuiltinIconSize lhs, BuiltinIconSize rhs);

For numbers, which are |ed (like CalendarDisplayOptions) your second suggestion looks promising. But it will 
be a hack to get
  void Calendar::set_display_options(Calendar::DisplayOptions flags);
to accept
  calendar.set_display_options(Calendar::DisplayOptions::SHOW_HEADING | 
Calendar::DisplayOptions::SHOW_DAY_NAMES); 

And it would be good to further disallow
  Calendar::DisplayOptions::SHOW_HEADING | UIManager::ItemType::POPUP


Diether

Attachment: pgplPaZfVfp2t.pgp
Description: Digitale Signatur von OpenPGP



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