[Issue 17952] New: std.range.transposed save is invalid

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 30 16:00:26 UTC 2017


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

          Issue ID: 17952
           Summary: std.range.transposed save is invalid
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: schveiguy at yahoo.com

auto x = [[1,2,3],[4,5,6]].transposed;
auto y = x.save;
assert(x.equal([[1,4],[2,5],[3,6]]));
y.popFront;
assert(x.equal([[1,4],[2,5],[3,6]])); // FAILS, x is really [[2,5],[3,6]]

The only way .save can truly be implemented is by duplicating the RangeOfRanges
range, and there is no standard for doing this (.dup is not consistent across
ranges).

We have 2 options:

1. Deprecate .save (i.e. make transposed NOT a forward range)
2. convert the RangeOfRanges element to an array, and duplicate on every .save.

Neither option is particularly good. My vote would be for option 1.

--


More information about the Digitalmars-d-bugs mailing list