C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [bitset] find first set bit after a position pos

From: Madhur Chauhan <madhur4127_at_[hidden]>
Date: Tue, 25 Oct 2022 12:27:12 +0530
Hello Alejandro,

Or, you can consider using ISO C (C23), which should be "usable" within C++.
>
> There's <stdbit.h> and the stdc_leading_zeros{c,s,i,l,ll}(3) family of
> functions, and the stdc_leading_zeros(3) type-generic function (which
> might be
> unavailable in C++, or maybe they implement it as an overloaded function,
> or
> maybe an 'auto' macro; we'll see).
>

Thanks for the suggestion but I believe this won't work for the use
case where the bitset exceeds 64 bits right? From C23 paper (emphasis
mine)[1]:

Extended integer types, least-width integer types, and exact-width integer
> types, can all be used with the type-generic macros since the type-generic
> macros are required to work over all standard (unsigned) integer types and
> extended (unsigned) integer types, while *excluding bool and bit-precise
> (_BitInt(N)) integer types* that do not match pre-existing type widths.



References:
1.
https://open-std.org/JTC1/SC22/WG14/www/docs/n3022.htm#design-bit-count_ones.count_zeros

-- 
Sincerely,
Madhur Chauhan
*“To live is the rarest thing in the world. Most people exist, that is
all.”*
*- **Oscar Wilde*

Received on 2022-10-25 06:57:50