是否可以在预处理器指令中使用非类型常量模板参数?这是我的想法:
template <int DING>
struct Foo
{
enum { DOO = DING };
};
template <typename T>
struct Blah
{
void DoIt()
{
#if (T::DOO & 0x010)
// some code here
#endif
}
};
当我尝试使用类似的东西时Blah<Foo<0xFFFF>>
,VC++ 2010 抱怨我们尝试使用的行中的括号不匹配#if
。我猜预处理器对模板一无所知,而这种事情不在它的领域。说啥?