[Issue 12563] std.container.SList.reverse
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Jun 7 09:23:22 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12563
--- Comment #2 from bearophile_hugs at eml.cc ---
(In reply to monkeyworks12 from comment #1)
> Why not use std.range.retro? The only downside is that you can't assign the
> result back to the original SList.
A SList is usually implemented with a chain of 2-structs that contain a cargo
plus a forward pointer. So you can't walk them backwards with retro. And indeed
this doesn't compile:
void main() {
import std.stdio: writeln;
import std.container: SList;
import std.range: retro;
auto list = SList!int([1, 7, 42]);
list[].writeln;
list[].retro.writeln;
list.retro.writeln;
}
--
More information about the Digitalmars-d-bugs
mailing list