Re: [閒聊] 不使用if的寫法
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
討論串 (同標題文章)
完整討論串 (本文為第 8 之 18 篇):