Bug 13824 – std.range.transposed irrevocably consumes subranges

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-12-06T06:31:00Z
Last change time
2015-01-02T21:40:17Z
Assigned to
nobody
Creator
hsteoh

Comments

Comment #0 by hsteoh — 2014-12-06T06:31:05Z
Code: ------ void main() { import std.stdio; import std.range; auto data = [ [1,2,3], [4,5,6], [7,8,9] ]; writeln(data.transposed()); writeln(data); } ------ Output: ------ [[1, 4, 7], [2, 5, 8], [3, 6, 9]] [[], [], []] ------ This limits the usefulness of transposed(), since a copy of the original range of ranges must be made if it needs to be used again in its original form after iterating over its transposed() wrapper.
Comment #1 by peter.alexander.au — 2015-01-02T21:40:17Z
*** This issue has been marked as a duplicate of issue 13041 ***