Given a pattern like
template<int dim> class Point { ... };
this template can be created explicitly as
template class Point<0>; template class Point<1>; template class Point<2>; template class Point<3>;
instead of instantiating each template individually as above, I would like to create recursive instances with a single call of type
template class RecursiveInstantiate<Point, 3>;
where RecursiveInstantiate<T, i> will instantiate T<i> , T<i-1> , ..., T<0> . How can I create such a RecursiveInstantiate class? If this is not possible, do you know how to do this with a preprocessor?
Actually, I'm interested in generalizing this for classes with several template parameters, such as Node<int i1,int i2,int i3> for all combinations i1, i2, i3 in {0,1,2,3}. But I hope that I can independently work out this second part.
Any advice is welcome, along with an explanation of why this is not possible, what I want to achieve.
Update: Thank you for your comments. Now I see more clearly where the problem really is. Line
template class Point<3>;
creates an instance of the template and exports its characters to the object file. Form implementation
template class RecursiveInstantiate<Point, 3>;
can create instances of classes class Point<3> , class Point<2> , .... Apparently, this happens only locally. Templates are not exported to the object file. I may have to look for a solution using a preprocessor.
As I see now, I did not ask my question accurately enough at the beginning, I appreciate your answers and those chosen as correct.
Note: I am trying to use this on linux with g ++ / clang as compilers.