mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-09 22:56:35 +00:00
util: fix consteval CountTrailingZeroes impl
This commit is contained in:
parent
1c5edaf4fb
commit
d27fe8a229
1 changed files with 3 additions and 0 deletions
|
@ -195,6 +195,7 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
static_assert(CountLeadingZeros(~static_cast<u64>(0)) == 0);
|
||||
static_assert(CountLeadingZeros(static_cast<u64>(1) << 5) == BITSIZEOF(u64) - 1 - 5);
|
||||
static_assert(CountLeadingZeros(static_cast<u64>(0)) == BITSIZEOF(u64));
|
||||
|
||||
template<typename T> requires std::integral<T>
|
||||
|
@ -202,6 +203,7 @@ namespace ams::util {
|
|||
if (std::is_constant_evaluated()) {
|
||||
auto count = 0;
|
||||
for (size_t i = 0; i < BITSIZEOF(T) && (x & 1) == 0; ++i) {
|
||||
x >>= 1;
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
|
@ -226,6 +228,7 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
static_assert(CountTrailingZeros(~static_cast<u64>(0)) == 0);
|
||||
static_assert(CountTrailingZeros(static_cast<u64>(1) << 5) == 5);
|
||||
static_assert(CountTrailingZeros(static_cast<u64>(0)) == BITSIZEOF(u64));
|
||||
|
||||
template<typename T> requires std::integral<T>
|
||||
|
|
Loading…
Reference in a new issue