auto template
This commit is contained in:
parent
c427fd71c1
commit
30618cd156
1 changed files with 10 additions and 10 deletions
|
@ -160,7 +160,7 @@ template <typename T>
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename E, E V>
|
template <auto V>
|
||||||
[[nodiscard]] constexpr std::string_view nameof_enum_impl() noexcept {
|
[[nodiscard]] constexpr std::string_view nameof_enum_impl() noexcept {
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
std::string_view name{__PRETTY_FUNCTION__};
|
std::string_view name{__PRETTY_FUNCTION__};
|
||||||
|
@ -196,21 +196,21 @@ struct nameof_enum_impl_t final {
|
||||||
|
|
||||||
switch (value - V) {
|
switch (value - V) {
|
||||||
case 0:
|
case 0:
|
||||||
return nameof_enum_impl<E, static_cast<E>(V)>();
|
return nameof_enum_impl<static_cast<E>(V)>();
|
||||||
case 1:
|
case 1:
|
||||||
return nameof_enum_impl<E, static_cast<E>(V + 1)>();
|
return nameof_enum_impl<static_cast<E>(V + 1)>();
|
||||||
case 2:
|
case 2:
|
||||||
return nameof_enum_impl<E, static_cast<E>(V + 2)>();
|
return nameof_enum_impl<static_cast<E>(V + 2)>();
|
||||||
case 3:
|
case 3:
|
||||||
return nameof_enum_impl<E, static_cast<E>(V + 3)>();
|
return nameof_enum_impl<static_cast<E>(V + 3)>();
|
||||||
case 4:
|
case 4:
|
||||||
return nameof_enum_impl<E, static_cast<E>(V + 4)>();
|
return nameof_enum_impl<static_cast<E>(V + 4)>();
|
||||||
case 5:
|
case 5:
|
||||||
return nameof_enum_impl<E, static_cast<E>(V + 5)>();
|
return nameof_enum_impl<static_cast<E>(V + 5)>();
|
||||||
case 6:
|
case 6:
|
||||||
return nameof_enum_impl<E, static_cast<E>(V + 6)>();
|
return nameof_enum_impl<static_cast<E>(V + 6)>();
|
||||||
case 7:
|
case 7:
|
||||||
return nameof_enum_impl<E, static_cast<E>(V + 7)>();
|
return nameof_enum_impl<static_cast<E>(V + 7)>();
|
||||||
default:
|
default:
|
||||||
return nameof_enum_impl_t<E, V + 8>{}(value);
|
return nameof_enum_impl_t<E, V + 8>{}(value);
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ template <typename T, typename = std::enable_if_t<std::is_enum_v<std::decay_t<T>
|
||||||
// nameof_enum used to obtain the simple (unqualified) string enum name of static storage enum variable.
|
// nameof_enum used to obtain the simple (unqualified) string enum name of static storage enum variable.
|
||||||
template <auto V, typename = std::enable_if_t<std::is_enum_v<std::decay_t<decltype(V)>>>>
|
template <auto V, typename = std::enable_if_t<std::is_enum_v<std::decay_t<decltype(V)>>>>
|
||||||
[[nodiscard]] constexpr std::string_view nameof_enum() noexcept {
|
[[nodiscard]] constexpr std::string_view nameof_enum() noexcept {
|
||||||
return detail::nameof_enum_impl<decltype(V), V>();
|
return detail::nameof_enum_impl<V>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// nameof_type used to obtain the string name of type.
|
// nameof_type used to obtain the string name of type.
|
||||||
|
|
Loading…
Reference in a new issue