menu 简单麦麦
account_circle

C++模板:完整的指南-C++ Templates: The Complete Guide

帮助2606人找到了他们想要的文件
上传于 2020-02-28 0次下载 4900次浏览
文件编号:1967
文件详情
标题(title):C++ Templates: The Complete Guide
C++模板:完整的指南
作者(author):David Vandevoorde, Nicolai M. Josuttis, Douglas Gregor
出版社(publisher):
大小(size):3 MB (3185275 bytes)
格式(extension):pdf
注意:如果文件下载完成后为无法打开的格式,请修改后缀名为格式对应后缀

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 Edition, 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.
Table of contents :
Cover......Page 1
Title......Page 4
Copyright......Page 5
Contents......Page 8
Preface......Page 24
Acknowledgments for the Second Edition......Page 26
Doug’s Acknowledgments for the Second Edition......Page 27
Acknowledgments for the First Edition......Page 28
David’s Acknowledgments for the First Edition......Page 29
About This Book......Page 30
Overall Structure of the Book......Page 31
Some Remarks About Programming Style......Page 32
The C++11, C++14, and C++17 Standards......Page 34
Feedback......Page 35
Part I: The Basics......Page 36
1.1.1 Defining the Template......Page 38
1.1.2 Using the Template......Page 39
1.1.3 Two-Phase Translation......Page 41
1.2 Template Argument Deduction......Page 42
1.3 Multiple Template Parameters......Page 44
1.3.1 Template Parameters for Return Types......Page 45
1.3.2 Deducing the Return Type......Page 46
1.3.3 Return Type as Common Type......Page 47
1.4 Default Template Arguments......Page 48
1.5 Overloading Function Templates......Page 50
1.6.2 Why Not inline?......Page 55
1.7 Summary......Page 56
2.1 Implementation of Class Template Stack......Page 58
2.1.1 Declaration of Class Templates......Page 59
2.1.2 Implementation of Member Functions......Page 61
2.2 Use of Class Template Stack......Page 62
2.3.1 Concepts......Page 64
2.4 Friends......Page 65
2.5 Specializations of Class Templates......Page 66
2.6 Partial Specialization......Page 68
2.7 Default Class Template Arguments......Page 71
2.8 Type Aliases......Page 73
2.9 Class Template Argument Deduction......Page 75
2.10 Templatized Aggregates......Page 78
2.11 Summary......Page 79
3.1 Nontype Class Template Parameters......Page 80
3.2 Nontype Function Template Parameters......Page 83
3.3 Restrictions for Nontype Template Parameters......Page 84
3.4 Template Parameter Type auto......Page 85
3.5 Summary......Page 89
4.1.1 Variadic Templates by Example......Page 90
4.1.3 Operator sizeof.........Page 92
4.2 Fold Expressions......Page 93
4.3 Application of Variadic Templates......Page 95
4.4 Variadic Class Templates and Variadic Expressions......Page 96
4.4.1 Variadic Expressions......Page 97
4.4.3 Variadic Class Templates......Page 98
4.4.4 Variadic Deduction Guides......Page 99
4.4.5 Variadic Base Classes and using......Page 100
4.5 Summary......Page 101
5.1 Keyword typename......Page 102
5.2 Zero Initialization......Page 103
5.3 Using this->......Page 105
5.4 Templates for Raw Arrays and String Literals......Page 106
5.5 Member Templates......Page 109
5.5.1 The .templateConstruct......Page 114
5.6 Variable Templates......Page 115
5.7 Template Template Parameters......Page 118
5.8 Summary......Page 124
6.1 Perfect Forwarding......Page 126
6.2 Special Member Function Templates......Page 130
6.3 Disable Templates with enable_if......Page 133
6.4 Using enable_if......Page 134
6.5 Using Concepts to Simplify enable_ifExpressions......Page 138
6.6 Summary......Page 139
7. By Value or by Reference?......Page 140
7.1 Passing by Value......Page 141
7.2.1 Passing by Constant Reference......Page 143
7.2.2 Passing by Nonconstant Reference......Page 145
7.2.3 Passing by Forwarding Reference......Page 146
7.3 Using std::ref()and std::cref()......Page 147
7.4 Dealing with String Literals and Raw Arrays......Page 150
7.4.1 Special Implementations for String Literals and Raw Arrays......Page 151
7.5 Dealing with Return Values......Page 152
7.6 Recommended Template Parameter Declarations......Page 153
7.7 Summary......Page 156
8.1 Template Metaprogramming......Page 158
8.2 Computing with constexpr......Page 160
8.3 Execution Path Selection with Partial Specialization......Page 162
8.4 SFINAE (Substitution Failure Is Not An Error)......Page 164
8.4.1 Expression SFINAE with decltype......Page 168
8.5 Compile-Time if......Page 169
8.6 Summary......Page 170
9.1.1 Linker Errors......Page 172
9.1.2 Templates in Header Files......Page 174
9.2 Templates and inline......Page 175
9.3 Precompiled Headers......Page 176
9.4 Decoding the Error Novel......Page 178
9.5 Afternotes......Page 184
9.6 Summary......Page 185
10.1 “Class Template” or “Template Class”?......Page 186
10.2 Substitution, Instantiation, and Specialization......Page 187
10.3 Declarations versus Definitions......Page 188
10.4 The One-Definition Rule......Page 189
10.5 Template Arguments versus Template Parameters......Page 190
10.6 Summary......Page 191
11.1 Callables......Page 192
11.1.1 Supporting Function Objects......Page 193
11.1.2 Dealing with Member Functions and Additional Arguments......Page 195
11.1.3 Wrapping Function Calls......Page 197
11.2.1 Type Traits......Page 199
11.2.3 std::declval()......Page 201
11.4 References as Template Parameters......Page 202
11.5 Defer Evaluations......Page 206
11.6 Things to Consider When Writing Generic Libraries......Page 207
11.7 Summary......Page 208
Part II: Templates in Depth......Page 210
12.1 Parameterized Declarations......Page 212
12.1.2 Linkage of Templates......Page 217
12.1.3 Primary Templates......Page 219
12.2.1 Type Parameters......Page 220
12.2.2 Nontype Parameters......Page 221
12.2.3 Template Template Parameters......Page 222
12.2.4 Template Parameter Packs......Page 223
12.2.5 Default Template Arguments......Page 225
12.3.1 Function Template Arguments......Page 227
12.3.3 Nontype Arguments......Page 229
12.3.4 Template Template Arguments......Page 232
12.3.5 Equivalence......Page 234
12.4 Variadic Templates......Page 235
12.4.1 Pack Expansions......Page 236
12.4.2 Where Can Pack Expansions Occur?......Page 237
12.4.3 Function Parameter Packs......Page 239
12.4.4 Multiple and Nested Pack Expansions......Page 240
12.4.6 Fold Expressions......Page 242
12.5.1 Friend Classes of Class Templates......Page 244
12.5.2 Friend Functions of Class Templates......Page 246
12.6 Afternotes......Page 248
13.1 Name Taxonomy......Page 250
13.2 Looking Up Names......Page 252
13.2.1 Argument-Dependent Lookup......Page 254
13.2.2 Argument-Dependent Lookup of Friend Declarations......Page 255
13.2.3 Injected Class Names......Page 256
13.2.4 Current Instantiations......Page 258
13.3 Parsing Templates......Page 259
13.3.1 Context Sensitivity in Nontemplates......Page 260
13.3.2 Dependent Names of Types......Page 263
13.3.3 Dependent Names of Templates......Page 265
13.3.4 Dependent Names in Using Declarations......Page 266
13.3.6 Dependent Expressions......Page 268
13.4.1 Nondependent Base Classes......Page 271
13.4.2 Dependent Base Classes......Page 272
13.5 Afternotes......Page 275
14.1 On-Demand Instantiation......Page 278
14.2.1 Partial and Full Instantiation......Page 280
14.2.2 Instantiated Components......Page 281
14.3.1 Two-Phase Lookup......Page 284
14.3.2 Points of Instantiation......Page 285
14.3.3 The Inclusion Model......Page 289
14.4 Implementation Schemes......Page 290
14.4.1 Greedy Instantiation......Page 291
14.4.2 Queried Instantiation......Page 292
14.4.3 Iterated Instantiation......Page 294
14.5.1 Manual Instantiation......Page 295
14.5.2 Explicit Instantiation Declarations......Page 297
14.6 Compile-Time ifStatements......Page 298
14.7 In the Standard Library......Page 300
14.8 Afternotes......Page 301
15.1 The Deduction Process......Page 304
15.2 Deduced Contexts......Page 306
15.3 Special Deduction Situations......Page 308
15.4 Initializer Lists......Page 309
15.5 Parameter Packs......Page 310
15.6.1 Reference Collapsing Rules......Page 312
15.6.2 Forwarding References......Page 313
15.6.3 Perfect Forwarding......Page 315
15.6.4 Deduction Surprises......Page 318
15.7 SFINAE (Substitution Failure Is Not An Error)......Page 319
15.7.1 Immediate Context......Page 320
15.8 Limitations of Deduction......Page 321
15.8.1 Allowable Argument Conversions......Page 322
15.8.2 Class Template Arguments......Page 323
15.8.3 Default Call Arguments......Page 324
15.8.4 Exception Specifications......Page 325
15.9 Explicit Function Template Arguments......Page 326
15.10 Deduction from Initializers and Expressions
付费内容
登录后即可获得
一个下载链接

常见问题

  • question_answer
    解压密码,提取码在哪?
    keyboard_arrow_down
    • 均在下载旁边哦,请注意查看,如果没有则是不需要密码
  • question_answer
    文件不符合描述怎么办?
    keyboard_arrow_down
    • 如果有文件问题,可以通过 卖家联系方式 联系卖家,如果 联系不上卖家 或 卖家无法解决 则可以在24小时内在我的订单页面申请售后
  • question_answer
    其他
    keyboard_arrow_down
    • 3.本文件为公益分享,文件由网上采集而来,如有侵权等问题,请及时联系客服删除
      常见问题及官方客服联系方式:点击前往
      售后问题处理方式:点击前往
登陆后下载
微信扫码支付(支付宝请点击登录后下载)
C++模板:完整的指南-C++ Templates: The Complete Guide
支付金额: 共计:¥0.0

添加收藏

创建新合集

-到底部了哦-