Magic_enum

screenshot of Magic_enum

Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code

Overview:

The "Magic Enum C++" library is a header-only C++17 library that provides static reflection for enums. It allows users to work with any enum type without needing to write any macro or boilerplate code. The library provides various features such as converting enum values to strings, strings to enum values, integers to enum values, indexed access to enum values, iterating through enum values, and more.

Features:

  • Enum value to string conversion
  • String to enum value conversion
  • Integer to enum value conversion
  • Indexed access to enum values
  • Enum value sequence
  • Number of enum elements
  • Enum value to integer conversion
  • Enum names sequence
  • Enum entries sequence
  • Enum fusion for multi-level switch/case statements
  • Enum switch runtime value as constexpr constant
  • Enum iteration for each enum as constexpr constant
  • Check if enum contains a value
  • Enum index in sequence
  • Functions for flags
  • Enum type name
  • Iostream operator for enum
  • Bitwise operator for enum
  • Checks whether type is an Unscoped enumeration
  • Checks whether type is a Scoped enumeration
  • Static storage enum variable to string
  • Lightweight and not restricted to the enum_range limitation
  • Support for array container for enums
  • Support for bitset container for enums
  • Support for set container for enums
  • Improved UB-free "SFINAE-friendly" underlying_type

Summary:

The "Magic Enum C++" library is a powerful header-only C++17 library that provides static reflection for enums. It allows users to work with enums easily without needing to write any additional code. The library offers a wide range of features, including conversions between enum values, strings, and integers, indexed access to enum values, enumeration iteration, and support for various container types. With simple installation options, the library can be integrated into projects using different build systems or package managers. It is licensed under the MIT License, making it free for both personal and commercial use.