Immutable immutable strings??
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Feb 10 10:07:29 PST 2012
I'm not sure whether the following a compiler/language bug or a Phobos
bug, but it's definitely some kind of bug:
auto s = "abc";
immutable t = "def";
writeln(typeid(s)); // immutable(char)[]
writeln(typeid(t)); // immutable(immutable(char)[])
// (what is this supposed to mean?!)
char ch = 'c';
bool b = canFind(s, ch); // OK
bool c = canFind(t, ch); // Compile error??
The compile error is:
test.d:11: Error: template std.algorithm.canFind(alias pred = "a == b",Range,V) if (is(typeof(find!(pred)(range,value)))) does not match any function template declaration
test.d:11: Error: template std.algorithm.canFind(alias pred = "a == b",Range,V) if (is(typeof(find!(pred)(range,value)))) cannot deduce template function from argument types !()(immutable(char[]),char)
Can somebody explain what's going on here?
T
--
There are two ways to write error-free programs; only the third one works.
More information about the Digitalmars-d-learn
mailing list