《C++ Templates 中文版》[陈伟柱译] 续2

 第3部分 模板与设计  
第14章 模板的多态威力  
14.1 动多态  
14.2 静多态  
14.3 动多态和静多态
 14.3.1 术语
 14.3.2 优点和缺点
 14.3.3 将两种多态结合起来  
14.4 新形式的设计模板  
14.5 泛型程序设计  
14.6 本章后记  
第15章 Traits 与Policy类  
15.1 一个实例:累加一个序列
 15.1.1 Fixed Traits  【获得T的相关类型】
 15.1.2 Value Trait  
 15.1.3 参数化trait  
 15.1.4 Policy和Policy类  【参数化运算】
 15.1.5 Trait和Policy:区别在何处?  
 15.1.6 成员模板 和 模板的模板参数  
 15.1.7 组合多个Policies 和/或 Traits  
 15.1.8 运用普通的迭代器进行累积  
15.2 类型函数  
 15.2.1 确定元素的类型  【从实参vector<T>中获得T!trait+部分特化】
 15.2.2 确定class类型  
 15.2.3 引用和限定符  
 15.2.4 Promotion trait  
15.3 Policy Traits  
 15.3.1 只读的参数类型  
 15.3.2 拷贝、交换和移动  
15.4 本章后记 
第16章 模板与继承  
16.1 命名模板参数
【缺省参数机制不错,但当需要改变一个时,不得不提供前面所有参数。如果能a<p3=1>多好!】
虚继承】 

16.2 空基类优化  【空类对象不能为0-->指针数组。有例外】
 16.3.1 布局原则
 16.2.2 成员作基类  
16.3 奇特的递归模板模式 【CRTP能统计构造个数】 
16.4 参数化虚拟性  【虚拟性?virtual】
16.5 本章后记
 
第17章 Metaprograms  【整数计算,枚举常数,递归模板,中止模板】
17.1 Metaprogram的第一个实例  
17.2 枚举值 和 静态常量  【静态常量也可以,枚举值迫使编译器按常数准备,不占内存,所以优选】
17.3 第2个例子:计算平方根  【ifthenelse模板
17.4 使用演绎变量  
17.5 计算完整性  
17.6 递归实例化 和 递归模板实参  
17.7 使用Metaprograms来展开循环 【向量计算取代循环!】
17.8 本章后记 
第18章 表达式模板  
18.1 临时变量和分割循环  
18.2 在模板实参中编码表达式  【用表达式模板实现表达】
 18.2.1 表达式模板的操作数  
 18.2.2 数组类型  
 18.2.3 运算符  
 18.2.4 回顾  
 18.2.5 表达式模板赋值  【用类模板组合成表达式,一次循环计算!】
18.3 表达式模板的性能与约束  
18.4 本章后记
 
第4部分 高级应用程序  
第19章 类型区分  
19.1 辨别基本类型  
19.2 辨别组合类型  
19.3 辨别函数类型  
19.4 运用重载解析辨别枚举类型     
19.5 辨别class类型  
19.6 装配成一个辨别所有类型的函数模板  
19.7 本章后记  
第20章. 智能指针  
20.1 Holders and Trules  
 20.1.1 安全处理异常  
 20.1.2 Holders 
 20.1.3 作为成员的Holders  
 20.1.4 资源获取于初始化  
 20.1.5 Holder的局限  
 20.1.6 复制Holders  
 20.1.7 跨函数调用地复制Holder  
 20.1.8 Trules  
20.2 引用记数  
 20.2.1 计数器在什么地方  
 20.2.2 并发访问计数器  
 20.2.3 析构和释放  
 20.2.4 CountingPtr 模板  
 20.2.5 一个简单的非侵入式计数器  
 20.2.6 一个简单的侵入式计数器模板  
 20.2.7 常数性
 20.2.8 隐式转型
 20.2.9 比较
20.3 本章后记
第21章 Tuples
21.1 Duos
21.2 可递归Duo
 21.2.1 域的个数
 21.2.2 域的类型
 21.2.3 域的值
21.3 Tuple构造
21.4 本章后记
第22章 函数对象和回调  【函数指针、仿函数才是对象,属于回调使用】
22.1 直接调用、间接调用与内联调用
【直接调用(call 地址)vs间接调用(函数地址在内存或寄存器),前者高效】
【编译函数:定义-->带名实体,调用-->带名调用,链接地址】 
【函数指针看不见函数名称,只有生成间接调用】
【模板回调主要是直接调用和内联调用】
【函数数组都decay成指针,(*f)()就是f()】
【多继承必然使得成员函数指针复杂(需要计算偏移),虚函数加剧复杂度】


22.2 函数指针与函数引用  
22.3 成员函数指针  
22.4 class类型的仿函数  
 22.4.1 class类型仿函数的第1个实例  
 22.4.2 class类型仿函数的类型  
22.5 指定仿函数  
 22.5.1 作为模板类型实参的仿函数  
 22.5.2 作为函数调用实参的仿函数 
 22.5.3 结合函数调用参数和模板类型参数  
 22.5.4 作为非类型模板实参的仿函数  
 22.5.5 函数指针的封装  
22.6 内省  
 22.6.1 分析一个仿函数的类型  
 22.6.2 访问参数的类型
 22.6.3 封装函数指针
22.7 函数对象组合
 22.7.1 简单的组合
 22.7.2 混合类型的组合
 22.7.3 减少参数的个数
22.8 值绑定
 22.8.1 选择绑定的目标  
 22.8.2 绑定签名  
 22.8.3 实参选择  
 22.8.4 辅助函数  
22.9 仿函数操作:一个完整的实现 
22.10 本章后记  
附录A 一处定义原则  
A.1 翻译单元  
A.2 声明和定义  
A.3 一处定义原则的细节  
 A.3.1 程序的一处定义约束  
 A.3.2 翻译单元的一处定义约束  
 A.3.3 跨翻译单元的等价性约束  
附录B 重载解析  
B.1 何时应用重载解析  
B.2 简化过的重载解析
 B.2.1 成员函数的隐含实参
 B.2.2 细化完美匹配
B.3重载的细节
 B.3.1 非模板优先 
 B.3.2 转型序列  
 B.3.3 指针的转型  
 B.3.4 仿函数和代理函数  
 B.3.5 其它的重载情况  
参考资料  
术语表 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
《C++ Template》第二版,2017年9月16日出版 Templates are among the most powerful features of C++, but they remain misunderstood and underutilized, even as the C++ language and development community have advanced. In C++ Templates, Second Editi on, three pioneering C++ experts show why, when, and how to use modern templates to build software that’s cleaner, faster, more efficient, and easier to maintain. Now extensively updated for the C++11, C++14, and C++17 standards, this new edition presents state-of-the-art techniques for a wider spectrum of applications. The authors provide authoritative explanations of all new language features that either improve templates or interact with them, including variadic templates, generic lambdas, class template argument deduction, compile-time if, forwarding references, and user-defined literals. They also deeply delve into fundamental language concepts (like value categories) and fully cover all standard type traits. The book starts with an insightful tutorial on basic concepts and relevant language features. The remainder of the book serves as a comprehensive reference, focusing first on language details and then on coding techniques, advanced applications, and sophisticated idioms. Throughout, examples clearly illustrate abstract concepts and demonstrate best practices for exploiting all that C++ templates can do. Understand exactly how templates behave, and avoid common pitfalls Use templates to write more efficient, flexible, and maintainable software Master today’s most effective idioms and techniques Reuse source code without compromising performance or safety Benefit from utilities for generic programming in the C++ Standard Library Preview the upcoming concepts feature The companion website, tmplbook.com, contains sample code and additional updates.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值