1
0
Fork 0
mirror of https://github.com/Neargye/magic_enum.git synced 2026-01-10 23:44:29 +00:00

move is_flags to customize::enum_range

force set the enum-flag true or false
This commit is contained in:
neargye 2022-01-27 15:34:05 +02:00
parent a8c9e57fbe
commit 9ed19fb9e9
4 changed files with 22 additions and 17 deletions

View file

@ -7,11 +7,13 @@
* Enum can't reflect if the enum is a forward declaration.
* For enum-flags add specialization `is_flags_enum` for necessary enum type. Specialization of `is_flags_enum` must be injected in `namespace magic_enum::customize`.
* For enum-flags add `is_flags` to specialization `enum_range` for necessary enum type. Specialization of `enum_range` must be injected in `namespace magic_enum::customize`.
```cpp
enum class Directions { Up = 1 << 1, Down = 1 << 2, Right = 1 << 3, Left = 1 << 4 };
template <>
struct magic_enum::customize::is_flags_enum<Directions> : std::true_type {};
struct magic_enum::customize::enum_range<Directions> {
static constexpr bool is_flags = true;
};
```
* Enum value must be in range `[MAGIC_ENUM_RANGE_MIN, MAGIC_ENUM_RANGE_MAX]`.