diff --git a/src/libipc/utility/countof.h b/src/libipc/utility/countof.h index b464e68..39f6999 100644 --- a/src/libipc/utility/countof.h +++ b/src/libipc/utility/countof.h @@ -17,11 +17,6 @@ LIBIPC_NAMESPACE_BEG_ * @see https://en.cppreference.com/w/cpp/iterator/size */ -template -constexpr std::size_t countof(T const (&)[N]) noexcept { - return N; -} - namespace detail { template @@ -48,13 +43,18 @@ template ::value , bool = countof_trait_has_Size::value> struct countof_trait; +template +struct countof_trait { + constexpr static auto countof(T const (&)[N]) noexcept { + return N; + } +}; + template struct countof_trait { constexpr static auto countof(C const &c) noexcept(noexcept(c.size())) { return c.size(); } - using return_t = decltype(countof_trait::countof(std::declval())); - enum : bool { noexcept_value = noexcept(countof_trait::countof(std::declval())) }; }; template @@ -62,15 +62,12 @@ struct countof_trait { constexpr static auto countof(C const &c) noexcept(noexcept(c.Size())) { return c.Size(); } - using return_t = decltype(countof_trait::countof(std::declval())); - enum : bool { noexcept_value = noexcept(countof_trait::countof(std::declval())) }; }; } // namespace detail template > -constexpr auto countof(C const &c) noexcept(R::noexcept_value) - -> typename R::return_t { +constexpr auto countof(C const &c) noexcept(noexcept(R::countof(c))) { return R::countof(c); }