
Le 2025-09-05 14:03, Ruben Perez via Boost a écrit :
On Thu, 4 Sep 2025 at 17:35, Gennaro Prota <gennaro.prota@gmail.com> wrote:
On 9/4/2025 1:35 PM, Ruben Perez wrote: [...]
DynamicBitset doesn't provide iterators, and doesn't pretend to be a container, because of the proxy reference type, which prevents iterators to satisfy the standard requirements. IOW, even if it provided iterators, they wouldn't be usable with the standard algorithms.
Is this still the case with C++20 ranges? AFAIK the forward iterator requirements were made less strict to support such cases. In gcc 15, the following static_assert succeeds:
static_assert(std::forward_iterator<std::vector<bool>::iterator>);
And the iterators/ranges seem usable in standard algorithms: https://godbolt.org/z/6P5MYTKG6
Yes. So do you suggest adding iterators only when DynamicBitset is compiled as C++20 or later?
I'd add them unconditionally. C++11 users can use them to iterate, and C++20 users can use them in algorithms, too. AFAIK what changed were the requirements, so no code needs to be guarded with a C++20 guard.
There's still the performance issue, though. I can see some value with const iteration, but anything that is modifying the bitset using iterators is, well, let's say probably far from optimal. I'm not sure encouraging such misuse is a good idea. Regards, Julien