On Monday, 21 September 2015 at 20:33:10 UTC, Jack Stouffer wrote:
import std.range;
void main() {
int[6] a = [1, 2, 3, 4, 5, 6];
pragma(msg, isInputRange!(typeof(a)));
pragma(msg, isForwardRange!(typeof(a)));
pragma(msg, isRandomAccessRange!(typeof(a)));
}
$ dmd -run test.d
false
false
false
That's ridiculous. Do I have to wrap my static arrays in
structs to get range primitives?
Is there an actual reason for this?
A static array has a constant length, so it is not possible to
popFront on a static array.
Making a dynamic array from it is easy, just slice it with []:
pragma(msg, isInputRange!(typeof(a[])));
pragma(msg, isForwardRange!(typeof(a[])));
pragma(msg, isRandomAccessRange!(typeof(a[])));