-ftemplate-depth (-qtemplatedepth) (C++ only)
Category
Pragma equivalent
None.
Purpose
Specifies the maximum number of recursively instantiated template specializations that will be processed by the compiler.
Syntax
>>- -f-- -template-depth--=--number----------------------------><
>>- -q--templatedepth--=--number-------------------------------><
Defaults
-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 256 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 -ftemplate-depth=400