D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 16363 - Cannot construct a random access range using frontTransversal
Summary: Cannot construct a random access range using frontTransversal
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: gruen_tobias
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-08 01:35 UTC by kirsybuu
Modified: 2016-10-01 11:47 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kirsybuu 2016-08-08 01:35:52 UTC
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 github-bugzilla 2016-08-29 19:07:33 UTC
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/b450113a4a6c5f6f329ef63cdaca4bd7ca3a8922
Enhancement 16363

Issue 16363 (Cannot construct a random access range using frontTransversal)
https://issues.dlang.org/show_bug.cgi?id=16291

- Added the length property to frontTransversal (only if the length is known)

https://github.com/dlang/phobos/commit/6394458fc3eed3800957d111650bd63bce010257
Merge pull request #4754 from togrue/issue_16363

Fix issue 16363 - Cannot construct a random access range using frontTransversal
Comment 2 github-bugzilla 2016-10-01 11:47:08 UTC
Commits pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/b450113a4a6c5f6f329ef63cdaca4bd7ca3a8922
Enhancement 16363

https://github.com/dlang/phobos/commit/6394458fc3eed3800957d111650bd63bce010257
Merge pull request #4754 from togrue/issue_16363