d切片示例
struct Integers {
private int z = 0;
public bool empty() { return false; }
public int front() { return this.z; }
public void popFront()
{
this.z *= -1;
if (this.z <= 0)
--this.z;
}
}
void main()
{
import std.stdio : writeln;
foreach (const z; Integers()) {
writeln(z);
if (z == 5)
break;
}
}