From 8df003ea5350bf4300918cb7679537315a270d43 Mon Sep 17 00:00:00 2001 From: terik23 Date: Tue, 9 Apr 2019 02:52:00 +0500 Subject: [PATCH] fixing --- include/nameof.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/nameof.hpp b/include/nameof.hpp index 6fef869..3ed5fb8 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -195,7 +195,7 @@ template template [[nodiscard]] constexpr decltype(auto) enum_strings_impl(std::integer_sequence) noexcept { - static_assert(std::is_enum_v, "magic_enum::detail::enum_strings_impl requires enum type."); + static_assert(std::is_enum_v, "nameof::detail::enum_strings_impl requires enum type."); constexpr std::array enum_names{{enum_name_impl(I + O)>()...}}; return enum_names; @@ -203,9 +203,10 @@ template template > [[nodiscard]] constexpr std::string_view nameof_enum_impl(int value) noexcept { - static_assert(std::is_enum_v, "magic_enum::detail::nameof_enum_impl requires enum type."); - constexpr int max = (enum_range::max < std::numeric_limits::max()) ? enum_range::max : std::numeric_limits::max(); - constexpr int min = (enum_range::min > std::numeric_limits::min()) ? enum_range::min : std::numeric_limits::min(); + static_assert(std::is_enum_v, "nameof::detail::nameof_enum_impl requires enum type."); + static_assert(enum_range::max > enum_range::min, "nameof::enum_range requires max > min."); + constexpr int max = enum_range::max < (std::numeric_limits::max)() ? enum_range::max : (std::numeric_limits::max)(); + constexpr int min = enum_range::min > (std::numeric_limits::min)() ? enum_range::min : (std::numeric_limits::min)(); constexpr auto enum_range = std::make_integer_sequence{}; constexpr auto enum_names = enum_strings_impl(enum_range); const int i = value - min; @@ -230,8 +231,8 @@ template } // namespace detail // Obtains simple (unqualified) string enum name of enum variable. -template , typename = std::enable_if_t>> -[[nodiscard]] constexpr std::string_view nameof_enum(T value) noexcept { +template , typename = std::enable_if_t>> +[[nodiscard]] constexpr std::string_view nameof_enum(E value) noexcept { static_assert(std::is_enum_v, "nameof::nameof_enum requires enum type."); return detail::nameof_enum_impl(static_cast(value));