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

Applicable invocations

Table 1. Invocations that accept the given options
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

Template control

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

XL-based front end begins-qtemplatedepth=300XL-based front end ends

Clang-based front end begins-ftemplate-depth=256 or -qtemplatedepth=256Clang-based front end ends

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 XL-based front end begins300XL-based front end endsClang-based front end begins256Clang-based front end ends 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

Related information