代码在这里。编译器是 VC++ 2012。
template<class T> // Normal class is okay. But template has the problem.
class A
{
const static unsigned N = 2; // not okay
// enum {N = 2}; // this is okay
template<unsigned i> void Fun() {}
template<> void Fun<N>() {} // error C2975 not constant expression
};
为什么?谢谢。