HP aC++/HP C Programmer's Guide (B3901-90036; A.06.26; September 2011)
// explicitly
// instantiate
// the
// sort<char> ()
// template
// function
// NOTE <char> is not required if
// the compiler can deduce this.
void foo() {
Array <int> ai;
sort(ai); // use of the sort<int> ()
} // template function which
// results in implicit instantiation
NOTE: All template options on an aCC command-line apply to every file on the
command line.
If you specify more than one option on a command-line, only the last option takes effect.
For More Information, refer to the ANSI/ISO C++ International Standard for additional
details including explicit specialization syntax.
Command-Line Option Instantiation
See “Template Options” (page 110) for more information on command-line instantiation.
Compile-Time Instantiation
By default, compile-time instantiation is in effect. Instantiation is attempted for any use
of a template in the translation unit where the instantiation is used. All used template
functions, all static data members and member functions of instantiated template classes,
and all explicit instantiations are instantiated in the resulting object file.
If there are duplicate instantiations at link-time, the linker arbitrarily selects an instantiation
for inclusion in the a.out or shared library.
The following command-lines are equivalent; each compiles a.C using compile-time
instantiation.
aCC -c +inst_compiletime a.C
aCC -c a.C
Why Use Compile-Time Instantiation
Compile-time instantiation is the default. It is easy to use. Your code may compile faster
when using compile-time instantiation.
166 Using HP aC++ Templates