1
0
Fork 0
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:
Daniil Goncharov 2022-03-18 13:58:07 +04:00 committed by GitHub
parent 84efdbd2bf
commit 60de6bff8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 74 additions and 48 deletions

View file

@ -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).");