splitter string/char different behavior

Jon Degenhardt jond at noreply.com
Sat Sep 30 20:18:25 UTC 2017


On Saturday, 30 September 2017 at 17:17:17 UTC, SrMordred wrote:
> writeln( "a.b.c".splitter('.').dropBack(1) ); //compiles ok
> writeln( "a.b.c".splitter(".").dropBack(1) );
>
> //error:
> Error: template std.range.dropBack cannot deduce function from 
> argument types !()(Result, int), candidates are:
> (...)
>
> Hm.. can someone explain whats going on?

Let's try again. I'm not sure the full explanation, but likely 
involves two separate template overloads being instantiated, each 
with a separate definition of the return type.

* "a.b.c".splitter('.') - This overload: 
https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d#L3696-L3703

* "a.b.c".splitter(".") - This overload: 
https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d#L3973-L3982

But why one supports dropBack and the other doesn't I don't know.


More information about the Digitalmars-d-learn mailing list