Once a generic class is defined, it can be used to generate other classes: this is like replaying the definition of the class, with the template placeholders filled in with actual type definitions.
This can be done in any Type definition block. The specialized type looks as follows:
_________________________________________________________________________________________________________
Specialized type
___________________________________________________________________
Which is a very simple definition. Given the declaration of TList in the previous section, the following would be a valid type definition:
The following is not allowed:
that is, a variable cannot be directly declared using a specialization.
The type in the specialize statement must be known. Given the 2 generic class definitions:
Then the following specialization is not valid:
because the type TMyFirstType is a generic type, and thus not fully defined. However, the following is allowed:
because TA is already fully defined when TB is specialized.
Note that 2 specializations of a generic type with the same types in a placeholder are not assignment compatible. In the following example:
variables of types TA and TB cannot be assigned to each other, i.e the following assignment will be invalid:
Remark: It is not possible to make a forward definition of a generic class. The compiler will generate an error if a forward declaration of a class is later defined as a generic specialization.