关于template 的23个问题

发现新大陆,以前慢慢才知道的东西,原来有个集中营:

看看updated, 处理方式是这么的好

35.1What's the idea behind templates?
35.2What's the syntax / semantics for a "class template"?
35.3What's the syntax / semantics for a "function template"?
35.4How do I explicitly select which version of a function template should get called?
35.5What is a "parameterized type"?
35.6What is "genericity"?
35.7My 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.8Huh? Can you provide an example of template specialization that doesn't use foo and bar?
35.9But 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.10All those templates and template specializations must slow down my program, right?
35.11So templates are overloading, right?
35.12Why can't I separate the definition of my templates class from its declaration and put it inside a .cpp file?
35.13How can I avoid linker errors with my template functions? Updated!
35.14How does the C++ keyword export help with template linker errors? Updated!
35.15How can I avoid linker errors with my template classes? Updated!
35.16Why do I get linker errors when I use template friends?
35.17How can any human hope to understand these overly verbose template-based error messages?
35.18Why am I getting errors when my template-derived-class uses a nested type it inherits from its template-base-class?
35.19Why am I getting errors when my template-derived-class uses a member it inherits from its template-base-class?
35.20Can the previous problem hurt me silently? Is it possible that the compiler will silently generate the wrong code?
35.21How can I create a container-template that allows my users to supply the type of the underlying container that actually stores the values?
35.22Follow-up to previous: can I pass in the underlying structure and the element-type separately?
35.23Related: all those proxies must negatively reflect on the speed of my program. Don't they?



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值