Bug 16363 – Cannot construct a random access range using frontTransversal
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-08-08T01:35:00Z
Last change time
2016-10-01T11:47:08Z
Assigned to
gruen_tobias
Creator
kirsybuu
Comments
Comment #0 by kirsybuu — 2016-08-08T01:35:52Z
The current implementation of FrontTransversal and Transversal both do not attempt to implement length or opDollar when the underlying range supports it, thus even when using assumeNotJagged the output range will not be a random access range.
import std.range;
void main() {
int[][] darr = [[0, 1, 2], [4, 5, 6]];
auto fT = frontTransversal!(TransverseOptions.assumeNotJagged)(darr);
auto l = fT.length;
auto s = fT[0 .. $];
static assert(isRandomAccessRange!(typeof(fT)));
}
alex.d(5): Error: no property 'length' for type 'FrontTransversal!(int[][], cast(TransverseOptions)2)'
alex.d(6): Error: undefined identifier '__dollar'
alex.d(7): Error: static assert (isRandomAccessRange!(FrontTransversal!(int[][], cast(TransverseOptions)2))) is false
Comment #1 by github-bugzilla — 2016-08-29T19:07:33Z