Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just a suggestion, maybe include magic_enum.h? #4

Open
WarlockD opened this issue Feb 5, 2022 · 0 comments
Open

Just a suggestion, maybe include magic_enum.h? #4

WarlockD opened this issue Feb 5, 2022 · 0 comments

Comments

@WarlockD
Copy link

WarlockD commented Feb 5, 2022

Wrote a simple do_repr

template<typename T>
concept onlyScopedEnums = std::is_scoped_enum_v<T>;

template<onlyScopedEnums E>
inline void do_repr(auto out, const E* self) noexcept {
    static constexpr auto type_name = magic_enum::enum_type_name<E>();
    out.type(type_name);
    if (self) {
        auto enum_value = magic_enum::enum_name(*self);
        out.value(enum_value);
    }
}

Haven't had any problems with it. I would suggest just building it into repr but it uses some hacks with with PRETTY_FUNCTION/FUNCSIG and a constexpr table to look up strings so not sure if its in scope of this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant