C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Finding the first/next set bit in a bitset

From: Anders Schau Knatten <anders_at_[hidden]>
Date: Sat, 24 May 2025 15:24:30 +0200
On Thu, May 22, 2025 at 2:25 PM Jan Schultke <janschultke_at_[hidden]>
wrote:

> P0237R0 proposes a bit_iterator, but it seems like it was abandoned by the
> author while in need of revision. I'm not 100% familiar with the history
> there.
>

Right, that one seems to iterate over all the bits, though, not just the
set ones. Which I'm sure is also useful, but I still think it would be very
useful to be able to iterate over only the set bits. I haven't seen any
proposals for how to do that, and I'm honestly not sure how one would do
that in a way that's both idiomatic, discoverable and easy to optimize. (My
failure of imagination of course doesn't mean it can be done.)

In any case, it will be possible to do this with your proposal, so I wish
you the best of luck with it! Personally I'd prefer the find_first and
find_next that libstdc++ has, but the count(...) ones are nice for
consistency.

Cheers,
Anders

Received on 2025-05-24 13:24:43