Inferring function argument types from other argument types

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Tue Nov 13 08:39:42 PST 2012


On 11/13/2012 05:05 PM, Vijay Nayar wrote:
> I believe this question was asked before, but here is the solution again.

The actual reality of what I'm trying to do is slightly more complex: it's more like

     struct Foo(_T1, _T2)
     {
         alias _T1 T1;
         alias _T2 T2;
         // etc.
     }

     FooT.T1 func(FooT, T)(FooT foo, T x)
     {
         return func2(x);
     }

... where func2() is also a templated function, and it's important that it take 
a type of FooT.T1 and not T.

So, I can't see what the solution is apart from casting x to FooT.T or 
explicitly indicating FooT.T1 as a template parameter for func2.


More information about the Digitalmars-d-learn mailing list