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 13
13
#include < algorithm>
14
14
#include < type_traits>
15
15
16
+ #ifdef _MSC_VER
17
+ # include < intrin.h>
18
+ #endif
19
+
16
20
template <int bits>
17
21
static constexpr inline uint64_t Rot (uint64_t x) { return (x << bits) | (x >> (64 - bits)); }
18
22
@@ -135,6 +139,17 @@ static inline int CountBits(I val, int max) {
135
139
} else {
136
140
return std::numeric_limits<unsigned long long >::digits - __builtin_clzll (val);
137
141
}
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;
138
153
#else
139
154
while (max && (val >> (max - 1 ) == 0 )) --max;
140
155
return max;
You can’t perform that action at this time.
0 commit comments