diff --git a/src/int_utils.h b/src/int_utils.h index a7889b9..bd70c90 100644 --- a/src/int_utils.h +++ b/src/int_utils.h @@ -14,7 +14,9 @@ #include #include -#ifdef _MSC_VER +#if defined(__cpp_lib_int_pow2) && __cpp_lib_int_pow2 >= 202002L +# include +#elif defined(_MSC_VER) # include #endif @@ -142,7 +144,11 @@ constexpr inline I Mask() { return ((I((I(-1)) << (std::numeric_limits::digit /** Compute the smallest power of two that is larger than val. */ template static inline int CountBits(I val, int max) { -#ifdef _MSC_VER +#if defined(__cpp_lib_int_pow2) && __cpp_lib_int_pow2 >= 202002L + // c++20 impl + (void)max; + return std::bit_width(val); +#elif defined(_MSC_VER) (void)max; unsigned long index; unsigned char ret;