From 07e7d8dff6235e75610ea6bac56547c1b087aa22 Mon Sep 17 00:00:00 2001 From: terik23 Date: Sun, 14 Jul 2019 21:00:34 +0500 Subject: [PATCH] add more assert --- include/nameof.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/nameof.hpp b/include/nameof.hpp index c847b2b..4dc75c6 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -73,6 +73,9 @@ static_assert(NAMEOF_ENUM_RANGE_MAX > 0, static_assert(NAMEOF_ENUM_RANGE_MAX < (std::numeric_limits::max)(), "NAMEOF_ENUM_RANGE_MAX must be less than INT_MAX."); +static_assert(NAMEOF_ENUM_RANGE_MAX > NAMEOF_ENUM_RANGE_MIN, + "NAMEOF_ENUM_RANGE_MAX must be greater than NAMEOF_ENUM_RANGE_MIN."); + namespace detail { template @@ -222,6 +225,8 @@ template [[nodiscard]] constexpr std::enable_if_t>, std::string_view> nameof_enum(E value) noexcept { using D = std::decay_t; static_assert(std::is_enum_v, "nameof::nameof_enum requires enum type."); + static_assert(enum_range::min > (std::numeric_limits::min)(), "nameof::enum_range requires min must be greater than INT_MIN."); + static_assert(enum_range::max < (std::numeric_limits::max)(), "nameof::enum_range requires max must be less than INT_MAX."); static_assert(enum_range::max > enum_range::min, "nameof::enum_range requires max > min."); using U = std::underlying_type_t; constexpr int max = enum_range::max < (std::numeric_limits::max)() ? enum_range::max : (std::numeric_limits::max)();