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

template void sort<char> (Array <char>&); // request to
// 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 118) 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
172 Using HP aC++ Templates