On Wed, Dec 17, 2025 at 08:31:58PM +0000, Jonathan Wakely wrote:
> > So, if you want to use something like popcount, then you need some
> > function template which for normal unsigned integrals will return
> > __builtin_popcountg on the argument and for struct __rand_uint128 will
> > return __builtin_popcountg(_M_hi) + __builtin_popcountg(_M_lo);
> 
> Do we need popcount at all? Isn't it just sizeof(_UInt) * CHAR_BIT?

If we are just talking about uint32_t, uint64_t, unsigned __int128
and this struct { uint64_t _M_hi, _M_lo; }; then I guess
sizeof(_UInt) * __CHAR_BIT__ would be good enough.
For arbitrary unsigned integral types of course not, whether it
is unsigned _BitInt(125) or unsigned __int20 etc.

        Jakub

Reply via email to