Function overload with template alias error

André Stein stone-remove at
Sat Dec 24 02:23:21 PST 2011


I'm trying to write a template function which takes a templated alias to 
another type:

struct test(T)

template aliasT(T)
     alias test!(T) aliasT;

void foo(T)(test!T t) { // works

void foo2(T)(aliasT!T t) { // doesn't work

int main(string[] args)
     test!(int) t;
     aliasT!(int) t2;
     foo2(t2); // error
     return 0;

When foo2(t2) is called which takes an alias to test!T as argument I get 
the following error from dmd:

*(21): Error: template variant.foo2(T) does not match any function 
template declaration
*(21): Error: template variant.foo2(T) cannot deduce template function 
from argument types !()(test!(int))

I thought that aliasT!T and test!T have the same internal types and the 
compiler would be able deduce the template parameters. Am I missing 
something or is this a bug in DMD? This is a reduced test case from a 
piece of code where I tried to write an templated overload to 


More information about the Digitalmars-d-learn mailing list