January 28, 2016 Object-based interface for a range of ranges | ||||
|---|---|---|---|---|
| ||||
This works:
int[][] a;
RandomAccessFinite!(int[]) r = inputRangeObject(a);
What would be a good way to achieve something equivalent to this?:
int[][] a;
RandomAccessFinite!(RandomAccessFinite!int) r = inputRangeObject(a);
| ||||
January 27, 2016 Re: Object-based interface for a range of ranges | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Luís Marques | On 01/27/2016 08:59 PM, Luís Marques wrote: > This works: > > int[][] a; > RandomAccessFinite!(int[]) r = inputRangeObject(a); > > What would be a good way to achieve something equivalent to this?: > > int[][] a; > RandomAccessFinite!(RandomAccessFinite!int) r = inputRangeObject(a); All I can say is the following compiles. I hope it works too. :) import std.range; import std.algorithm; import std.conv; void main() { int[][] a; RandomAccessFinite!(RandomAccessFinite!int) r = inputRangeObject( a.map!(e => inputRangeObject(e).to!(RandomAccessFinite!int))); } Instead of to!(RandomAccessFinite!int) one can use the cast operator as well. Ali | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply