-
Notifications
You must be signed in to change notification settings - Fork 426
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
support gcc8 with defined MAGIC_ENUM_NO_CHECK_SUPPORT and with specialized magic_enum::customize::enum_name #137
Conversation
…gic_enum::customize::enum_name
In general, I like the changes, I will look at them a little more before the merge. |
Corrected the style and made the same check for n<E, V>(). Can you check if these changes are ok for you? and I think this PR is ready |
These changes are ok! Thanks :) |
Thanks! |
@schaumb I really like the Magic Enum library, but unfortunately I only have a gcc8 compiler available for my project. |
Hi @JuliaGut If you want to use it, you need to specify all member's names individually. enum class EN {
asd,
fgh
};
namespace magic_enum::customize {
template<>
constexpr customize_t enum_name<EN>(EN e) {
switch(e) {
case EN::asd: return "asd";
case EN::fgh: return "fgh";
}
return invalid_tag;
}
} |
Thanks a lot for the quick response! 🥇 |
I tried to run examples and tests with gcc8, with manually specialized
magic_enum::customize::enum_name
.I know that GCC8 is not supported, but these changes help us to make compatible our code with older GCC too only with the custom template function.
I replaced
#if defined(MAGIC_ENUM_SUPPORTED) && MAGIC_ENUM_SUPPORTED
macros to
if constexpr (supported<E>::value) {
at class name getter
n()
, andoperator<<
These functions work with custom
magic_enum::customize::enum_name
, so it is enough to checksupported
flag.I replaced
detail::min_v<E>
template parameterE
, becauseE
can be a reference, andstd::underlying_type
is undefined in some compilers when the template parameter is a reference.I switched
values_v
andentries_v
fromauto
tostd::array
, because GCC8 is not able to deduct the whole type, butstd::array
template parameters. This change should not change the newer compilers (and it is not a big change)