Given a set of template functions and classes,
template <int dim>
class A;
template <int dim>
void F();
is it possible to define a macro MULTIDIM
that would do explicit instantiation of these templates for multiple values of parameter dim
(e.g. dim=1
and dim=2
)?
For example,
MULTIDIM(
template class A<DIM>;
template void F<DIM>();
)
is supposed to instantiate the same entities as
template class A<1>;
template void F<1>();
template class A<2>;
template void F<2>();
One way to define it could be something like
#define MULTIDIM(x) \
constexpr int DIM = 1; x \
constexpr int DIM = 2; x
but obviously this is not valid since both definitions of DIM
are
in the same scope.