[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.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <__concepts/arithmetic.h>
|
||||
#include <__config>
|
||||
#include <__type_traits/is_unsigned.h>
|
||||
#include <__type_traits/is_unsigned_integer.h>
|
||||
#include <limits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp>
|
||||
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __countr_zero(_Tp __t) _NOEXCEPT {
|
||||
static_assert(is_unsigned<_Tp>::value, "__countr_zero only works with unsigned types");
|
||||
static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_zero only works with unsigned types");
|
||||
return __builtin_ctzg(__t, numeric_limits<_Tp>::digits);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <__concepts/arithmetic.h>
|
||||
#include <__config>
|
||||
#include <__type_traits/is_unsigned.h>
|
||||
#include <__type_traits/is_unsigned_integer.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp>
|
||||
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __popcount(_Tp __t) _NOEXCEPT {
|
||||
static_assert(is_unsigned<_Tp>::value, "__popcount only works with unsigned types");
|
||||
static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__popcount only works with unsigned types");
|
||||
return __builtin_popcountg(__t);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user