This code compiles: import std.algorithm; void main() { string str = "abc123"; auto i = countUntil!((a, b){return (a >= '0' && a <= '9') || a == '.';}) (str, 0); } It shouldn't. Notice that the second argument to countUntil is 0, which is an int, not a range.
Are you sure that this is a bug? The documentation says that it counts until haystack.startsWith!pred(needle) is true, and startsWith is also defined for single element needles. You are right, the usefulness of this behavior is questionable, though.
Okay. I misunderstood countUntil. Its signature is sizediff_t countUntil(alias pred = "a == b", R1, R2)(R1 haystack, R2 needle) if (is(typeof(startsWith!pred(haystack, needle)))) Of course, I didn't see the template constraint in the documentation, and given the type names, I assumed that needle had to be a range. My mistake. There's no problem with this code.
The real issue here IMHO is the fact that 0 implicitly converts to a dchar, but that's not going to change anytime soon. The original code that I copied this from was doing that though. I wouldn't normally put a 0 there. In any case, this isn't a bug.