Why do operation on <bit> return signed numbers?
Solution 1:
From the paper:
The counting operations return "int" quantities, consistent with the rule "use an int unless you need something else". This choice does not reflect, in the type, the fact that counts are always non-negative.
gcc's intrinsic here (__builtin_popcount
) also returns int
.