I have a templated C++ function:
template<int i, int j> void foo();
I would like to define it in a .cpp file and instantiate it explicitely. The parameters i and j have the same admissible range of values, from 1 to N included. So far, for a function with a single template parameter such as
template<int i> void foo();
I've been using the Boost Preprocessor library like so:
#define BOOST_PP_LOCAL_MACRO(n)\ template void foo<n>(); #define BOOST_PP_LOCAL_LIMITS (1,N) #include BOOST_PP_LOCAL_ITERATE() This macro expands to N lines with n spanning 1 to N, each instantiating the function for the current value of n.
Is it possible to implement a nested loop using this library? Is it even theoretically possible given how the C preprocessor works?
I have searched for answers on stackoverflow with no success. Question Generate nested for loops using C preprocessor is similar to mine but (unlike the author), I would prefer to use the BOOST_PP lib if possible. My attempts to modify the above macro have been clueless to the point I don't think they are significant.