[libc-commits] [libc] [libc] rename cpp::count_ones to cpp::popcount to better mirror std:: (PR #84388)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Thu Mar 7 14:46:59 PST 2024
================
@@ -269,14 +269,12 @@ first_trailing_one(T value) {
return value == cpp::numeric_limits<T>::max() ? 0 : countr_zero(value) + 1;
}
-/// Count number of 1's aka population count or hamming weight.
+/// Count number of 1's aka population count or Hamming weight.
///
/// Only unsigned integral types are allowed.
-// TODO: rename as 'popcount' to follow the standard
-// https://en.cppreference.com/w/cpp/numeric/popcount
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
-count_ones(T value) {
+popcount(T value) {
----------------
nickdesaulniers wrote:
I filed https://github.com/llvm/llvm-project/issues/82058 which resulted in https://github.com/llvm/llvm-project/commit/21d83324fbdbd91de0115d48f3b55979f57807b7.
We can use `__has_builtin` to use it for newer compilers.
https://github.com/llvm/llvm-project/pull/84388
More information about the libc-commits
mailing list