How many maximum depedent types are supported?

Viewed 53

This is just my curiosity to understand more about C++ behavior. It's somehow not realistic. As I know for template it could be declared with a type which depends on another type For example vector<T> T can be any type and so T can continue depending on something else. So when will it end up with a limit such as an error raised by compiler ?? This also has the same understanding as recursive function Anyway I might be wrong

1 Answers

The C++ standard does not set a limit for template recursion depth, but it does recommend a minimum limit of 1024.

Some code (e.g. Boost Spirit, PyBind) can approach this limit with complicated grammars or Python bindings. You could also attain it trivially with some metaprogramming.

With GCC, you can control the recursion limit by passing

-ftemplate-depth=X
Related