Question about explicit template instantiation

bearophile bearophileHUGS at lycos.com
Sun Feb 10 14:54:09 PST 2008


Edward Diener:
> Thanks for the information but I await your and Janice's response about 
> what a template instantiation is.

The situation is rather simple. A D template is a section of code that is parametric in one or more types. Just like a function is a piece of code that is parametric on the value of some types (the situation isn't fully symmetric because in D types aren't first class values yet, but they are close enough for many purposes). Inside that section you can put what you want, types that depend of the template types, classes that are depends of the template types (that you can think as variables), etc. When you instantiate a type you give the value to those type variables, so you just define what types those "type variables" are, so you define real pieces of code, for functions, classes, etc, that you can take a pointer of, you can instantiate, you can call, etc. Before that, they are "virtual", generic, not even fully cheeked by the compiler. As time passes, D types become a bit more and more first class, that allows you to operate on them in more ways (at compile time).

Bye,
bearophile



More information about the Digitalmars-d mailing list