File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 1313#include < algorithm>
1414#include < type_traits>
1515
16+ #ifdef _MSC_VER
17+ # include < intrin.h>
18+ #endif
19+
1620template <int bits>
1721static constexpr inline uint64_t Rot (uint64_t x) { return (x << bits) | (x >> (64 - bits)); }
1822
@@ -135,6 +139,17 @@ static inline int CountBits(I val, int max) {
135139 } else {
136140 return std::numeric_limits<unsigned long long >::digits - __builtin_clzll (val);
137141 }
142+ #elif _MSC_VER
143+ (void )max;
144+ unsigned long index;
145+ unsigned char ret;
146+ if (std::numeric_limits<I>::digits <= 32 ) {
147+ ret = _BitScanReverse (&index, val);
148+ } else {
149+ ret = _BitScanReverse64 (&index, val);
150+ }
151+ if (!ret) return 0 ;
152+ return index;
138153#else
139154 while (max && (val >> (max - 1 ) == 0 )) --max;
140155 return max;
You can’t perform that action at this time.
0 commit comments