isInputRange is false for non-copyable types
Shachar Shemesh
shachar at weka.io
Sun Apr 15 04:26:54 UTC 2018
import std.range;
import std.stdio;
struct S {
int a;
@disable this(this);
}
void main() {
writeln(isInputRange!(S[])); // Prints false
}
The reason, as far as I can tell, is that an input range requires that
we can do:
auto a = ir.front; // Assuming ir isn't empty
That doesn't work for non-copyable types, for obvious reasons.
With that said, that seems more like a deficiency in the input range
definition than anything. There is no reason we shouldn't be able to
iterator type operations over non-copyable types.
Shachar
More information about the Digitalmars-d
mailing list