HP aC++/HP C A.06.20 Programmer's Guide

Following is the overview of template processing:During compile-time instantiation,
the compiler instantiates every template entity it sees in a translation unit provided it
has the required template definition
The compiler places an instantiation in every .o file in which a template is used
and its definition is known. The linker arbitrarily chooses a .o file to satisfy an
instantiation request. Only the chosen instantiation appears in the a.out or .so
file. Any redundant instantiations in other .o files are ignored.
No instantiation information is placed in object (.o) files. The linker is responsible
for ignoring duplicate instantiations.
No .I files are created. All .o files are compiled only once.
Explicit Instantiation
You request explicit instantiation by using the explicit template instantiation syntax
(as defined in the ANSI/ISO C++ International Standard) in your source file.
You can request explicit instantiation of a particular template class or a particular
template function. In addition, member functions and static data members of class
templates may be explicitly instantiated.
Explicit instantiation of a class instantiates all member functions and static data members
of that class, regardless of whether or not they are used.
For example, following is a request to explicitly instantiate the Table template class
with char*:
template class Table<char*>;
When you specify an explicit instantiation, you are asking the compiler to instantiate
a template at the point of the explicit instantiation in the translation unit in which it
occurs.
Usage
This might be useful when you are building a library for distribution and want to create
a set of compiler-generated template specializations that you know will most commonly
be used. Then when an application is linked with this library, any of these commonly
used specializations need not be instantiated.
Another scenario might be a frequently used library that contains a repository of
template specializations for your development team. Instantiating all such specializations
in one, known translation unit would allow easy maintenance when changes are needed
and eliminate cases of duplicate definition.
Performance
Although time is required to analyze and design code for explicit instantiation,
compilation may be faster than for the equivalent implicit instantiation.
170 Using HP aC++ Templates