HP aC++/HP C Programmer's Guide (B3901-90036; A.06.26; September 2011)
5 Using HP aC++ Templates
The following sections overview template processing and describe the instantiation coding
methods available to you.
• “Invoking Compile-Time Instantiation” (page 163)
• “Scope and Precedence” (page 163)
• “Template Processing” (page 163)
• “Explicit Instantiation” (page 164)
• “Command-Line Option Instantiation” (page 166)
• “Compile-Time Instantiation” (page 166)
• “Migrating from Automatic Instantiation to Compile-time Instantiation” (page 167)
• “C++ Template Tutorial” (page 168)
Invoking Compile-Time Instantiation
There are three methods of invoking compile-time instantiation:
• Explicit Instantiation (developer-directed)
• Command-Line Option Instantiation (developer-directed)
• Compile-Time Instantiation (default)
Scope and Precedence
Explicit instantiation provides instantiation for a particular template class or template
function. While command line options and the default compile-time instantiation provide
instantiation at the level of the translation unit.
If you use explicit instantiation in addition to command-line options or default instantiation,
explicit instantiation takes precedence.
For example, using the +inst_compiletime option requests instantiation of all used
template functions and all static data members and member functions of instantiated
template classes within a translation unit. Using explicit instantiation requests instantiation
of all members of a particular template class or a particular template function.
Template Processing
In HP aC++, compile-time instantiation is the default template instantiation mechanism.
During compile-time instantiation, the compiler instantiates every template entity it sees
in a translation unit provided it has the required template definition.
Invoking Compile-Time Instantiation 163