From 9ede5ab9010c7d3c3be628d0ea27407d9848891a Mon Sep 17 00:00:00 2001 From: neargye Date: Sun, 24 May 2020 17:52:22 +0500 Subject: [PATCH] clean-up namespace --- include/nameof.hpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/include/nameof.hpp b/include/nameof.hpp index f2dfd0b..5db6f3f 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -384,8 +384,6 @@ constexpr auto n() noexcept { template inline constexpr auto enum_name_v = n(); -namespace enums { - template constexpr bool cmp_less(L lhs, R rhs) noexcept { static_assert(std::is_integral_v && std::is_integral_v, "nameof::detail::cmp_less requires integral type."); @@ -517,8 +515,6 @@ constexpr auto strings() noexcept { template inline static constexpr auto strings_v = strings(); -} // namespace nameof::detail::enums - template constexpr auto n() noexcept { #if defined(NAMEOF_TYPE_SUPPORTED) && NAMEOF_TYPE_SUPPORTED @@ -550,19 +546,19 @@ inline constexpr bool is_nameof_enum_supported = detail::nameof_enum_supported [[nodiscard]] constexpr auto nameof_enum(E value) noexcept -> detail::enable_if_enum_t { - using namespace detail::enums; using D = detail::remove_cvref_t; using U = std::underlying_type_t; static_assert(detail::nameof_enum_supported::value, "nameof::nameof_enum unsupported compiler (https://github.com/Neargye/nameof#compiler-compatibility)."); - static_assert(count_v > 0, "nameof::nameof_enum requires enum implementation and valid max and min."); + static_assert(detail::count_v > 0, "nameof::nameof_enum requires enum implementation and valid max and min."); - if (const auto i = static_cast(value) - min_v; static_cast(value) >= static_cast(min_v) && static_cast(value) <= static_cast(max_v)) { - if constexpr (sparsity_v) { - if (const auto idx = indexes_v[i]; idx != invalid_index_v) { - return strings_v[idx]; + if (const auto i = static_cast(value) - detail::min_v; static_cast(value) >= static_cast(detail::min_v) && + static_cast(value) <= static_cast(detail::max_v)) { + if constexpr (detail::sparsity_v) { + if (const auto idx = detail::indexes_v[i]; idx != detail::invalid_index_v) { + return detail::strings_v[idx]; } } else { - return strings_v[i]; + return detail::strings_v[i]; } }