diff --git a/README.md b/README.md index 9ba5710..8a323d4 100644 --- a/README.md +++ b/README.md @@ -177,12 +177,12 @@ enum Color { RED = 2, BLUE = 4, GREEN = 8 }; * `magic_enum::enum_names` returns `std::array` with all string enum name where `N = number of enum values`, sorted by enum value. -* Enum value must be in range `[MAGIC_ENUM_RANGE_MIN, MAGIC_ENUM_RANGE_MAX]`. By default `MAGIC_ENUM_RANGE_MAX = 128`, `MAGIC_ENUM_RANGE_MIN = -128`. +* Enum value must be in range `[MAGIC_ENUM_RANGE_MIN, MAGIC_ENUM_RANGE_MAX]`. By default `MAGIC_ENUM_RANGE_MIN = -128`, `MAGIC_ENUM_RANGE_MAX = 128`. - If need another range for all enum types by default, redefine the macro `MAGIC_ENUM_RANGE_MAX` and `MAGIC_ENUM_RANGE_MIN`. + If need another range for all enum types by default, redefine the macro `MAGIC_ENUM_RANGE_MIN` and `MAGIC_ENUM_RANGE_MAX`. ```cpp - #define MAGIC_ENUM_RANGE_MAX 256 #define MAGIC_ENUM_RANGE_MIN 0 + #define MAGIC_ENUM_RANGE_MAX 256 #include ``` diff --git a/include/magic_enum.hpp b/include/magic_enum.hpp index c4d71d2..ef66b45 100644 --- a/include/magic_enum.hpp +++ b/include/magic_enum.hpp @@ -41,21 +41,21 @@ #include #include -// Enum value must be less than MAGIC_ENUM_RANGE_MAX. By default MAGIC_ENUM_RANGE_MAX = 128. -// If need another max range for all enum types by default, redefine the macro MAGIC_ENUM_RANGE_MAX. -#if !defined(MAGIC_ENUM_RANGE_MAX) -# define MAGIC_ENUM_RANGE_MAX 128 -#endif - -// Enum value must be greater than MAGIC_ENUM_RANGE_MIN. By default MAGIC_ENUM_RANGE_MIN = -128. +// Enum value must be greater or equals than MAGIC_ENUM_RANGE_MIN. By default MAGIC_ENUM_RANGE_MIN = -128. // If need another min range for all enum types by default, redefine the macro MAGIC_ENUM_RANGE_MIN. #if !defined(MAGIC_ENUM_RANGE_MIN) # define MAGIC_ENUM_RANGE_MIN -128 #endif +// Enum value must be less or equals than MAGIC_ENUM_RANGE_MAX. By default MAGIC_ENUM_RANGE_MAX = 128. +// If need another max range for all enum types by default, redefine the macro MAGIC_ENUM_RANGE_MAX. +#if !defined(MAGIC_ENUM_RANGE_MAX) +# define MAGIC_ENUM_RANGE_MAX 128 +#endif + namespace magic_enum { -// Enum value must be in range [-MAGIC_ENUM_RANGE_MAX, MAGIC_ENUM_RANGE_MIN]. By default MAGIC_ENUM_RANGE_MAX = 128, MAGIC_ENUM_RANGE_MIN = -128. +// Enum value must be in range [-MAGIC_ENUM_RANGE_MAX, MAGIC_ENUM_RANGE_MIN]. By default MAGIC_ENUM_RANGE_MIN = -128, MAGIC_ENUM_RANGE_MAX = 128. // If need another range for all enum types by default, redefine the macro MAGIC_ENUM_RANGE_MAX and MAGIC_ENUM_RANGE_MIN. // If need another range for specific enum type, add specialization enum_range for necessary enum type. template