diff --git a/include/nameof.hpp b/include/nameof.hpp index 79e56cc..f330dea 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -59,6 +59,7 @@ struct enum_range final { static_assert(std::is_enum_v, "nameof::enum_range requires enum type."); static constexpr int min = std::is_signed_v> ? NAMEOF_ENUM_RANGE_MIN : 0; static constexpr int max = NAMEOF_ENUM_RANGE_MAX; + static_assert(max > min, "nameof::enum_range requires max > min."); }; namespace detail { diff --git a/test/test.cpp b/test/test.cpp index ef97b7a..d659bfb 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -82,8 +82,10 @@ enum number : unsigned long { zero = 0, one = 100, two = 200, three = 300, four namespace nameof { template <> struct enum_range { + static_assert(std::is_enum_v, "nameof::enum_range requires enum type."); static constexpr int min = 100; static constexpr int max = 300; + static_assert(max > min, "nameof::enum_range requires max > min."); }; }