mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd::util: Add missing popcount specializations. (regression fe0f398e14
) (-Wundefined-inline)
This commit is contained in:
parent
1c6d216daf
commit
f930f480c7
1 changed files with 26 additions and 0 deletions
|
@ -20,6 +20,8 @@ inline namespace util
|
|||
template<> constexpr int popcount(const unsigned long long) noexcept;
|
||||
template<> constexpr int popcount(const unsigned long) noexcept;
|
||||
template<> constexpr int popcount(const unsigned int) noexcept;
|
||||
template<> constexpr int popcount(const unsigned short) noexcept;
|
||||
template<> constexpr int popcount(const unsigned char) noexcept;
|
||||
}}
|
||||
|
||||
template<>
|
||||
|
@ -57,3 +59,27 @@ noexcept
|
|||
return __builtin_popcount(a);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<>
|
||||
constexpr int
|
||||
ircd::util::popcount(const unsigned short a)
|
||||
noexcept
|
||||
{
|
||||
#if __has_feature(__cpp_lib_bitops)
|
||||
return std::popcount(a);
|
||||
#else
|
||||
return __builtin_popcount(a);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<>
|
||||
constexpr int
|
||||
ircd::util::popcount(const unsigned char a)
|
||||
noexcept
|
||||
{
|
||||
#if __has_feature(__cpp_lib_bitops)
|
||||
return std::popcount(a);
|
||||
#else
|
||||
return __builtin_popcount(a);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue