Here I want to lockstep iterate over two arrays of size_t
import std.stdio;
import std.range;
import std.exception;
import std.conv;
struct zip(R,Q)
if(isInputRange!(R) && isInputRange!(Q))
{
R r;
Q q;
@property
const auto front() {
return tuple(r.front, q.front);
}
void popFront() {
r.popFront();
q.popFront();
}
@property
const bool empty() {
bool re = r.empty;
enforce(re == q.empty);
return re;
}
}
void main() {
size_t[] a = [0,1,2,3,4,5];
size_t[] b = [2,3,4,5,6,7];
foreach(size_t i, size_t j; zip!(size_t[],size_t[])(a,b)) {
writeln(to!string(i) ~ " " ~ to!string(j));
}
}
But this fails to compile with
src/Interpreter.d(30): Error: cannot infer argument types
However when I change the foreach line to use uint instead of size_t (I'm on a 32-bit laptop)
foreach(uint i, uint j; zip!(size_t[],size_t[])(a,b)) {
It compiles and runs just fine. What's going on?