c++模板元编程模板的模板参数

代码如下:

/* [email protected] www.gaimo.net 02.15.2009 */ //dev c++ #include #include //#include //#include //#include using namespace std; template class F> struct accumulate { enum {RET = accumulate::RET + F::RET}; }; template class F> struct accumulate<0,F> { enum { RET = F<0>::RET }; }; template struct square { enum { RET = n*n }; }; int main(int argc, char *argv[]) { cout << accumulate<5,square>::RET << endl; system("PAUSE"); return EXIT_SUCCESS; }

你可能感兴趣的:(c++,模板元编程,核动力机器人代码)