模板还可以这样递归...
#include <iostream>using namespace std;const unsigned P = 10;template <unsigned P> struct test{ static void func() { cout << "func: " << P << endl; test<P - 1>().func(); }}; struct test<0>{ static void func() { cout << "func0" << endl; }};int main(){ test<P>::func(); return 0;}#include <iostream>using namespace std;const unsigned P = 10;template <unsigned P>struct test{ static void func() { cout << "func: " << P << endl; test<P - 1>::func();//这里直接使用::操作符调用就行了,没必要使用对象调用func静态成员函数了 }};template<>//这里应该是特化struct test<0>{ static void func() { cout << "func0" << endl; }};int main(){ test<P>::func(); return 0;}
[解决办法]
貌似挺實用的~
[解决办法]
学习了
[解决办法]
MPL基础嘛