Figuring out template argument deduction
Andrej Mitrovic
none at none.none
Fri May 20 15:59:24 PDT 2011
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.
More information about the Digitalmars-d-learn
mailing list