I am compiling this code with g++ version 3.4.4 on windows:-
#include <iostream>
template< int i >
class LOOP{
public:
static inline void EXEC(int* count){
(*count)++;
LOOP< i-1 >::EXEC(count);
}
};
template<> class LOOP< 0 >{
public:
static inline void EXEC(int* count){
(*count)++;
}
};
int main(int i){
int barely = 0;
LOOP< 1000 >::EXEC(&barely);
}
It complains, incomplete type LOOP<500> used in nested name specifier and has a list of the previous instantiations before it, “instantiated from static void LOOP::EXEC(int *) with i – 1000” and so on.
When I change it to LOOP<100> it compiles fine though.
EDIT I am running this on cygwin if that affects the implementation limits.
You hit the implementation’s template depth limit. You can increase the limit by compiling with
-ftemplate-depth=1005(modern GCC) or-ftemplate-depth-1005(older GCC).