[英]dmd can't infer type even when type is given
Here I want to lockstep iterate over two arrays of size_t 在这里,我想锁定两个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而不是size_t时(我在32位笔记本电脑上)
foreach(uint i, uint j; zip!(size_t[],size_t[])(a,b)) {
It compiles and runs just fine. 它编译并运行得很好。 What's going on?
这是怎么回事?
It might be a bug. 这可能是一个错误。 In v2.065.0 it doesn't work, but it does work in the latest git-head development version.
在v2.065.0中它不起作用,但它确实在最新的git-head开发版本中有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.