Comment #0 by bearophile_hugs — 2012-12-25T01:59:17Z
import std.array: join;
void main() {
string[] names1;
auto r1 = names1.join(); // OK
immutable string[] names2;
auto r2 = names2.join(); // error
}
DMD 2.061alpha gives:
test.d(6): Error: template std.array.join does not match any function template declaration. Candidates are:
...\dmd2\src\phobos\std\array.d(1441): std.array.join(RoR, R)(RoR ror, R sep) if (isInputRange!(RoR) && isInputRange!(ElementType!(RoR)) && isForwardRange!(R) && is(Unqual!(ElementType!(ElementType!(RoR))) == Unqual!(ElementType!(R))))
...\dmd2\src\phobos\std\array.d(1451): std.array.join(RoR)(RoR ror) if (isInputRange!(RoR) && isInputRange!(ElementType!(RoR)))
...\dmd2\src\phobos\std\array.d(1441): Error: templte std.array.join cannot deduce template function from argument types !()(immutable(char[][]))a
Comment #1 by hsteoh — 2013-01-03T20:16:40Z
This is because popFront() is not defined for an immutable array, so isInputRange!(typeof(names2)) is false.
I don't know how one could get around this problem, since an immutable array is, by definition, immutable, so popFront() cannot possibly be valid on such an array.
Comment #2 by hsteoh — 2013-01-03T20:19:10Z
It doesn't work for immutable(string)[] either, because join() requires the elements to be input ranges as well, but immutable(string) cannot have popFront() defined since it's immutable.
Comment #3 by bearophile_hugs — 2013-09-21T05:27:00Z
*** This issue has been marked as a duplicate of issue 7690 ***