The functions from P0553R4: Bit operations are constrained to only work on unsigned integers. The proposal does not give a reason for this constraint. I can see that this makes sense if the bit representation of a signed integer is not defined, but with C++20, we are guaranteed that signed integers use two's complement.
To me, it thus seems reasonable to allow e.g. std::popcount
to be called with a signed integer type, as an implementation could simply cast to the corresponding unsigned type to do the bit-operation in the unsigned domain.
What is the reason for P0553R4 to add this constraint? (Is it simply missing synchronization between P0553R4 and P0907R4?)
template <typename T> int spopcount(T s) { return popcount(static_cast<std::make_unsigned_t<decltype(s)>>(s)); }
... but anyway, I presume the P0553 proposal itself predates the 2s complement representation as an independent proposal. Something that could be easily "fixed" with a new small proposal. Proposals like that need someone to propose them.<bit>
family of functions only working with unsigned types can be found in the reasoning behind that decision?