Re: [閒聊] 不使用if的寫法

看板Programming作者 (AzureBlaze)時間12年前 (2013/01/08 05:42), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串8/18 (看更多)
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
文章代碼(AID): #1Gwx7V5L (Programming)
討論串 (同標題文章)
文章代碼(AID): #1Gwx7V5L (Programming)