【发布时间】:2015-10-09 20:22:00
【问题描述】:
以下代码编译失败:
assert("(((())))()()()()))".count!(c => c.among!('(', ')')) > 0);
带有错误信息:
"Error: template std.algorithm.searching.count cannot deduce function from argument types !((c) => c.among!('(', ')'))(string), candidates are..."
但是 [标准库 (http://dlang.org/phobos/std_algorithm_searching.html#.count) 清楚地表明存在count 的重载,它采用谓词,计算谓词返回 true 的 R 的所有元素。那么,当我尝试以这种方式使用count 时,为什么编译器会报错呢?
【问题讨论】: