www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Figuring out template argument deduction

After reading the Argument Deduction section in
http://d-programming-language.org/template.html for the umpteenth time, I still
don't quite grok how things work.

For example:

template Foo(T1 : T1[], T2) { pragma(msg, T1); }
template Bar(T1 : T2[], T2) { pragma(msg, T1); }

alias Foo!(int[], int) foo;   // T1 = int
alias Bar!(int[], int) bar;   // T1 = int[]

void main() { }

In the docs it says that these cases refer to:
"2. If the type specialization is dependent on a type parameter, the type of
that parameter is set to be the corresponding part of the type argument."

So what does "corresponding part" mean? It sounds so ambiguous that I can't
figure it out.
May 20 2011