On Sat, 19 Feb 2011 16:23:12 -0500, Jacob Carlborg <[email protected]> wrote:
Compiling the following code with DMD 2.052 on Mac OS X:
import std.array;
void main ()
{
char[] a;
char[] b;
a.replace(1, 3, b);
}
Results in the following error:
test.d(7): Error: template std.array.replace(T,Range) if
(isDynamicArray!(Range) && is(ElementType!(Range) : T)) does not match
any function template declaration
test.d(7): Error: template std.array.replace(T,Range) if
(isDynamicArray!(Range) && is(ElementType!(Range) : T)) cannot deduce
template function from argument types !()(char[],int,int,char[])
What am I doing wrong or isn't std.array.replace supposed to work with
char[]?
D currently suffers from a form of schizophrenia. in Phobos, char[] and
wchar[] (and related const/immutable versions) are *NOT* treated as arrays
of char and wchar. They are treated as bi-directional ranges of dchar.
The compiler does not see it this way, it thinks they are arrays.
The error in your assumption is that Range's element type is char, when in
fact it is dchar (Range is the type of the second char[]). So the
is(ElementType!(char[]) : char) fails.
-Steve