Bug 7490 – BitArray should support slicing to extract a range

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-12T13:23:54Z
Last change time
2017-10-16T08:35:09Z
Keywords
bootcamp
Assigned to
No Owner
Creator
bearophile_hugs
See also
http://d.puremagic.com/issues/show_bug.cgi?id=7487

Comments

Comment #0 by bearophile_hugs — 2012-02-12T13:23:54Z
It seems std.array.array() is not able to convert a std.bitmanip.BitArray into a dynamic array: import std.array, std.bitmanip; void main() { BitArray ba; ba.length = 10; foreach (b; ba) {} // OK array(ba); // error } DMD 2.058beta: test.d(6): Error: template std.array.array(Range) if (isIterable!(Range) && !isNarrowString!(Range)) does not match any function template declaration test.d(6): Error: template std.array.array(Range) if (isIterable!(Range) && !isNarrowString!(Range)) cannot deduce template function from argument types !()(BitArray)
Comment #1 by lovelydear — 2012-04-19T08:53:57Z
See related 7487 and 7488
Comment #2 by andrej.mitrovich — 2014-04-24T19:30:29Z
That's never going to be supported. What can be supported is for BitArray to expose a range interface, e.g. via: BitArray ba; auto arr = ba[].array; // call opSlice to get a range, then array() will work I've changed the title.
Comment #3 by razvan.nitu1305 — 2017-10-16T08:35:09Z
The example in the original bug report now compiles and runs on git HEAD. Closing as fixed.