fix nameof_enum
This commit is contained in:
parent
0e425a33b7
commit
7e3b975054
1 changed files with 2 additions and 4 deletions
|
@ -579,10 +579,8 @@ template <typename E>
|
||||||
// Obtains simple (unqualified) string enum name of static storage enum variable.
|
// Obtains simple (unqualified) string enum name of static storage enum variable.
|
||||||
// This version is much lighter on the compile times and is not restricted to the enum_range limitation.
|
// This version is much lighter on the compile times and is not restricted to the enum_range limitation.
|
||||||
template <auto V>
|
template <auto V>
|
||||||
[[nodiscard]] constexpr auto nameof_enum() noexcept {
|
[[nodiscard]] constexpr auto nameof_enum() noexcept -> detail::enable_if_enum_t<decltype(V), std::string_view> {
|
||||||
using D = detail::remove_cvref_t<decltype(V)>;
|
constexpr std::string_view name = detail::enum_name_v<detail::remove_cvref_t<decltype(V)>, V>;
|
||||||
static_assert(std::is_enum_v<D>, "nameof::nameof_enum requires enum type.");
|
|
||||||
constexpr auto name = detail::n<D, V>();
|
|
||||||
static_assert(name.size() > 0, "Enum value does not have a name.");
|
static_assert(name.size() > 0, "Enum value does not have a name.");
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
|
Loading…
Reference in a new issue