[Issue 10845] New: std.range.Cycle broken for reference type forward ranges
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 18 04:59:57 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10845
Summary: std.range.Cycle broken for reference type forward
ranges
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: peter.alexander.au at gmail.com
--- Comment #0 from Peter Alexander <peter.alexander.au at gmail.com> 2013-08-18 04:59:56 PDT ---
import std.stdio;
import std.range;
import std.algorithm;
void main()
{
auto a = inputRangeObject(iota(3).filter!"true");
writeln(a.cycle.take(10));
}
Outputs
[0, 1, 2, 0, 1, 2,
then asserts: http://dpaste.dzfl.pl/84de028d
The problem is Cycle.popFront:
void popFront()
{
_current.popFront();
if (_current.empty) _current = _original;
}
It should be _current = _original.save, otherwise the _original range is
consumed on the second iteration.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list