1 #ifndef GENESIS_UTILS_BITS_OPERATORS_H_
2 #define GENESIS_UTILS_BITS_OPERATORS_H_
34 #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
39 #include <immintrin.h>
42 # define GENSIS_HAS_COMPILETIME_BMI2 1
44 # define GENSIS_HAS_COMPILETIME_BMI2 0
65 template <
typename Integral>
66 inline constexpr Integral extract_bits( Integral source, Integral mask )
71 Integral lsb = mask & -mask;
73 bool isset = source & lsb;
74 res |= isset ? bb : 0;
81 inline uint64_t bit_extract( uint64_t source, uint64_t mask )
83 return _pext_u64( source, mask );
98 inline constexpr
size_t pop_count( T x )
109 #endif // ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
110 #endif // include guard