awesome-repositories.com
博客
MCP
awesome-repositories.com

通过 AI 驱动的搜索,发现最优秀的开源仓库。

探索精选搜索开源替代品自托管软件博客网站地图
项目关于排名机制媒体报道MCP 服务器
法律隐私政策服务条款
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
·
Neargye avatar

Neargye/magic_enum

0
View on GitHub↗
6,115 星标·559 分支·C++·MIT·7 次浏览

Magic Enum

Magic Enum is a C++ library that provides compile-time reflection for enumerations, enabling conversion between enum values and their string names, iteration over enum members, and validation of enum values without relying on macros or external code generation. It uses template metaprogramming and constexpr functions to extract enum information directly from the compiler's internal representation, making the entire reflection process static and free of runtime overhead.

The library distinguishes itself through its comprehensive set of compile-time enum utilities, including the ability to count enum elements, iterate over all values, and dispatch runtime enum values to compile-time code paths via switch-like constructs. It also supports bitwise-combined enum flags, allowing flag combinations to be decomposed into individual components and mapped to their string names, as well as enum fusion, which encodes two enum values into a single integer for multi-level switch dispatch.

Beyond its core reflection capabilities, Magic Enum offers string parsing that converts string representations back into enum values with support for case-insensitive matching, integer-to-enum conversion with validity checking, and membership validation to determine whether a given value, integer, or string belongs to an enum's set of valid members. The library is header-only and requires no additional build steps or configuration to use.

Features

  • Enum Reflection - Provides compile-time reflection for C++ enums, converting values to strings and iterating members without macros.
  • Compile-Time Conversions - Converts any C++ enum value to its string name at compile time using template metaprogramming.
  • String-to-Enum Parsers - Parses string representations back into enum values with case-insensitive matching support.
  • Enum-to-String Converters - Converts enum values to their string names at compile time without macros or runtime overhead.
  • Enum Parsers - Parses string representations back into C++ enum values with case-insensitive and custom matching rules.
  • String Serializations - Provides compile-time conversion between enum values and their string names without macros.
  • Integer-to-Enum Converters - Converts integers to enum values with validity checking, returning optional results for invalid inputs.
  • Enum Membership Validators - Validates integer-to-enum conversions using constexpr lookup, returning optional values for invalid inputs.
  • Enum Switch Dispatchers - Ships a compile-time switch dispatch mechanism for mapping enum values to constexpr code paths.
  • Template Specializations - Generates unique template specializations per enum type for type-safe string conversion and iteration.
  • Compile-Time Enum Counters - Counts distinct enum values at compile time without macros or runtime overhead.
  • Compile-Time Enum Iterators - Iterates over all enum values at compile time for code generation and static analysis.
  • Compile-Time Enum Switches - Dispatches runtime enum values to compile-time code paths via constexpr lambdas.
  • Enum Index Retrievers - Returns the zero-based index of an enum value within its compile-time sequence.
  • Multi-Enum Dispatchers - Implements enum fusion to encode two enum values into a single integer for multi-level switch dispatch.
  • Bitwise Flag Definitions - Supports bitwise-combined enum flags by decomposing integers into individual flag components and mapping them to names.
  • String Conversions - Handles bitwise-combined enum flags by converting flag combinations to string names and parsing them back.
  • Enum Value Sequences - Generates compile-time sequences of enum values for iteration and counting without runtime overhead.

Star 历史

neargye/magic_enum 的 Star 历史图表neargye/magic_enum 的 Star 历史图表

AI 搜索

探索更多 awesome 仓库

用简单的语言描述您的需求 —— AI 将根据相关性为您从数千个精选开源项目中进行排序。

Start searching with AI

Magic Enum 的开源替代方案

相似的开源项目,按与 Magic Enum 的功能重合度排序。
  • vandadnp/flutter-tips-and-tricksvandadnp 的头像

    vandadnp/flutter-tips-and-tricks

    6,822在 GitHub 上查看↗

    This repository is a collection of practical code snippets and implementation patterns for Flutter and Dart. It serves as a comprehensive guide and reference for asynchronous programming, state management patterns, and UI component design. The project provides advanced language reference material covering generics, reflection, factory constructors, and null-aware operators. It also includes specific utilities for manipulating Dart collections, such as helper methods for transforming and filtering maps, lists, and iterables. The coverage extends to high-level capabilities including asynchrono

    Dartdartflutterflutter-ui
    在 GitHub 上查看↗6,822
  • c3lang/c3cc3lang 的头像

    c3lang/c3c

    5,147在 GitHub 上查看↗

    c3c is the compiler for the C3 programming language, transforming source code into executable binaries, static libraries, or dynamic libraries using an LLVM backend. It implements a system based on result-based error handling, scoped memory pooling, and a semantic macro system. The compiler provides first-class support for hardware-backed SIMD vectors that map directly to processor instructions and enables runtime polymorphism through interface-based dynamic dispatch. The project covers a broad set of low-level capabilities, including manual and pooled memory management, inline assembly inte

    C3c3compilerlanguage
    在 GitHub 上查看↗5,147
  • riok/mapperlyriok 的头像

    riok/mapperly

    4,100在 GitHub 上查看↗

    Mapperly is a C# source generator used for high-performance object-to-object mapping in .NET. It functions as a compile-time mapping library that produces the necessary transformation code during the build process, eliminating the need for runtime reflection when converting between domain models and data transfer objects. The tool distinguishes itself by providing type-safe diagnostic validation and strict mapping enforcement, emitting warnings for unmapped properties at compile time. It includes specialized capabilities for circular reference handling and deep cloning to maintain object iden

    C#
    在 GitHub 上查看↗4,100
  • federico-busato/modern-cpp-programmingfederico-busato 的头像

    federico-busato/Modern-CPP-Programming

    15,808在 GitHub 上查看↗

    This project is a comprehensive educational resource and programming course covering C++ language semantics and features from C++03 through C++26. It provides structured tutorials and technical guides focused on modern C++ development. The material offers specialized instruction on template metaprogramming, including the use of type traits and compile-time computations. It features detailed guides on concurrency and parallelism for multi-core execution, as well as a reference for software design applying SOLID principles and RAII. Additionally, it covers build performance optimization to redu

    HTMLc-plus-pluscode-qualitycompilers
    在 GitHub 上查看↗15,808
查看 Magic Enum 的所有 12 个替代方案→

常见问题解答

neargye/magic_enum 是做什么的?

Magic Enum is a C++ library that provides compile-time reflection for enumerations, enabling conversion between enum values and their string names, iteration over enum members, and validation of enum values without relying on macros or external code generation. It uses template metaprogramming and constexpr functions to extract enum information directly from the compiler's internal representation, making the entire reflection process static and free of runtime overhead.

neargye/magic_enum 的主要功能有哪些?

neargye/magic_enum 的主要功能包括:Enum Reflection, Compile-Time Conversions, String-to-Enum Parsers, Enum-to-String Converters, Enum Parsers, String Serializations, Integer-to-Enum Converters, Enum Membership Validators。

neargye/magic_enum 有哪些开源替代品?

neargye/magic_enum 的开源替代品包括: c3lang/c3c — c3c is the compiler for the C3 programming language, transforming source code into executable binaries, static… vandadnp/flutter-tips-and-tricks — This repository is a collection of practical code snippets and implementation patterns for Flutter and Dart. It serves… federico-busato/modern-cpp-programming — This project is a comprehensive educational resource and programming course covering C++ language semantics and… riok/mapperly — Mapperly is a C# source generator used for high-performance object-to-object mapping in .NET. It functions as a… bufbuild/protoc-gen-validate — This project is a protocol buffer validation plugin and code generator that creates consistent validation logic across… duke-git/lancet — Lancet is a comprehensive extension of the Go standard library, providing a collection of reusable functions and data…