[Issue 13824] New: std.range.transposed irrevocably modifies subranges

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Dec 5 22:31:05 PST 2014


https://issues.dlang.org/show_bug.cgi?id=13824

          Issue ID: 13824
           Summary: std.range.transposed irrevocably modifies subranges
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody at puremagic.com
          Reporter: hsteoh at quickfur.ath.cx

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.

--


More information about the Digitalmars-d-bugs mailing list