The diagram in section 8.1, page 388 shows that the type template list can have extra specifiers for the types. This is especially useful for object types: if the template type must descend from a certain class, then this can be specified in the template list:
Given the above definition, the following will compile:
But this will not compile
The compiler will return an error:
Multiple types can be grouped together:
Additionally, it is possible to specify more than one type identifier for class and interface type restrictions. If a class is specified, then the type used for the template must be equal to or descend from the indicated type:
A class used to specialize T must descend from TComponent and must implement IEnumerable.
If an interface is specified, then the template type must implement at least this interface, but it can also be a descendent interface from this interface:
Multiple interfaces can be specified, in that case the class type must implement all listed interfaces: It is possible to mix one class name with several interface names.
If no type restrictions are in effect, the compiler will assume that template types are not assignment compatible.
This is specially important when the generic class contains overloaded methods. Given the following generic type declaration:
Specializing the above will compile if T1 and T2 are of two different types and neither is also LongInt. The following will compile:
But the following 2 will not compile: