https://issues.dlang.org/show_bug.cgi?id=8851

--- Comment #15 from [email protected] ---
(In reply to Andrej Mitrovic from comment #14)
> import std.string;
> 
> void main()
> {
>     char sep = '|';
>     string z = ["foo", "bar"].join(sep.only);
> }

I'll assume you also imported std.range, and got this error?
Error: template std.array.join cannot deduce function from argument types ...

It seems the issue here is that the template restrictions are overzealous in
that it checks for exact element type matching, rather than checking if they
have a common type (Or at the very least, if ElementType!Sep is implicitly
convertible to ElementType!(ElementType!RoR)).

As a workaround, using an (explicit) dchar only works.

//----
import std.range;
import std.stdio;

void main()
{
    ["foo", "bar"].join(dchar('|').only).writeln();
}
//----

So Jonathan's original
assesment(https://issues.dlang.org/show_bug.cgi?id=8851#c1) was also correct
(it's a dual issue I guess)

--

Reply via email to