Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
humble

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
hri

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
jazzy

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
kilted

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
rolling

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

No version for distro ardent showing humble. Known supported distros are highlighted in the buttons above.
Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
humble

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
hri

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

No version for distro bouncy showing humble. Known supported distros are highlighted in the buttons above.
Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
humble

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
hri

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

No version for distro crystal showing humble. Known supported distros are highlighted in the buttons above.
Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
humble

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
hri

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

No version for distro eloquent showing humble. Known supported distros are highlighted in the buttons above.
Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
humble

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
hri

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

No version for distro dashing showing humble. Known supported distros are highlighted in the buttons above.
Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
humble

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
hri

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
galactic

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

No version for distro foxy showing humble. Known supported distros are highlighted in the buttons above.
Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
humble

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
hri

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
iron

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

No version for distro lunar showing humble. Known supported distros are highlighted in the buttons above.
Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
humble

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
hri

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

No version for distro jade showing humble. Known supported distros are highlighted in the buttons above.
Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
humble

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
hri

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

No version for distro indigo showing humble. Known supported distros are highlighted in the buttons above.
Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
humble

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
hri

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

No version for distro hydro showing humble. Known supported distros are highlighted in the buttons above.
Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
humble

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
hri

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

No version for distro kinetic showing humble. Known supported distros are highlighted in the buttons above.
Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
humble

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
hri

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

No version for distro melodic showing humble. Known supported distros are highlighted in the buttons above.
Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
humble

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
hri

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange

Package symbol

magic_enum package from magic_enum repo

magic_enum

ROS Distro
noetic

Package Summary

Tags No category tags.
Version 0.9.7
License MIT
Build type CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/Neargye/magic_enum.git
VCS Type git
VCS Version master
Last Updated 2025-06-11
Dev Status MAINTAINED
CI status Continuous Integration : 0 / 0
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

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

Additional Links

No additional links.

Maintainers

  • Neargye

Authors

No additional authors.

Github releases Conan package Vcpkg package Build2 package Meson wrap License Compiler explorer OpenSSF Scorecard Stand With Ukraine

Magic Enum C++

Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.

If you like this project, please consider donating to one of the funds that help victims of the war in Ukraine: https://u24.gov.ua.

Documentation

Features & Examples

  • Basic
  #include <magic_enum/magic_enum.hpp>
  #include <iostream>

  enum class Color { RED = -10, BLUE = 0, GREEN = 10 };

  int main() {
    Color c1 = Color::RED;
    std::cout << magic_enum::enum_name(c1) << std::endl; // RED
    return 0;
  }
  
  • Enum value to string
  Color color = Color::RED;
  auto color_name = magic_enum::enum_name(color);
  // color_name -> "RED"
  
  • String to enum value
  std::string color_name{"GREEN"};
  auto color = magic_enum::enum_cast<Color>(color_name);
  if (color.has_value()) {
    // color.value() -> Color::GREEN
  }

  // case insensitive enum_cast
  auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);

  // enum_cast with BinaryPredicate
  auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }

  // enum_cast with default
  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Integer to enum value
  int color_integer = 2;
  auto color = magic_enum::enum_cast<Color>(color_integer);
  if (color.has_value()) {
    // color.value() -> Color::BLUE
  }

  auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
  
  • Indexed access to enum value
  std::size_t i = 0;
  Color color = magic_enum::enum_value<Color>(i);
  // color -> Color::RED
  
  • Enum value sequence
  constexpr auto colors = magic_enum::enum_values<Color>();
  // colors -> {Color::RED, Color::BLUE, Color::GREEN}
  // colors[0] -> Color::RED
  
  • Number of enum elements
  constexpr std::size_t color_count = magic_enum::enum_count<Color>();
  // color_count -> 3
  

File truncated at 100 lines see the full file

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

No dependencies on ROS packages.

System Dependencies

Name
cmake

Dependant Packages

Name Deps
movie_publisher

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged magic_enum at Robotics Stack Exchange