[問題] 關於contructor template的兩個問題
Code :
http://codepad.org/mTAG98oV
編譯環境是VC 2008 SP1
我想問題問題有兩個
1、
第36行開始的全特化compile不過
錯誤訊息:
C2143: syntax error : missing ';' before '<'
嗯..後面幾個不重要,總之是syntax error
以前面的function template foo為例,全特化的模板參數可寫可不寫
不寫的話compiler會幫你推導
但是在constructor template,不寫會過(code 31行)
寫了反而會compile error..這是什麼巫術!?
2、
第43行 compile error
MyTest test(true, true);
因為沒有這個constructor
這我可以理解,第5行的template根本沒有instantiation
我想問題問題是,有什麼方法可以explicit instantiation這個template嗎?
MyTest test<bool>(true, true); 也會syntax error..
當然如果像第10行那樣,參數列上有typename,就能deduce出來
但是像第5行的template有辦法explicit instantiation嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.45.171.80
→
08/26 01:07, , 1F
08/26 01:07, 1F
→
08/26 01:08, , 2F
08/26 01:08, 2F
→
08/26 01:10, , 3F
08/26 01:10, 3F
→
08/26 01:10, , 4F
08/26 01:10, 4F
→
08/26 01:24, , 5F
08/26 01:24, 5F
→
08/26 01:24, , 6F
08/26 01:24, 6F
→
08/26 01:25, , 7F
08/26 01:25, 7F
推
08/26 01:28, , 8F
08/26 01:28, 8F
→
08/26 01:30, , 9F
08/26 01:30, 9F
→
08/26 01:31, , 10F
08/26 01:31, 10F
→
08/26 01:46, , 11F
08/26 01:46, 11F
→
08/26 02:01, , 12F
08/26 02:01, 12F
→
08/26 02:04, , 13F
08/26 02:04, 13F
→
08/26 02:08, , 14F
08/26 02:08, 14F
→
08/26 02:13, , 15F
08/26 02:13, 15F
→
08/26 08:18, , 16F
08/26 08:18, 16F
→
08/27 10:15, , 17F
08/27 10:15, 17F
→
08/28 05:55, , 18F
08/28 05:55, 18F
→
08/28 05:56, , 19F
08/28 05:56, 19F
→
08/28 11:34, , 20F
08/28 11:34, 20F
→
08/28 11:35, , 21F
08/28 11:35, 21F
→
08/28 11:37, , 22F
08/28 11:37, 22F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章