bit_util: bug: Infinite loop in HighestSetBit
This commit is contained in:
parent
3caf192f60
commit
33bba6028c
1 changed files with 3 additions and 0 deletions
|
@ -101,6 +101,9 @@ inline int HighestSetBit(T value) {
|
|||
template <typename T>
|
||||
inline size_t LowestSetBit(T value) {
|
||||
auto x = static_cast<std::make_unsigned_t<T>>(value);
|
||||
if (x == 0)
|
||||
return BitSize<T>();
|
||||
|
||||
size_t result = 0;
|
||||
while ((x & 1) == 0) {
|
||||
x >>= 1;
|
||||
|
|
Loading…
Reference in a new issue