templateregistry

Applies to C++

Purpose

Maintains records of all templates as they are encountered in the source and ensures that only one instantiation of each template is made.

Syntax

        .-templateregistry--+------------------+-.
        |                   '-=--registry_file-' |
>>- -q--+-notemplateregistry---------------------+-------------><
 
 

Notes

The -qtempinc and -qtemplateregistry compiler options are mutually exclusive. Specifying -qtempinc implies -qnotemplateregistry. Similarly, specifying -qtemplateregistry implies -qnotempinc. However, specifying -qnotempinc does not imply -qtemplateregistry.

The -qtemplateregistry option maintains records of all templates as they are encountered in the source, and ensures that only one instantiation of each template is made. The first time that the compiler encounters a reference to a template instantiation, that instantiation is generated and the related object code is placed in the current object file. Any further references to identical instantiations of the same template in different compilation units are recorded but the redundant instantiations are not generated. No special file organization is required to use the -qtemplateregistry option.

If you do not specify a location, the compiler will save all template registry information to the file templateregistry stored in the current working directory. Template registry files must not be shared between different programs. If there are two or more programs whose source is in the same directory, relying on the default template registry file stored in the current working directory will result in this situation, and may lead to incorrect results.

Example

To compile the file myprogram.C and place the template registry information into the /tmp/mytemplateregistry file, enter:

 xlc++ myprogram.C -qtemplateregistry=/tmp/mytemplateregistry

Related References

Compiler Command Line Options
templaterecompile
tempinc

See also Using C++ templates. IBM Copyright 2003