From ec5a59e82563db18f10c9f0b926a697da55c44e0 Mon Sep 17 00:00:00 2001 From: terik23 Date: Thu, 25 Apr 2019 21:57:00 +0500 Subject: [PATCH] add check max/min --- include/nameof.hpp | 1 + test/test.cpp | 2 ++ 2 files changed, 3 insertions(+) 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."); }; }