Template argument deduction
Tom
tom at nospam.com
Mon Feb 28 19:39:15 PST 2011
I have...
import std.stdio;
int main(string[] args) {
foo([[1,2],[3,4],[5,6]]); // ERROR [1]
bar([[1,2],[3,4],[5,6]]); // OK
foo!int([[1,2],[3,4],[5,6]]); // OK
return 0;
}
void foo(T)(T[2][] t) {
writeln(typeid(t));
}
void bar(T)(T[][] t) {
writeln(typeid(t));
}
[1]
src\main.d(4): Error: template main.foo(T) does not match any function
template declaration
src\main.d(4): Error: template main.foo(T) cannot deduce template
function from argument types !()(int[][])
Why can't compiler deduce template parameters from arguments in the
first instantiation?
Thanks in advance,
Tom;
More information about the Digitalmars-d-learn
mailing list