作者azureblaze (AzureBlaze)
看板Programming
标题Re: [闲聊] 不使用if的写法
时间Tue Jan 8 13:42:53 2013
C++:
template<int>
class YesNo{
public:
static void print(){
printf("no");
}
};
template<>
class YesNo<1>{
static void print(){
printf("yes");
}
};
const int i = 1;
YesNo<i>::print();
YesNo<i-1>::print();
YesNo<Factorial<5>::value>::print();
这题目的需求我觉得只有在compile time处理才有意义...
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 1.171.54.154