Template arg deduction

Kevin Bailey keraba at yahoo.com
Wed Jul 7 19:14:52 UTC 2021


I'm trying to use some fairly simple template argument deduction, 
but
maybe I'm not getting the syntax correct. C++ doesn't event blink 
at
something like this, but D is giving me:

temptest.d(18): Error: template temptest.func cannot deduce 
function from argument types !()(bar), candidates are:
temptest.d(10):        func(T)(foo!T.bar f)

I guess D can't crack open a type like that?

```
template foo(T)
{
class bar
{
         T t;
}

}

void func(T)(            // 10
         foo!(T).bar f)
{
}

int main()
{
         foo!int.bar fi;
         func(fi);        // 18
}
```



More information about the Digitalmars-d-learn mailing list