Back to TIL list

Magic Enum C++

Created at

Biblioteca C++17 header-only que provê reflexão estática de enums, trabalha com qualquer tipo de enum sem usar macros.

  • enum_cast obtains enum value from string or integer.
  • enum_value returns enum value at specified index.
  • enum_values obtains enum value sequence.
  • enum_count returns number of enum values.
  • enum_integer obtains integer value from enum value.
  • enum_name returns string name from enum value.
  • enum_names obtains string enum name sequence.
  • enum_entries obtains pair (value enum, string enum name) sequence.
  • enum_index obtains index in enum value sequence from enum value.
  • enum_contains checks whether enum contains enumerator with such value.
  • enum_type_name returns string name of enum type.
  • is_unscoped_enum checks whether type is an Unscoped enumeration.
  • is_scoped_enum checks whether type is an Scoped enumeration.
  • underlying_type improved UB-free "SFINAE-friendly" std::underlying_type.
  • ostream_operators ostream operators for enums.
  • bitwise_operators bitwise operators for enums.

Inserir exemplos

Referências