Disjoint slices of an array as reference

data pulverizer data.pulverizer at gmail.com
Thu Aug 20 02:38:33 UTC 2020


On Thursday, 20 August 2020 at 02:21:15 UTC, data pulverizer 
wrote:
> However I would like to have disjoint slices, something like 
> this:
>
> ```
> auto y = x[0..5, 9..14];
> ```

I've been thinking about this some more and I don't think it is 
possible. An array in D is effectively two pointers either side 
of a memory block. When you create a slice you are creating 
another array two pointers somewhere in the same memory block. A 
disjoint slice array would need more than two pointers - which is 
not possible since an array only has 2.


More information about the Digitalmars-d-learn mailing list