-ftemplate-depth (-qtemplatedepth) (C++ only)

Pragma equivalent

None.

Purpose

Specifies the maximum number of recursively instantiated template specializations that will be processed by the compiler.

Syntax

Read syntax diagramSkip visual syntax diagram
>>- -f-- -template-depth--=--number----------------------------><

Read syntax diagramSkip visual syntax diagram
>>- -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 between 1 and 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

Related information



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us