HP aC++/HP C A.06.25 Programmer's Guide
Migration Considerations when Using Templates
In HP aC++, templates are processed differently than in HP C++ (cfront). HP aC++ does
not have a repository. All instantiations are placed in an object (.o) file (with additional
information in a .Ia file if you specify the +inst_auto command-line option). You
cannot modify these files as was possible with the files in a repository.
See Chapter 5: “Using HP aC++ Templates” (page 173) for more information.
To begin migrating code containing templates to HP aC++, try to compile and link
using the default compile-time instantiation. If this fails with compilation errors, you
can compile using one of the following:
• The +inst_all option to view all compile-time errors, including template
instantiation errors. This may generate errors that will not occur in your program,
because the draft standard allows template parameters that cannot instantiate all
members. The +inst_all option forces instantiation of such members.
• The +inst_directed option to mask compile-time template instantiation errors.
To reset after all translation units compile successfully:
1. Remove any .o and .I files. Using a clobber makefile target to remove .I files is
similar to removing the ptrepository directory in cfront.
2. Recompile and link using compile-time instantiation.
Verbose Template Processing Information
Use the +inst v option to replace the cfront -ptv option tp process verbose template
information.
Common Template Migration Syntax Changes
You must use the keyword typname to distinguish types in template code in HP aC++.
Also, use the this-> notation to reference data members.
The cfront Implicit Include Convention
The preferred method for specifying template declarations and definitions in HP aC++
is to put declarations and definitions in the same file.
In HP C++ (cfront), for any .h file that contains template declarations, there is a .c file
that contains definitions for those templates.
HP aC++ provides the following options to ease migration from HP C++ (cfront):
• +inst implicit_include: This option instructs the compiler to use the cfront
default file, name lookup, for template definition files.
• +inst include_suffixes: Use this option to replace the cfront -ptS"list"
option. This specifies file name extensions for template definition files.
288 Migrating from HP C++ (cfront) to HP aC++