[英]dmd can't infer type even when type is given
在這里,我想鎖定兩個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));
}
}
但這無法編譯
src/Interpreter.d(30): Error: cannot infer argument types
但是,當我更改foreach行使用uint而不是size_t時(我在32位筆記本電腦上)
foreach(uint i, uint j; zip!(size_t[],size_t[])(a,b)) {
它編譯並運行得很好。 這是怎么回事?
這可能是一個錯誤。 在v2.065.0中它不起作用,但它確實在最新的git-head開發版本中有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.