xxxxxxxxxx
struct OutputRange
{
private bool valid = true;
private void* ptr;
int count = 0;
void put(Val)(auto ref scope Val val)
{
assert(this.valid == true);
this.count += 1;
}
~this() pure nothrow
{
this.valid = false;
}
}
void main() pure nothrow
{
import std.algorithm : copy;
import std.range : only;
OutputRange or;
only(1, 2, 3, 4).copy(&or); // ok
assert(or.count == 4);
}