Skip to content

Commit b49c789

Browse files
committed
[libc++] Fix constraints in __countr_zero and __popcount
Currently these two functions are constrained on `is_unsigned`, which is more permissive than what is required by the standard for their public counterparts. This fixes the constraints to match the public functions by using `__libcpp_is_unsigned_integer` instead.
1 parent 50f534e commit b49c789

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

libcxx/include/__bit/countr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include <__concepts/arithmetic.h>
1313
#include <__config>
14-
#include <__type_traits/is_unsigned.h>
14+
#include <__type_traits/is_unsigned_integer.h>
1515
#include <limits>
1616

1717
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2525

2626
template <class _Tp>
2727
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __countr_zero(_Tp __t) _NOEXCEPT {
28-
static_assert(is_unsigned<_Tp>::value, "__countr_zero only works with unsigned types");
28+
static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_zero only works with unsigned types");
2929
return __builtin_ctzg(__t, numeric_limits<_Tp>::digits);
3030
}
3131

libcxx/include/__bit/popcount.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include <__concepts/arithmetic.h>
1313
#include <__config>
14-
#include <__type_traits/is_unsigned.h>
14+
#include <__type_traits/is_unsigned_integer.h>
1515

1616
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1717
# pragma GCC system_header
@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424

2525
template <class _Tp>
2626
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __popcount(_Tp __t) _NOEXCEPT {
27-
static_assert(is_unsigned<_Tp>::value, "__popcount only works with unsigned types");
27+
static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__popcount only works with unsigned types");
2828
return __builtin_popcountg(__t);
2929
}
3030

0 commit comments

Comments
 (0)