On Saturday, 11 October 2014 at 18:01:41 UTC, Uranuz wrote:
When I want to pass generic String by const reference I get an
error. As far as I understand const should accept both mutable
and immutable data. And there I want to pass it by reference.
Is it possible? Or is there any reason why it is not? Is it a
bug?
void doSmth(String)(ref const(String) str) {}
void main()
{
doSmth("Foo");
}
Compilation output:
/d198/f399.d(5): Error: template f399.doSmth does not match any
function template declaration. Candidates are:
/d198/f399.d(1): f399.doSmth(String)(ref const(String)
str)
/d198/f399.d(5): Error: template f399.doSmth(String)(ref
const(String) str) cannot deduce template function from
argument types !()(string)
Try doSmth!String("bla");
Also, the type is string, not String ?