Re: Why are static arrays not ranges?

2015-09-21 Thread jmh530 via Digitalmars-d-learn
On Monday, 21 September 2015 at 20:33:10 UTC, Jack Stouffer wrote: That's ridiculous. Do I have to wrap my static arrays in structs to get range primitives? Is there an actual reason for this? I had done basically the same thing. Below is my naive implementation. import std.traits;

Re: Why are static arrays not ranges?

2015-09-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 21, 2015 20:46:51 Jack Stouffer via Digitalmars-d-learn wrote: > On Monday, 21 September 2015 at 20:39:55 UTC, Jesse Phillips > wrote: > > 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

Re: Why are static arrays not ranges?

2015-09-21 Thread cym13 via Digitalmars-d-learn
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

Why are static arrays not ranges?

2015-09-21 Thread Jack Stouffer via Digitalmars-d-learn
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

Re: Why are static arrays not ranges?

2015-09-21 Thread Jesse Phillips via Digitalmars-d-learn
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

Re: Why are static arrays not ranges?

2015-09-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 21 September 2015 at 20:33:10 UTC, Jack Stouffer wrote: pragma(msg, isInputRange!(typeof(a))); try: pragma(msg, isInputRange!(typeof(a[]))); Notice the addition of the [] after the a. That's the slicing operator and it will yield a range. Is there an actual reason for

Re: Why are static arrays not ranges?

2015-09-21 Thread anonymous via Digitalmars-d-learn
On Monday 21 September 2015 22:33, 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

Re: Why are static arrays not ranges?

2015-09-21 Thread Jack Stouffer via Digitalmars-d-learn
On Monday, 21 September 2015 at 20:39:55 UTC, Jesse Phillips wrote: 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,