The best way to instantiate templates depends on the programming environment and the capabilities of the programmer. Table 30 lists the template instantiation options and describes advantages and disadvantages of each.
Table 30. Template Instantiation Management Options
CRTCPPMOD Option | Advantages | Disadvantages |
---|---|---|
ILE C++ Default: TEMPLATE(*NONE) TMPLREG(*NONE) |
You do not need to restructure code or file structure In a network environment, you avoid potential file identification problems associated with the ILE C++ TEMPINC option. In a team environment, you avoid file sharing problems associated with the ILE C++ TEMPINC option. In a mixed IFS/Data Management environment, you avoid file system
dependency problems associated with the ILE C++ TEMPINC option.
|
The time required to compile and link an entire application might be dramatically increased because:
If you make any change to the implementation of a template, you must recompile every unit that uses the template. To avoid multiple template definitions, you must manually structure the code so that a single definition is generated for each template class function or static data member. To do this:
|
ILE C++ Template Registry: CRTCPPMOD TEMPLATE(*NONE)
TMPLREG(*DFT)
or CRTCPPMOD TEMPLATE(*NONE) TMPLREG('path-name') |
One template instantiation per application is guaranteed. You do not need to structure programs for automatic instantiation. Minimal manual intervention is required.
|
You might need to manually recompile dependent files whenever a
template insantiation is removed.
|
ILE C++ TEMPINC option: CRTCPPMOD TEMPLATE(*TEMPINC)
TMPLREG(*NONE)
or CRTCPPMOD TEMPLATE('path-name') TMPLREG(*NONE) |
One template instantiation per application is guaranteed. You avoid the longer compilation times that result from using the default. You do not have to recompile all units that use a template whenever that
template implementation is changed.
|
You need to split into separate files implementation of the following:
This option might not be practical in a team programming environment because:
|
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.