直接上例子:
template <bool>
struct StaticCheck { StaticCheck(...);};
template <>
struct StaticCheck<false> {};
bool f =false;
StaticCheck<f>();
报错: Error 1 error C2971: 'StaticCheck' : template parameter 'unnamed-parameter' : 'f' : a local variable cannot be used as a non-type argument y:/projects/c++/ht/ht.cpp 55 HT
可见一个变量无法做模板参数.
将f将为 const bool, 问题解决