How to have a const variable in a for loop for the generation of template classes?
问题 I have a code like template <size_t N> class A { template <size_t N> someFunctions() {}; }; Now I want to create instances of the class and call the functions in it in a for loop for a set of many values like // in main() int main() { for (int i = 1; i <= 100; i++) { const int N = i; // dont know how to do this A<N> a; a.functionCalls(); } } How to do this? Hoping for a method to do this. 回答1: This would require something called a template for which is the expected form expansion statements