Comment #0 by bearophile_hugs — 2012-09-20T10:17:13Z
Is this supposed to work? If the answer is negative, maybe it's a good idea to support this:
struct Foo(T) {}
void bar(Spam, T)(Spam!T y) {}
void main() {
Foo!int x;
bar(x);
}
DMD 2.061alpha gives:
temp.d(5): Error: template temp.bar does not match any function template declaration
temp.d(5): Error: template temp.bar(Spam,T) cannot deduce template function from argument types !()(Foo!(int))
Comment #1 by k.hara.pg — 2012-09-20T18:18:33Z
(In reply to comment #0)
> Is this supposed to work? If the answer is negative, maybe it's a good idea to
> support this:
>
> struct Foo(T) {}
> void bar(Spam, T)(Spam!T y) {}
> void main() {
> Foo!int x;
> bar(x);
> }
Compiler would infer Spam as a template symbol in IFTI, but it is TemplateTypeParameter. Therefore this doesn't work.
Correct code is here:
struct Foo(T) {}
void bar(alias Spam, T)(Spam!T y) {}
void main() {
Foo!int x;
bar(x);
}
You can receive deduced template symbol by TemplateAliasParamerter. Then all works.