C++ Migration Guide

Cfront Link-Time Instantiation

The Sun C++ compiler's implementation of templates is different from that of AT&T's Cfront compiler. Cfront uses link-time instantiation, which uses the following algorithm:

  1. Compile all user source files.

  2. Using the prelinker, ptlink, link all object files created in Step 1 into a partially linked executable.

  3. Examine the link output and instantiate all undefined functions for which there are matching templates.

  4. Link all created templates along with the partially linked executable files from Step 2.

  5. As long as there are undefined functions for which there are matching template functions, repeat Steps 3 through 4.

  6. Perform the final pass of the link phase on all created object files.

The main advantage of link-time instantiation is that no special outside support is required to handle specializations (user-provided functions intended to override instantiated template functions). Only those functions that have not been defined in the user source files become targets of instantiation by the compiler.

The two main disadvantages of link-time instantiation are: