carb::cpp20::countr_zero

Defined in carb/cpp20/Bit.h

template<class T, std::enable_if_t<std::is_integral<T>::value && std::is_unsigned<T>::value, bool> = false>
int carb::cpp20::countr_zero(T val)

Returns the number of consecutive 0 bits in the value of val, starting from the least significant bit.

See

https://en.cppreference.com/w/cpp/numeric/countr_zero

Note

Unlike std::countr_zero, this function is not constexpr. This is because the compiler intrinsics used to implement this function are not constexpr until C++20, so it was decided to drop constexpr in favor of being able to use compiler intrinsics.

Template Parameters

T – An unsigned integral type

Parameters

val – An unsigned integral value

Returns

The number of consecutive 0 bits in the provided value, starting from the least significant bit.