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

Converting Directed Mode to Explicit Instantiation
If you use directed mode instantiation with the cfront based compiler, an awk script
can be used to convert your file to an instantiation file that uses the explicit instantiation
syntax:
Example:
#!/usr/bin/ksh
# For a Directed-Mode Instantiation file that is the parameter
# to the script, create a file that can be compiled with the
# aC++ compiler using the Explicit Instantiation Syntax.
# (Note that this will only work for classes.)
closure_file=$1
closure_file_base_name=${1%\.*}
eis_file=$closure_file_base_name.eis.C
print Output file: $eis_file
# Get all of the include directives.
grep #include $closure_file > /tmp/dmi2eis1.$$
# Collect all of the Directed-Mode Instantiation directives.
grep -v #include $closure_file \
| grep -e > -e < \
| grep -v ( \
| awk {if ($1 != //) {print $0;} } >/tmp/dmi2eis2.$$
# Print the line assuming that the last element is the variable
# name followed immediately by a semi-colon.
awk { n=split($0,sp0);
printf(template class);
for (i=1; i<=(n-1); i++) {
printf( %s, sp0[i]);
}
printf(;\n);
} < /tmp/dmi2eis2.$$ > /tmp/dmi2eis3.$$
cat /tmp/dmi2eis1.$$ /tmp/dmi2eis3.$$ > $eis_file
rm -f /tmp/dmi2eis*.$$
NOTE: You can use explicit instantiation to instantiate a template class and all its
member functions, an individual template function, or a member function of a template
class.
Migration Considerations when Using Templates 287