C++ Migration Guide

Chapter 5 Migrating From C++ 3.0 to C++ 5.0

This chapter discusses the migration of working code from a C++ 3.0 or 3.0.1 compiler directly to the C++ 5.0 compiler.

Keywords Added Since the C++ 3.0 Compiler

The following keywords have been added to C++ since the C++ 3.0 compiler. If you use any of these as identifiers, you should change the names. As shown in Table 3-1, some keywords can be turned off in C++ 5.0.


bool, false, true
const_cast, dynamic_cast, reinterpret_cast, static_cast
explicit
export
mutable
namespace, using
typename
wchar_t

Source Code Incompatibilities

The following list describes changes that must be made to code that was written for the C++ 3.0 compiler before compiling the code with the C++ 5.0 compiler.

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: