是否可以在预处理程序指令中使用非类型常量模板参数?这就是我的想法:
template <int DING>
struct Foo
{
enum { DOO = DING };
};
template <typename T>
struct Blah
{
void DoIt()
{
#if (T::DOO & 0x010)
// some code here
#endif
}
};
Run Code Online (Sandbox Code Playgroud)
当我尝试使用类似的东西时Blah<Foo<0xFFFF>>,VC++ 2010会抱怨我们尝试使用的行中无法匹配的括号#if.我猜测预处理器并不真正知道任何关于模板的事情,这种事情只是不在其领域.说啥?