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

Overview
 __  __             _        ______                          _____
|  \/  |           (_)      |  ____|                        / ____|_     _
| \  / | __ _  __ _ _  ___  | |__   _ __  _   _ _ __ ___   | |   _| |_ _| |_
| |\/| |/ _` |/ _` | |/ __| |  __| | '_ \| | | | '_ ` _ \  | |  |_   _|_   _|
| |  | | (_| | (_| | | (__  | |____| | | | |_| | | | | | | | |____|_|   |_|
|_|  |_|\__,_|\__, |_|\___| |______|_| |_|\__,_|_| |_| |_|  \_____|
               __/ |
              |___/

Github releases Conan package Vcpkg package License Build status Build status Codacy badge Try online Compiler explorer

Magic Enum C++

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

  • enum_cast obtains enum value from string or integer.
  • enum_value returns enum value at specified index.
  • enum_values obtains enum value sequence.
  • enum_count returns number of enum values.
  • enum_integer obtains integer value from enum value.
  • enum_name returns name from enum value.
  • enum_names obtains string enum name sequence.
  • enum_entries obtains pair (value enum, string enum name) sequence.
  • enum_index obtains index in enum value sequence from enum value.
  • enum_contains checks whether enum contains enumerator with such value.
  • enum_type_name returns name of enum type.
  • is_unscoped_enum checks whether type is an Unscoped enumeration.
  • is_scoped_enum checks whether type is an Scoped enumeration.
  • underlying_type improved UB-free "SFINAE-friendly" underlying_type.
  • ostream_operators ostream operators for enums.
  • bitwise_operators bitwise operators for enums.

Documentation

Features

  • C++17
  • Header-only
  • Dependency-free
  • Compile-time
  • Enum to string
  • String to enum
  • Iterating over enum

Examples

// For example color enum.
enum class Color { RED = 2, BLUE = 4, GREEN = 8 };
  • 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
    }
  • Integer to enum value

    int color_integer = 2;
    auto color = magic_enum::enum_cast<Color>(color_integer);
    if (color.has_value()) {
      // color.value() -> Color::RED
    }
  • Indexed access to enum value

    std::size_t i = 1;
    Color color = magic_enum::enum_value<Color>(i);
    // color -> Color::BLUE
  • 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
  • Enum value to integer

    Color color = Color::RED;
    auto color_integer = magic_enum::enum_integer(color);
    // color -> 2
  • Enum names sequence

    constexpr auto& color_names = magic_enum::enum_names<Color>();
    // color_names -> {"RED", "BLUE", "GREEN"}
    // color_names[0] -> "RED"
  • Enum entries sequence

    constexpr auto& color_entries = magic_enum::enum_entries<Color>();
    // color_entries -> {{Color::RED, "RED"}, {Color::BLUE, "BLUE"}, {Color::GREEN, "GREEN"}}
    // color_entries[0].first -> Color::RED
    // color_entries[0].second -> "RED"
  • Ostream operator for enum

    using namespace magic_enum::ostream_operators; // out-of-the-box ostream operators for enums.
    Color color = Color::BLUE;
    std::cout << color << std::endl; // "BLUE"
  • Bitwise operator for enum

    enum class Flags { A = 1 << 0, B = 1 << 1, C = 1 << 2, D = 1 << 3 };
    using namespace magic_enum::bitwise_operators; // out-of-the-box bitwise operators for enums.
    // Support operators: ~, |, &, ^, |=, &=, ^=.
    Flags flags = Flags::A | Flags::B & ~Flags::C;
  • Checks whether type is an Unscoped enumeration.

    enum color { red, green, blue };
    enum class direction { left, right };
    
    magic_enum::is_unscoped_enum<color>::value -> true
    magic_enum::is_unscoped_enum<direction>::value -> false
    magic_enum::is_unscoped_enum<int>::value -> false
    
    // Helper variable template.
    magic_enum::is_unscoped_enum_v<color> -> true
  • Checks whether type is an Scoped enumeration.

    enum color { red, green, blue };
    enum class direction { left, right };
    
    magic_enum::is_scoped_enum<color>::value -> false
    magic_enum::is_scoped_enum<direction>::value -> true
    magic_enum::is_scoped_enum<int>::value -> false
    
    // Helper variable template.
    magic_enum::is_scoped_enum_v<direction> -> true
  • Static storage enum variable to string This version is much lighter on the compile times and is not restricted to the enum_range limitation.

    constexpr Color color = Color::BLUE;
    constexpr auto color_name = magic_enum::enum_name<color>();
    // color_name -> "BLUE"

Remarks

  • magic_enum does not pretend to be a silver bullet for reflection for enums, it was originally designed for small enum.

  • Before use, read the limitations of functionality.

  • For the small enum use the API from the namespace magic_enum, and for enum-flags use the API from the namespace magic_enum::flags.

Integration

  • You should add the required file magic_enum.hpp.

  • If you are using vcpkg on your project for external dependencies, then you can use the magic-enum package.

  • If you are using Conan to manage your dependencies, merely add magic_enum/x.y.z to your conan's requires, where x.y.z is the release version you want to use.

  • Alternatively, you can use something like CPM which is based on CMake's Fetch_Content module.

    CPMAddPackage(
        NAME magic_enum
        GITHUB_REPOSITORY Neargye/magic_enum
        GIT_TAG x.y.z # Where `x.y.z` is the release version you want to use.
    )
  • Bazel is also supported, simply add to your WORKSPACE file:

    http_archive(
        name = "magic_enum",
        strip_prefix = "magic_enum-<commit>",
        urls = ["https://github.com/Neargye/magic_enum/archive/<commit>.zip"],
    )
    

    To use bazel inside the repository it's possible to do:

    bazel build //...
    bazel test //...
    bazel run //:example
    

    (Note that you must use a supported compiler or specify it with export CC= <compiler>.)

Compiler compatibility

  • Clang/LLVM >= 5
  • MSVC++ >= 14.11 / Visual Studio >= 2017
  • Xcode >= 10
  • GCC >= 9
  • MinGW >= 9

Licensed under the MIT License

Issues
  • Compiler croaks if max/min interval is too wide

    Compiler croaks if max/min interval is too wide

    I am encountering problems if the max/min interval is too wide. The interval limit appears to be different on different compilers, but for example INT16_MIN+1 to INT16MAX-1 is too wide on either of the compilers I have tried. It always fails starting at line 448:

      constexpr bool valid[sizeof...(I)] = {is_valid<E, value<E, Min, IsFlags>(I)>()...};
      constexpr std::size_t count = values_count(valid);
    
      if constexpr (count > 0) {
        E values[count] = {};
        for (std::size_t i = 0, v = 0; v < count; ++i) {
          if (valid[i]) {
            values[v++] = value<E, Min, IsFlags>(i);
          }
        }
    

    I realize that a wide interval may quite inefficient for a compiler. It might be useful to put a warning in the Limitations section of the docs and suggest what a reasonable limit might be.

    question 
    opened by rpatters1 18
  • Proposed enhancement to enum_name

    Proposed enhancement to enum_name

    EDIT: Thinking a bit harder, it might be better that this functionality be moved to a new method, perhaps called enum_name_of_bits_set or something and leave enum_name alone...

    Hi, I have no clue about github or pull requests, so I thought I'd write my proposed enhancement to enum_name here...

    If an enum contains bitfield values, there exists already the ability to bitwise AND and OR the values together to create flag fields. But there is no way to print such a flag.

    Example :

    using namespace magic_enum;
    using namespace magic_enum::bitwise_operators;
    
    enum Rooms { None = 0, Bedroom = 1 << 0, Lounge = 1 << 1, Kitchen = 1 << 2 };
    Rooms toPaint = Rooms::Bedroom | Rooms::Kitchen;
    
    std::cout << "My wife want me to paint these : " << enum_name<Rooms>(toPaint) << '\n';
    

    Desired output : My wife want me to paint these : Bedroom|Kitchen

    Actual output : My wife want me to paint these :

    Here is a replacement

        // Returns string enum name from enum value.
        // If enum value does not have name or value out of range, returns empty string.
        template <typename E>
        [[nodiscard]] constexpr auto enum_name(E value) noexcept 
        -> detail::enable_if_enum_t<E, std::string_view>
        {
            //  Begin Changes ga2k 2020-05-29
    
            //  return enum_traits<E>::name(value);
    
            auto n = enum_traits<E>::name(value);
            if (!n.empty())
                return n;
    
            //  See if there is a name for each bit set in value. 
            //  If so, concatenate them with '|' separator
    
            //  First find largest value
    
            constexpr auto values = enum_values<E>();
            constexpr auto largest = values[values.size() - 1];
            static std::string s;
    
            for (int b = 0; (1 << b) <= largest; ++b)
            {
                if ((value & (1 << b)) == (1 << b))	// This bit is set in value
                {
                    auto n2 = enum_traits<E>::name(static_cast<E>(1 << b));
    
                    if (n2.empty())
                        return n2;	// No name at this bt value : not a bitfield value, so bail
    
                    if (!s.empty())
                    {
                        s += '|';
                    }
    
                    s += n2;
                }
            }
    
            return static_cast<std::string_view>(s);
                
            // End Additions ga2k 2020-05-29
        }
    

    Thoughts?

    enhancement help wanted 
    opened by ga2k 18
  • Intellisense hangs forever when using magic_enum since 0.6.1 on x86 projects

    Intellisense hangs forever when using magic_enum since 0.6.1 on x86 projects

    Ctrl+clicking on anything in my project stalls waiting for intellisense to complete if I include magic_enum 0.6.1 or newer. Version 0.6.0 doesn't have this problem.

    Edit: Only happens on 32bit projects.

    Tested in Visual Studio 2019 and Visual Studio 2017.

    invalid 
    opened by albertvaka 14
  • O(1) conversion to location of enum in enum_values

    O(1) conversion to location of enum in enum_values

    Is there a way to do O(1) conversion of Color::BLUE to 1 (rather than 4, as enum_integer would do)?

    Motivation: I have an enum generated by an external tool which may have gaps in it, and I need to pack the enums into a contiguous sequence of integers starting at 0 (so that I can more efficiently store it in memory somewhere else). I don't need this packing to be stable across invocations of the program, but it should be stable within the program.

    enhancement 
    opened by ezyang 14
  • Compilation error using clang

    Compilation error using clang

    Hi I recently switched my project from using gcc to clang, and ran into this error:

    _deps/magic_enum_content-src/include/magic_enum.hpp:116:18: error: constexpr variable 'prefix' must be initialized by a constant expression
      constexpr auto prefix = name.find_last_of(" :,-)") + 1;
                     ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

    Clang version:

    clang version 8.0.0 (Fedora 8.0.0-1.fc30)
    Target: x86_64-unknown-linux-gnu
    

    Gcc version:

    g++ (GCC) 9.1.1 20190503 (Red Hat 9.1.1-1)
    

    Flag list:

                              -Wall
                              -Wextra
                              -Werror
                              -Wnon-virtual-dtor
                              -Wold-style-cast
                              -Woverloaded-virtual
                              -Wsign-conversion
                              -Wconversion
                              -Wnull-dereference
                              -Wformat=2
                              -Wdouble-promotion
                              -fasynchronous-unwind-tables
                              -fstack-protector
                              -fstack-protector-strong
                              -fPIC
                              -pipe
                              -fsanitize=address
                              -fsanitize=undefined
                              -g
                              -fdiagnostics-color=always
                              -fno-omit-frame-pointer
    

    Thank you for your work in this library, please let me know if I can provide more info.

    bug help wanted 
    opened by khoitd1997 14
  • magic enum static_asserts on an enum value of 129

    magic enum static_asserts on an enum value of 129

    I ran into this with 0.7.2, then upgraded to 0.7.3. Both have this issue. I use git and tags, so this was with tag "v0.7.3".

    Consider the following snippet:

    #include <magic_enum.hpp>
    
    enum Errors {
      SE_EKEYREJECTED = 129,
    };
    
    std::string to_string(Errors error)
    {
      auto sv = magic_enum::enum_name(error);
      return std::string{sv};
    }
    
    int main()
    {
    }
    

    When compiling, you get:

    include/magic_enum.hpp:407:21: error: static assertion failed: magic_enum::enum_range detects enum value larger than max range size.
      407 |       static_assert(!is_valid<E, value<E, lhs + 1, IsFlags>(0)>(), "magic_enum::enum_range detects enum value larger than max range size.");
    include/magic_enum.hpp:407:21: note: ‘! magic_enum::detail::is_valid<Errors, SE_EKEYREJECTED>()’ evaluates to false
    

    Using a value of 128 or 130 compiles fine. Having other enums in there does not make a difference.

    question 
    opened by CarloWood 11
  • Question about flag-based api

    Question about flag-based api

    I am trying to reduce compile-time requirements of memory and time for my project. I have some power-of-2-based enums that span a pretty wide interval. I was hoping that using the flags api would use much fewer resources, but I can't see any difference in behavior. I still have to set /constexpr:depth and /constexpr:steps quite high before it will compile in Visual Studio 2022.

    Here is an outline of my code:

    enum A {A1 = 8192, A2=32};
    
    // static_assert in magic_enum.hpp fires if this isn't here
    namespace magic_enum::customize {
       template <>
       struct enum_range<A> {
          static constexpr int min = 32;
          static constexpr int max = 8192;
       };
    } // namespace magic_enum
    
    // this function exists solely to return a value equal to the enumerated type value
    template<int I>
    static int __magic_enum_return_i() { return I; }
    
    template<typename ENUM>
    void AddEnumeratedTypeFlags()
    {
       constexpr std::size_t count = magic_enum::flags::enum_count<ENUM>();
       constexpr auto names = magic_enum::flags::enum_names<ENUM>();
    
       constexpr_for<0, count, 1>([&](auto i)
       {
          //run-time function that processes each enum value
          Process(names[i].data(), &__magic_enum_return_i<magic_enum::flags::enum_value<ENUM, i>()>);
       });
    }
    
    void MyCode()
    {
       AddEnumeratedTypeFlags<A>();
    }
    

    I'm wondering if there is something further I need to do to get the benefit of the flags api.

    bug question 
    opened by rpatters1 10
  • Compile errors on Clang 8.0.1

    Compile errors on Clang 8.0.1

    Hi there. I am trying to compile for PS4, using Clang 8.0.1:

    -- The CXX compiler identification is Clang 8.0.1
    -- The C compiler identification is Clang 8.0.1
    

    However, I run into these errors:

    [...]\magic_enum.hpp(458,23): error : constexpr variable 'values_v<ColorType, false>' must be initialized by a constant expression
    [...]\magic_enum.hpp(467,23): error : constexpr variable 'min_v<ColorType, false, std::underlying_type<ColorType>::type>' must be initialized by a constant expression
    [...]\magic_enum.hpp(470,23): error : constexpr variable 'max_v<ColorType, false, std::underlying_type<ColorType>::type>' must be initialized by a constant expression
    [...]\magic_enum.hpp(475,18): error : constexpr variable 'max' must be initialized by a constant expression
    [...]\magic_enum.hpp(476,18): error : constexpr variable 'min' must be initialized by a constant expression
    [...]\magic_enum.hpp(477,18): error : constexpr variable 'range_size' must be initialized by a constant expression
    [...]\magic_enum.hpp(478,17): error : static_assert expression is not an integral constant expression
    

    Any help with this would be appreciated. Thank you!

    help wanted invalid 
    opened by colinbasnettskyboxlabs 10
  • Better syntax for custom enum names

    Better syntax for custom enum names

    Following up #47.

    I'm not really happy with the current syntax for defining custom enum names, specially because you need to deal with functions defined in the namespace detail which does not seem right. Furthermore, a function named n is not a very intuitive name for people using the library.

    Threrefore, I have 2 suggestions on how to improve it:

    1. Add a function template <auto V> std::string_view magic_enum::custom_name() to the API:
    template <auto V>
    constexpr std::string_view magic_enum::custom_name() noexcept { return ""; }
    ...
    // a small change in `n()`
    template <typename E, E V>
    std::string_view magic_enum::n() { 
      if constexpr (auto s = custom_name<V>(); !s.empty())
        return s;
      else {
        ... // current `n()` implementation
      }
    }
    ...
    // example of usage
    template <>
    constexpr std::string_view magic_enum::custom_name<Color::red> noexcept { return "the red color"; }
    

    Pros:

    • Removed redundant template parameter typename E.
    • Specialization defined using a function defined in magic_enum, not in magic_enum::detail
    • Intuitive function name custom_name instead of n.

    Cons:

    • The if constexpr in n() is a bit ugly...
    • Very verbose if you compare with option 2.
    1. Use a macro (as suggested by @Neargye in #47):
    #define MAGIC_ENUM_CUSTOM_NAME(VALUE, TEXT) \
    template <> constexpr auto magic_enum::detail::n<decltype(VALUE), VALUE>() noexcept { return std::string_view{TEXT}; }
    ...
    // example of usage
    MAGIC_ENUM_CUSTOM_NAME(Color::red, "the red color")
    

    Pros:

    • Simpler syntax.

    Cons:

    • Its a macro... ¯\(ツ)
    • It might not be clear that you cannot declare it inside a class/namespace.

    Let me know what you think.

    enhancement 
    opened by mhbackes 10
  • Aliased enums behaving oddly

    Aliased enums behaving oddly

    From the limitations, I see that aliases don't work, this would be fine, but I seem to be getting an odd case where the first-use of a value, is NOT the one used, furthermore, I'm getting 0x0 for a string, instead of the alias. (Either in my case would be fine, but not an empty string)

    THEN, debugging in vs17, when I look at the strings table (which I guess is all the names baked into an array) my values START at 128 instead of 0 this is the enum https://github.com/SoylentGraham/SoyLib/blob/master/src/SoyPixels.h#L22 enum strings

    I've been using this library for a while now without problems, even with this enum, so perhaps I've just missed this case, or in this particular code I'm using it in a strange way... (still investigating :)

    invalid 
    opened by SoylentGraham 10
  • static assertion failed with gcc 9.2.1

    static assertion failed with gcc 9.2.1

    Hello,

    We have been trying to use magic_enum::enum_count. It works well with Visual Studio 2017 but does not compile with gcc 9.2.1. Here is the code:

    enum class MyEnum : std::size_t
    {
        Value0,
        Value1,
        Value2
    };
    constexpr std::size_t countEnum = magic_enum::enum_count<MyEnum>();
    

    And with gcc 9.2.1 we have the following issue:

    MagicEnum.h:442:26: error: static assertion failed: magic_enum::enum_range requires enum implementation and valid max and min. static_assert( count > 0, "magic_enum::enum_range requires enum implementation and valid max and min." );

    We have the latest version of MagicEnum as of today. We have looked at the limitations, we don't seem to be in one of those situations. Did we miss anything? It looks like it is supposed to work from gcc 9 and upward.

    Thank you so much for your work and very nice contribution. Magic enum seems pretty cool.

    Cheers,

    Olivier

    help wanted invalid 
    opened by morph208 10
  • Support wide char

    Support wide char

    Is it possible to support wide char ?

    #define MAGIC_ENUM_USING_ALIAS_STRING_VIEW using string_view = std::wstring_view; #define MAGIC_ENUM_USING_ALIAS_STRING using string = std::wstring; #include "magic_enum.hpp"

    wstring_view name = magic_enum::enum_name(Color::Red);

    opened by noujaimc 1
  • declaration of 'last' hides global declaration

    declaration of 'last' hides global declaration

    I found the following warning in my windows build. Looks like it has not been addressed. I renamed the inner variable last something else to work around the issue. Note that the vcpkg port also has this issue and vcpkg is not using the latest magic_enum port.

    link to vcpkg issue

    9>C:\Users\johnc\main\tcdu\include\702\C702Words.h(450): message : see reference to function template instantiation 'std::optional<WordID> magic_enum::enum_cast<WordID>(unsigned int) noexcept' being compiled (compiling source file ..\..\src\702\C702Protocol.cpp)
    9>C:\tools\vcpkg\installed\x64-windows\include\magic_enum.hpp(763,44): error C2220: the following warning is treated as an error (compiling source file ..\..\src\702\C702SubSystem.cpp)
    9>C:\tools\vcpkg\installed\x64-windows\include\magic_enum.hpp(763,44): warning C4459: declaration of 'last' hides global declaration (compiling source file ..\..\src\702\C702SubSystem.cpp)
    9>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\chrono(812,32): message : see declaration of 'std::chrono::last' (compiling source file ..\..\src\702\C702SubSystem.cpp)
    
    
    opened by johnco3 7
  • magic_enum/example/CMakeLists.txt

    magic_enum/example/CMakeLists.txt

    manual set(MAGIC_ENUM_OPT_BUILD_EXAMPLES ON)

    target_link_libraries(${target} PRIVATE ${CMAKE_PROJECT_NAME})

    target_link_libraries(${target} PRIVATE ${PROJECT_NAME}) ?

    opened by lglgdouble 2
  • Feature request: `enum_name<Color>`

    Feature request: `enum_name`

    Would it make sense to have a shorthand for enum_name which can cast?

    Such that this:

    enum class Color { RED = 2, BLUE = 4, GREEN = 8 };
    auto color_name = magic_enum::enum_name(magic_enum::enum_cast<Color>(2).value());
    

    Or more accurately this:

    enum class Color { RED = 2, BLUE = 4, GREEN = 8 };
    auto color_name = magic_enum::enum_cast<Color>(2).has_value() ? magic_enum::enum_name(magic_enum::enum_cast<Color>(2).value() : "";
    

    can become this:

    enum class Color { RED = 2, BLUE = 4, GREEN = 8 };
    auto color_name = magic_enum::enum_name<Color>(2);
    
    opened by Timple 3
Releases(v0.8.0)
  • v0.8.0(May 10, 2022)

    Release v0.8.0

    • [breaking changes] New enum-flags API. Added is_flags option in enum_range.

    • [breaking changes] New customize. (#166)

    • Add enum_fuse - fusing function in separate header.

    • Add support for non-ASCII characters (UNIX/Linux) (#95)

    • Add enum_switch and enum_for_each.

    • Add istream operators.

    • Add compile-time enum_index and enum_value.

    • Add support gcc8 with defined MAGIC_ENUM_NO_CHECK_SUPPORT. (#137)

    • Many small fixes underflow in out of range check, bool enum, etc.

    Source code(tar.gz)
    Source code(zip)
    magic_enum.hpp(55.05 KB)
    magic_enum_fuse.hpp(3.65 KB)
  • v0.7.3(Jun 21, 2021)

    Release v0.7.3

    • Add detect values out of range and fail compilation (#70)
    • Add ability to include external configuration header (#86)
    • Fix std::array in some cases is missing constexpr on some of it's functions (#76)
    • Fix using leak (#80)
    • Fix hard error if enum is empty or non-reflected (#79)
    • Fix some warning
    Source code(tar.gz)
    Source code(zip)
    magic_enum.hpp(41.35 KB)
  • v0.7.2(Dec 23, 2020)

  • v0.7.1(Dec 2, 2020)

  • v0.7.0(Oct 14, 2020)

    Release v0.7.0

    • Add namespace flags with API for enum-flags https://github.com/Neargye/magic_enum/issues/40
    • Add syntax for defining custom enum names https://github.com/Neargye/magic_enum/issues/50
    • Add way to switch std::optional, std::string and std::string_view to custom type https://github.com/Neargye/magic_enum/issues/45
    • Add support for bazel https://github.com/Neargye/magic_enum/pull/56
    • Add MAGIC_ENUM_OPT_INSTALL option in CMakeLists.txt https://github.com/Neargye/magic_enum/pull/54
    • Add macro MAGIC_ENUM_SUPPORTED_ALIASES to check whether enum-aliases supported https://github.com/Neargye/magic_enum/issues/36
    • Improve API usability https://github.com/Neargye/magic_enum/issues/55
    • Fix build error in clang https://github.com/Neargye/magic_enum/issues/53
    • [breaking changes] enum_range moved to namespace magic_enum::customize https://github.com/Neargye/magic_enum/pull/52
    Source code(tar.gz)
    Source code(zip)
    magic_enum.hpp(40.17 KB)
  • v0.6.6(Jun 5, 2020)

    Release v0.6.5

    • Fix compiler check https://github.com/Neargye/magic_enum/issues/39
    • Fix hangs Intellisense https://github.com/Neargye/magic_enum/issues/34
    • Fix compatibility with legacy C-Style APIs https://github.com/Neargye/magic_enum/issues/37
    • Add comparison predicate for enum_cast https://github.com/Neargye/magic_enum/issues/35
    • Add enum_contains https://github.com/Neargye/magic_enum/pull/30
    • Add enum_type_name https://github.com/Neargye/magic_enum/issues/25
    Source code(tar.gz)
    Source code(zip)
    magic_enum.hpp(27.10 KB)
  • v0.6.5(Jan 31, 2020)

  • v0.6.4(Dec 30, 2019)

  • v0.6.3(Oct 18, 2019)

  • v0.6.2(Oct 8, 2019)

    Release v0.6.2

    • Fix cvref regression, fix https://github.com/Neargye/magic_enum/pull/16.

    • Add documentation.

    • Improve enum_value for dense enums.

    • Add check if the enum is a forward declaration or valid enum_range::max and enum_range::min, fix #15.

    • Add macro MAGIC_ENUM_SUPPORTED to check compiler support.

    • Caching enum_values, enum_names, enum_entries.

    • Remove is_fixed_enum.

    Source code(tar.gz)
    Source code(zip)
    magic_enum.hpp(23.29 KB)
  • v0.6.1(Sep 29, 2019)

    Release v0.6.1

    • Less bin size and overhead reduction, thanks @rollbear. Fix https://github.com/Neargye/magic_enum/issues/14.

    • Fix type cast for unsigned enum.

    • More SFINAE-friendly.

    • Add enum_index. Fix https://github.com/Neargye/magic_enum/issues/12.

    • Add enum_traits.

    • Add error msg unsupported compiler, use MAGIC_ENUM_NO_CHECK_SUPPORT to suppress supported compiler check.

    Source code(tar.gz)
    Source code(zip)
    magic_enum.hpp(23.30 KB)
  • v0.6.0(Jul 27, 2019)

    Release v0.6.0

    • Fix build fail with sanitize, see https://github.com/Neargye/magic_enum/issues/6

    • Fix Syntax Error caused by "Windows.h", see https://github.com/Neargye/magic_enum/issues/7

    • Fix implicit conversion changes signedness.

    • Improving compile times.

    • Improve ostream operators for enums.

    • Add bitwise operators for enums.

    • Add is_fixed_enum, underlying_type.

    • [breaking changes] change magic_enum::ops to magic_enum::ostream_operators

    Source code(tar.gz)
    Source code(zip)
    magic_enum.hpp(18.91 KB)
Owner
Daniil Goncharov
Daniil Goncharov
std::tuple like methods for user defined types without any macro or boilerplate code

Boost.PFR This is a C++14 library for very basic reflection that gives you access to structure elements by index and provides other std::tuple like me

Boost.org 1k Jun 21, 2022
A C++14 macro to get the type of the current class without naming it

self_macro C++14 header only library that exposes a macro that creates a type alias for the current class without naming it. Also exposes macros that

Mital Ashok 8 Jan 14, 2022
Gesture-Detecting-Macro-Keyboard - Glorified Bluetooth macro keyboard with machine learning (TensorFlow Lite for Microcontrollers) running on an ESP32.

Gesture detection tldr; Glorified Bluetooth macro keyboard with machine learning (TensorFlow Lite for Microcontrollers) running on an ESP32. Main feat

Jakob Krantz 63 Jun 19, 2022
Generate code for pretty-printing C++ enums

enums Generate code for pretty-printing C++ enums. Supported platforms Only Linux x86/x86_64 systems are supported. For the missing platforms, the too

Andrei Burdulescu 0 Jan 31, 2022
Meta - static reflection tools for c++. i mostly use this with entt.

meta Static reflection tools for C++. I use it with EnTT but it can work with anything. The main features the library provides are: Registering types

Nikhilesh S 8 Jan 16, 2022
A modern-day Boss Key software tool. Switch instantly from work to play & play to work with Bosky.

Bosky By: Seanpm2001, Bosky-dev Et; Al. Top README.md Read this article in a different language Sorted by: A-Z Sorting options unavailable ( af Afrika

Sean P. Myrick V19.1.7.2 1 Nov 11, 2021
Tiny header-only library providing bitwise operators for enums in C++11

bitflags Tiny header-only library providing bitwise operators for enums in C++11. Getting started Import the operators from namespace avakar::bitflags

Martin Vejnár 2 Jan 29, 2022
A reflective enum implementation for C++

wise_enum Because reflection makes you wise, not smart wise_enum is a standalone smart enum library for C++11/14/17. It supports all of the standard f

Nir Friedman 258 Jun 27, 2022
Get_next_line is a project that taught me some new concepts like static variables file_desctiptors how they work

Get_next_line is a project that taught me some new concepts like static variables file_desctiptors how they work, how to create them, read and import data from them.

Ahmed El Mountassir 4 Apr 19, 2022
Implementation of python itertools and builtin iteration functions for C++17

CPPItertools Range-based for loop add-ons inspired by the Python builtins and itertools library. Like itertools and the Python3 builtins, this library

Ryan Haining 1.2k Jun 23, 2022
An AI for playing NES Tetris at a high level. Based primarily on search & heuristic, with high quality board evaluation through value iteration.

StackRabbit An AI that plays NES Tetris at a high level. Primarily based on search & heuristic, with high-quality board eval through value iteration.

Greg Cannon 200 Jun 18, 2022
Loads a signed kernel driver which allows you to map any driver to kernel mode without any traces of the signed / mapped driver.

CosMapper Loads a signed kernel driver (signed with leaked cert) which allows you to map any driver to kernel mode without any traces of the signed /

null 107 Jul 2, 2022
Automatically load dlls into any executables without replacing any files!

Automatically loaded dll using xinput9_1_0 proxy. Please put the modified xinput9_1_0.dll in the executable's directory.

null 11 Apr 17, 2022
header-only UTF-8 string functions based on STL-string

utf8_xxx header-only UTF-8 string functions based on STL-string size_t utf8_len(const std::string& _Str) std::string utf8_sub(const std::string& _Str,

Voidmatrix 2 Dec 27, 2021
C Program to input a string and adjust memory allocation according to the length of the string.

C-String C Program to input a string and adjust memory allocation according to the length of the string. With the help of this program, we have replic

Kunal Kumar Sahoo 1 Jan 20, 2022
Apex cheat without R/W. can implement your own R/W and it will work fine

pubApexCheat Apex cheat without R/W. can implement your own R/W and it will work fine. will update readme later Aimbot Prediction and imGui draw funct

null 22 Jun 20, 2022
32blit SDK boilerplate for the PicoSystem RP2040-based handheld

PicoSystem 32blit Boilerplate This is a basic template for starting 32blit projects for the Pimoroni PicoSystem. It shows a minimal code layout and as

32blit 10 Mar 23, 2022