c++模板类FAQ

C++模板:究竟什么是特化?
https://www.ibm.com/developerworks/mydeveloperworks/blogs/12bb75c9-dfec-42f5-8b55-b669cc56ad76/entry/c__e6_a8_a1_e6_9d_bf__e7_a9_b6_e7_ab_9f_e4_bb_80_e4_b9_88_e6_98_af_e7_89_b9_e5_8c_96?lang=en
https://www.ibm.com/developerworks/mydeveloperworks/blogs/5894415f-be62-4bc0-81c5-3956e82276f3/entry/c_templates_what_s_all_this_specialization_about_anyway8?lang=en
 
http://blog.csdn.net/pongba/article/details/19130
 
备注: c++ 11引入 extern template(声明模板何时不实例话)来支持分离式编译,vs2012开始支持
 分离式编译关键字export几乎不被主流编译器支持
 
FAQ连接
 
35.1 What's the idea behind templates?
35.2 What's the syntax / semantics for a "class template"?
35.3 What's the syntax / semantics for a "function template"?
35.4 How do I explicitly select which version of a function template should get called?
35.5 What is a "parameterized type"?
35.6 What is "genericity"?
35.7 My template function does something special when the template type T is int or std::string; how do I write my template so it uses the special code when T is one of those specific types?
35.8 Huh? Can you provide an example of template specialization that doesn't use foo and bar?
35.9 But most of the code in my template function is the same; is there some way to get the benefits of template specialization without duplicating all that source code?
35.10 All those templates and template specializations must slow down my program, right?
35.11 So templates are overloading, right?
35.12 Why can't I separate the definition of my templates class from its declaration and put it inside a .cpp file?
35.13 How can I avoid linker errors with my template functions? Updated!
35.14 How does the C++ keyword export help with template linker errors? Updated!
35.15 How can I avoid linker errors with my template classes? Updated!
35.16 Why do I get linker errors when I use template friends?
35.17 How can any human hope to understand these overly verbose template-based error messages?
35.18 Why am I getting errors when my template-derived-class uses a nested type it inherits from its template-base-class?
35.19 Why am I getting errors when my template-derived-class uses a member it inherits from its template-base-class?
35.20 Can the previous problem hurt me silently? Is it possible that the compiler will silently generate the wrong code?
35.21 How can I create a container-template that allows my users to supply the type of the underlying container that actually stores the values?
35.22 Follow-up to previous: can I pass in the underlying structure and the element-type separately?
35.23

Related: all those proxies must negatively reflect on the speed of my program. Don't they?

 

原文链接: https://www.cnblogs.com/starsky/archive/2013/03/22/2974753.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    c++模板类FAQ

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/81595

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月9日 下午8:08
下一篇 2023年2月9日 下午8:09

相关推荐