From e4d3ea10a5413c96ba02a6c64b617d18ed93fb5d Mon Sep 17 00:00:00 2001 From: terik23 Date: Tue, 26 Mar 2019 22:15:11 +0500 Subject: [PATCH] static_assert for double-check --- include/nameof.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/nameof.hpp b/include/nameof.hpp index 407470a..f6bfe56 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -162,6 +162,7 @@ template template [[nodiscard]] constexpr std::string_view nameof_enum_impl() noexcept { + static_assert(std::is_enum_v); #if defined(__clang__) std::string_view name{__PRETTY_FUNCTION__}; constexpr auto suffix = sizeof("]") - 1; @@ -190,6 +191,7 @@ template template struct nameof_enum_impl_t final { [[nodiscard]] constexpr std::string_view operator()(int value) const noexcept { + static_assert(std::is_enum_v); if constexpr (V > std::numeric_limits>::max()) { return "nameof_enum::out_of_range"; } @@ -220,6 +222,7 @@ struct nameof_enum_impl_t final { template struct nameof_enum_impl_t final { [[nodiscard]] constexpr std::string_view operator()(int) const noexcept { + static_assert(std::is_enum_v); return "nameof_enum::out_of_range"; } };