为什么可以';我将std.algorithm.count与谓词函数一起使用
以下代码无法编译:为什么可以';我将std.algorithm.count与谓词函数一起使用,d,phobos,D,Phobos,以下代码无法编译: assert("(((())))()()()()))".count!(c => c.among!('(', ')')) > 0); 出现以下错误消息: "Error: template std.algorithm.searching.count cannot deduce function from argument types !((c) => c.among!('(', ')'))(string), candidates are..." 但是[sta
assert("(((())))()()()()))".count!(c => c.among!('(', ')')) > 0);
出现以下错误消息:
"Error: template std.algorithm.searching.count cannot deduce function from argument types !((c) => c.among!('(', ')'))(string), candidates are..."
但是[standard library()清楚地表明有一个超负荷的count
接受一个谓词,计算谓词返回true的R
的所有元素。那么,当我试图以这种方式使用count
时,为什么编译器会抱怨?断言(((((())())”.count!(c=>c.interest!(“(”(“,”),“)”)!=0)>0);
问题是:
uint
而不是bool
(检查文档中的返回值)
奇怪的是,模板约束明确地说
是(typeof(unaryFun!pred(haystack.front)):bool)
。我本以为是(uint:bool)
会返回true,但我想不会。