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.
Comment #1 by schveiguy — 2017-10-30T17:50:53Z
Scratch that, x is not really [[2,5],[3,6]], it's an empty range! Just using equals destroys it.
transposed clearly isn't even close to a forward range.
Comment #2 by schveiguy — 2017-10-30T17:54:13Z
To ensure this test case is checking the right issue, change the third line to:
assert(y.equal([[1,4],[2,5],[3,6]]));
And get rid of the y.popFront.
Clearly, we should be able to iterate y without iterating x. But that's not what happens (consuming any saved range consumes them all).
Comment #3 by github-bugzilla — 2017-11-01T18:57:15Z