add check max/min
This commit is contained in:
parent
7ba9b945de
commit
ec5a59e825
2 changed files with 3 additions and 0 deletions
|
@ -59,6 +59,7 @@ struct enum_range final {
|
||||||
static_assert(std::is_enum_v<E>, "nameof::enum_range requires enum type.");
|
static_assert(std::is_enum_v<E>, "nameof::enum_range requires enum type.");
|
||||||
static constexpr int min = std::is_signed_v<std::underlying_type_t<E>> ? NAMEOF_ENUM_RANGE_MIN : 0;
|
static constexpr int min = std::is_signed_v<std::underlying_type_t<E>> ? NAMEOF_ENUM_RANGE_MIN : 0;
|
||||||
static constexpr int max = NAMEOF_ENUM_RANGE_MAX;
|
static constexpr int max = NAMEOF_ENUM_RANGE_MAX;
|
||||||
|
static_assert(max > min, "nameof::enum_range requires max > min.");
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
|
@ -82,8 +82,10 @@ enum number : unsigned long { zero = 0, one = 100, two = 200, three = 300, four
|
||||||
namespace nameof {
|
namespace nameof {
|
||||||
template <>
|
template <>
|
||||||
struct enum_range<number> {
|
struct enum_range<number> {
|
||||||
|
static_assert(std::is_enum_v<number>, "nameof::enum_range<number> requires enum type.");
|
||||||
static constexpr int min = 100;
|
static constexpr int min = 100;
|
||||||
static constexpr int max = 300;
|
static constexpr int max = 300;
|
||||||
|
static_assert(max > min, "nameof::enum_range<number> requires max > min.");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue