mcpp index

neargye.magic_enum

import

Header-only C++17 library for static reflection of enums, exposed as C++23 module magic_enum

import magic_enum;
mcpp add neargye.magic_enum@0.9.8

Usage

From this repository's own test project — built and run by CI, not written for the website.

// Behavioral test: enum_name, enum_cast, enum_values under `mcpp test`.
import std;
import magic_enum;

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

int main() {
    Color c = Color::RED;
    auto name = magic_enum::enum_name(c);
    bool ok = (name == "RED");

    auto cast = magic_enum::enum_cast<Color>("GREEN");
    ok = ok && cast.has_value() && cast.value() == Color::GREEN;

    auto values = magic_enum::enum_values<Color>();
    ok = ok && values.size() == 3;

    return ok ? 0 : 1;
}

tests/examples/magic_enum/tests/reflection.cpp · project tests/examples/magic_enum

openkal

targetresultenvironmenttest projectfirst diagnostic
aarch64-linux-muslrunsposixmagic_enum
x86_64-linux-gnurunsposixmagic_enum
x86_64-linux-muslrunsposixmagic_enum
x86_64-windows-muslfailsmagic_enumerror: openkal-llvm-runtime is requested as '0.15.2' by magic_enum-tests, and the platform openkal-platform 0.32.1 is a version group

How this was measured

Measured 2026-11-29 by tests/openkal/compat.py with openkal-llvm-runtime 0.15.2, llvm@22.1.8, mcpp 2026.11.23.1. The test project selects no platform dependency of its own. The badge above is a summary of the strictest measured target -- the table above states each target's own environment.

Build

modules
magic_enum
targets
magic_enum (lib)
import std
no
include dirs
include

Sources (1)

  • module/magic_enum.cppm

Versions

VersionPlatforms Mirrorssha256
0.9.8 latest LinuxWindowsmacOS GLOBAL CN 88709dc8a969…