-
Notifications
You must be signed in to change notification settings - Fork 454
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
enum_flags limitation? #314
Comments
Hi,
enum_flags_* сhecks all Example enum class TestEnum {
A = 0,
B = 1,
C = 2,
D = 3,
E = 8192
};
enum_count<TestEnum>() = 4;
// '' - mean enmpty string
enum_name(TestEnum::A) = 'A'; vs enum_flags_name(TestEnum::A) = '';
enum_name(TestEnum::B) = 'B'; vs enum_flags_name(TestEnum::B) = 'B';
enum_name(TestEnum::C) = 'C'; vs enum_flags_name(TestEnum::C) = 'C';
enum_name(TestEnum::D) = 'D'; vs enum_flags_name(TestEnum::D) = 'B|C';
enum_name(TestEnum::E) = ''; vs enum_flags_name(TestEnum::E) = 'E';
enum_flags_cast('A') = nullopt; vs enum_cast('A') = TestEnum::A;
enum_flags_cast('D') = nullopt; vs enum_flags_cast('B|C') = TestEnum::D; vs enum_cast('D') = TestEnum::D;
|
I'll add a documentation update later. |
Hi @Neargye, about the zero not being included in the flags for me that's really not an issue. I mostly use magic_enum to generate UI to edit flags and the none/all cases are handled by my ImGui control anyway so I never put the 0 value in my enum flags. This is also how engines like e.g. Unity deal with C# enum flags so I got used to have MyEnum val = (MyEnum)0 instead of having a MyEnum::None entry in the enum flags. |
Hi, I did not know about the magic_enum::enum_flags funcs until recently but the limitations are unclear to me.
e.g. I use
and I have this enum
magic_enum::enum_name returns empty string for anything above 256 as expected but magic_enum::enum_flags_name(1026) works and returns "B|K".
Does the MAGIC_ENUM_RANGE_MAX apply to enum flags and how? Is it the maximum amount of flags avaible? Thanks
The text was updated successfully, but these errors were encountered: