无论is_ar为多少,始终输出 "not"
[cpp]
template//ant::is_arithmetic::value >
class Test
{
public:
void test()
{
#if is_ar
cout<<"is\n";
#elif !is_ar
cout<<"not\n";
#endif
cout<<"is_arr="<
}
};
为什么?
可能原因:
#elif 是预处理过程中解析的,不做表达狮的估值
不过要实现倒可以这样写(但麻烦多了):
[cpp]
template::value >
class Test
{
public:
void test()
{
cout<<"not\n";
}
};
[cpp]
template
class Test
{
public:
void test()
{
cout<<"is\n";
}
};