[分享] C++ Templates & Generic Programming

看板C_and_CPP作者 (Dan)時間8年前 (2015/11/09 21:56), 編輯推噓8(8011)
留言19則, 10人參與, 最新討論串1/1
本魯近日參加 "Effective C++ 3/e" 讀書會 負責第七章 "Templates & Generic Programming" 和大家分享投影片,請不吝指教 <(_ _)> https://speakerdeck.com/dannvix/c-plus-plus-templates-and-generic-programming 內容包含: - Item 41: Understand implicit interfaces and compile-time polymorphism - Item 42: Understand the two meanings of `typename` - Item 43: Know how to access names in templatized base classes - Item 44: Factor parameter-independent code out of templates - Item 45: Use member function templates to accept "all compatible types" - Item 46: Define non-member function inside templates when type conversion are desired - Item 47: Use traits classes for information about types - Item 48: Be aware of template metaprogramming // 內容較多故字體偏小,建議下載 PDF 以方便閱讀 :P -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.240.178.38 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1447077381.A.DC1.html

11/09 23:14, , 1F
<(_ _)>
11/09 23:14, 1F

11/10 00:10, , 2F
看英文版的哦,好猛
11/10 00:10, 2F

11/10 16:08, , 3F
Thanks for sharing, 有其他章節的投影片嗎?
11/10 16:08, 3F

11/10 16:42, , 4F
感謝!!想要看其他章節+1
11/10 16:42, 4F

11/10 20:05, , 5F
其它章節是別人做的,就無法分享囉 :P
11/10 20:05, 5F

11/11 09:25, , 6F
我還滿想了解 item 23的XD
11/11 09:25, 6F

11/11 09:57, , 7F
程式寫的好,要飯要到老
11/11 09:57, 7F

11/13 00:36, , 8F
http://ideone.com/MDCjDK 請問這為什麼選擇c而不是
11/13 00:36, 8F

11/13 00:36, , 9F
b呢?
11/13 00:36, 9F

11/13 00:37, , 10F
appendix好像有寫說他要找最特化的? 那應該找b不是?
11/13 00:37, 10F

11/13 00:38, , 11F
還有最後一頁的 最後一點 The primaray template....
11/13 00:38, 11F

11/13 00:39, , 12F
only那部份英文不太理解, 是說以有特化以特化為優先?
11/13 00:39, 12F

11/13 15:23, , 13F
11/13 15:23, 13F

11/13 22:47, , 14F
因為它把 b 當作是 a 的 specialization
11/13 22:47, 14F

11/13 22:53, , 15F
and c is more specialized than a
11/13 22:53, 15F

11/15 10:31, , 16F
b不是全特化嗎?怎會輸c
11/15 10:31, 16F

11/15 12:53, , 17F
但它們都是 template 要先依 partial ordering 比較 a & c
11/15 12:53, 17F

11/15 12:54, , 18F
若 a 勝 c 結果就會選 b, 但是現在 c 比 a 特殊.
11/15 12:54, 18F

02/01 23:43, , 19F
02/01 23:43, 19F
文章代碼(AID): #1MGAO5t1 (C_and_CPP)