29 #if _MSC_VER || __GNUC__ || __clang__
35 static const int S[] = {1, 2, 4, 8, 16, 32};
36 static const uint64_t B[] = {0x5555555555555555, 0x3333333333333333, 0x0F0F0F0F0F0F0F0F,
37 0x00FF00FF00FF00FF, 0x0000FFFF0000FFFF, 0x00000000FFFFFFFF };
39 c = v - ((v >> 1) & B[0]);
40 c = ((c >> S[1]) & B[1]) + (c & B[1]);
41 c = ((c >> S[2]) + c) & B[2];
42 c = ((c >> S[3]) + c) & B[3];
43 c = ((c >> S[4]) + c) & B[4];
44 return ((c >> S[5]) + c) & B[5];
50 return popcount(
static_cast<uint64_t
>(v >> 64) )
51 +
popcount(
static_cast<uint64_t
>(v & 0xffffffffffffffffULL) );