mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-10 23:44:29 +00:00
improve name_impl
This commit is contained in:
parent
22167885d7
commit
2e61a86b2f
1 changed files with 7 additions and 6 deletions
|
|
@ -122,18 +122,19 @@ inline constexpr auto range_v = range_impl<E>();
|
||||||
return {}; // Invalid name.
|
return {}; // Invalid name.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct always_false final : std::false_type {};
|
||||||
|
|
||||||
template <typename E, E V>
|
template <typename E, E V>
|
||||||
[[nodiscard]] constexpr std::string_view name_impl() noexcept {
|
[[nodiscard]] constexpr auto name_impl() noexcept {
|
||||||
static_assert(std::is_enum_v<E>, "magic_enum::detail::name_impl requires enum type.");
|
static_assert(std::is_enum_v<E>, "magic_enum::detail::name_impl requires enum type.");
|
||||||
#if defined(__clang__)
|
#if defined(__clang__) || defined(__GNUC__) && __GNUC__ >= 9
|
||||||
return pretty_name({__PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 2});
|
return pretty_name({__PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 2});
|
||||||
#elif defined(__GNUC__) && __GNUC__ >= 9
|
|
||||||
return pretty_name({__PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 51});
|
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
return pretty_name({__FUNCSIG__, sizeof(__FUNCSIG__) - 17});
|
return pretty_name({__FUNCSIG__, sizeof(__FUNCSIG__) - 17});
|
||||||
#else
|
#else
|
||||||
# error "magic_enum: Unsupported compiler (https://github.com/Neargye/magic_enum#compiler-compatibility)."
|
static_assert(always_false<E>{}, "magic_enum: Unsupported compiler (https://github.com/Neargye/magic_enum#compiler-compatibility).");
|
||||||
return {}; // Unsupported compiler.
|
return std::string_view{}; // Unsupported compiler.
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue