模板元编程例子

#include <iostream>
#include<string>
using namespace std;


template<int N>
class Pow3{
public:
    static const int result = 3 * Pow3<N-1>::result;
};

template < >
class Pow3<0>{
public:
    static const int result =1;
};

int main(int argc, char *argv[]){
    cout << "Pow3<2>::result= "<< Pow3<2>::result << endl;
    return 0;
}

  

简直就是SQL中的语法分析

posted @ 2018-08-06 19:31  友哥  阅读(127)  评论(0编辑  收藏  举报