Technical data

Cray Standard C/C++ Reference Manual
instantiation of template entities until all source files of the complete program
have been read.
The Cray Standard C++ compiler provides an instantiation mechanism that
performs automatic instantiation at linkage and provides command line options
and
#pragma directives that give the programmer more explicit control over
instantiation.
6.1 Automatic Instantiation
The goal of an automatic instantiation mode is to provide trouble-free
instantiation. The programmer should be able to compile source files to object
code, link them and run the resulting program, without questioning how the
necessary instantiations are done.
In practice, this is difficult for a compiler to do, and different compilers
use different automatic instantiation schemes with different strengths and
weaknesses.
The Cray Standard C++ compiler requires a normal, top-level, explicitly
compiled source file that contains the definition of both the template entity and of
any types required for the particular instantiation. This requirement is met in
one of the following ways:
Each .h file that declares a template entity also contains either the definition
of the entity or includes another file containing the definition.
When the compiler sees a template declaration in a .h file and discovers a
need to instantiate that entity, implicit inclusion gives the compiler permission
to search for an associated definition file having the same base name and a
different suffix and implicitly include that file at the end of the compilation
(see Section 6.5, page 116).
The programmer makes sure that the files that define template entities also
have the definitions of all the available types and adds code or directives in
those files to request instantiation of those entities.
Automatic instantiation is accomplished by the Cray Standard C++ compiler
as follows:
1. The first time the source files of a program are compiled, no template entities
are instantiated. However, the generated object files contain information
about things that could have been instantiated in each compilation. For any
source file that makes use of a template instantiation, an associated .ti file is
110 S217936