mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-09 23:34:23 +00:00
new customize (#166)
This commit is contained in:
parent
84efdbd2bf
commit
60de6bff8c
5 changed files with 74 additions and 48 deletions
|
|
@ -35,6 +35,15 @@
|
|||
#include <sstream>
|
||||
|
||||
enum class Color { RED = -12, GREEN = 7, BLUE = 15 };
|
||||
template <>
|
||||
constexpr magic_enum::customize::customize_t magic_enum::customize::enum_name<Color>(Color value) noexcept {
|
||||
switch (value) {
|
||||
case Color::RED:
|
||||
return "red";
|
||||
default:
|
||||
return default_tag;
|
||||
}
|
||||
}
|
||||
|
||||
enum class Numbers : int { one = 1, two, three, many = 127 };
|
||||
|
||||
|
|
@ -94,16 +103,6 @@ struct magic_enum::customize::enum_range<Binary> {
|
|||
static constexpr int max = 64;
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr std::string_view magic_enum::customize::enum_name<Color>(Color value) noexcept {
|
||||
switch (value) {
|
||||
case Color::RED:
|
||||
return "red";
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
using namespace magic_enum;
|
||||
|
||||
static_assert(is_magic_enum_supported, "magic_enum: Unsupported compiler (https://github.com/Neargye/magic_enum#compiler-compatibility).");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue