magic_enum/0.9.5

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

Available packages
Header Only

Install
Add the following line to your conanfile.txt:
[requires]
magic_enum/0.9.5

Using magic_enum

Note

If you are a new Conan user, we recommend reading the how to consume packages tutorial.

If you need additional assistance, please ask a question in the Conan Center Index repository.

Simplest use case consuming this recipe and assuming CMake as your local build tool:

[requires]
magic_enum/0.9.5
[generators]
CMakeDeps
CMakeToolchain
[layout]
cmake_layout
from conan import ConanFile
from conan.tools.cmake import cmake_layout


class ExampleRecipe(ConanFile):
    settings = "os", "compiler", "build_type", "arch"
    generators = "CMakeDeps", "CMakeToolchain"

    def requirements(self):
        self.requires("magic_enum/0.9.5")

    def layout(self):
        cmake_layout(self)

Now, you can run this Conan command to locally install (and build if necessary) this recipe and its dependencies (if any):

$ conan install conanfile.txt --build=missing

Useful information to take into account to consume this library:


These are the main declared targets:

  • CMake package name(s): magic_enum
  • CMake target name(s): magic_enum::magic_enum
  • pkg-config file name(s): magic_enum.pc

A simple use case using the CMake file name and the global target:

# ...
find_package(magic_enum REQUIRED)
# ...
target_link_libraries(YOUR_TARGET magic_enum::magic_enum)

These are all the available headers. Some of these ones might be non-public; make sure of it by visiting the magic_enum homepage listed above:

#include "magic_enum/magic_enum.hpp"
#include "magic_enum/magic_enum_all.hpp"
#include "magic_enum/magic_enum_containers.hpp"
#include "magic_enum/magic_enum_flags.hpp"
#include "magic_enum/magic_enum_format.hpp"
#include "magic_enum/magic_enum_fuse.hpp"
#include "magic_enum/magic_enum_iostream.hpp"
#include "magic_enum/magic_enum_switch.hpp"
#include "magic_enum/magic_enum_utility.hpp"