Reputation:
There are many limits imposed by the C++ standard, such as the maximum amount of function parameters, the maximum length of an identifier or the maximum amount of nested scopes.
What I am curious about is the limit (or the lack of it) of maximum nested template declarations, such as this:
template <template <template < template <template < ...
I heard from someone that it is just two (template <template <typename T> class>
), but that's not the case (at least not with the most recent version of the MSVC compiler).
I am interested, whether there actually is a limit to this and, if there is, what is its value and how did it change between the different releases of the C++ standard.
Upvotes: 4
Views: 318
Reputation: 181057
There is no value imposed by the standard. This is an implementation defined value that will be documented by your compiler. The only direct limit I can find in the standard since there is nothing in [temp.arg.template] is found in [implimits] and it is
- Template parameters in a template declaration ([temp.param]) [1 024].
where 1024 is the recommended minimum number of parameters. This is just a recomendation though, paragraphs 1 and 2:
Annex B (informative) Implementation quantities [implimits]
Because computers are finite, C++ implementations are inevitably limited in the size of the programs they can successfully process. Every implementation shall document those limitations where known. This documentation may cite fixed limits where they exist, say how to compute variable limits as a function of available resources, or say that fixed limits do not exist or are unknown.
The limits may constrain quantities that include those described below or others. The bracketed number following each quantity is recommended as the minimum for that quantity. However, these quantities are only guidelines and do not determine compliance.
emphasis mine
Make that clear.
Upvotes: 4