| |
| | Type Inference |
 | | If further inference shows that x1 has the "real" type of X, then it is also known that "type a" is actually X, and that x2 is therefore also of type X, and so on. |
 | | That is not type inference, that is still just type specialization; when the compiler looks at the instantiation of add(T1, T2), it doesn't have to do any analysis whatsoever to discover that T1=int, T2=double, because that is simply the types of what was passed to add(). |
 | | A similar language with actual type inference might see that x and y are double, since they are used that way after the template instantiation, and given that knowledge, work backwards to see that add() should be specialized on (double, double). |
| c2.com /cgi/wiki?TypeInference (1932 words) |
|