On Wednesday, 21 December 2016 at 09:08:51 UTC, Ezneh wrote:
Hi, in one of my projects I have to get a slice from a BitArray.

I am trying to achieve that like this :

void foo(BitArray ba)
{
auto slice = ba[0..3]; // Assuming it has more than 4 elements
}

The problem is that I get an error :

"no operator [] overload for type BitArray".

Is there any other way to get a slice from a BitArray ?

Thanks,
Ezneh.

The problem is BitArray keeps multiple elements in one byte. You can't return just three bits but in the best case one byte with 8 elements.

What could be done some internal range could be returned that gives access to the bits. But it isn't implemented.

Reply via email to