-qtemplatedepth (-ftemplate-depth) (C++ only)
Applicable invocations
Option | xlc (Compiling C) | xlC (Compiling C++) | xlclang (Compiling C) | xlclang++ (Compiling C++) |
---|---|---|---|---|
-qtemplatedepth | ✓ | ✓ | ||
-ftemplate-depth | ✓ |
Note: Only typical invocations are listed in this table. You can refer
to the full list of compiler
invocations for all basic
invocations and their equivalent special invocations.
Category
Pragma equivalent
None.
Purpose
Specifies the maximum number of recursively instantiated template specializations that will be processed by the compiler.
Syntax
Defaults
-qtemplatedepth=300
-ftemplate-depth=256 or -qtemplatedepth=256
Parameters
- number
- The maximum number of recursive template instantiations. The number can be a value in the range of 1 to INT_MAX. If your code attempts to recursively instantiate more templates than number, compilation halts and an error message is issued. If you specify an invalid value, the default value of 300256 is used.
Usage
Note that setting this option to a high value can potentially cause an out-of-memory error due to the complexity and amount of code generated.
Predefined macros
None.
Examples
To allow the following code in
myprogram.cpp
to be compiled successfully:
template <int n> void foo() {
foo<n-1>();
}
template <> void foo<0>() {}
int main() {
foo<400>();
}
Enter:
xlc++ myprogram.cpp -qtemplatedepth=400