Prix bas
CHF75.35
Cet article manque chez l'éditeur. Il sera livré dès que possible.
Auteur
David Vandevoorde started programming C++ in the late 1980s. After obtaining a PhD from the Rensselaer Polytechnic Institute, he became technical lead of Hewlett-Packard’s C++ compiler team. In 1999 he joined the Edison Design Group (EDG), whose C++ compiler technology is widely recognized as the industry’s most advanced. He is an active member of the C++ Standard Committee and a moderator of the newsgroup comp.lang.c++.moderated (which he co-founded). He is the author of C++ Solutions, the companion to The C++ Programming Language, 3rd Edition.
Nicolai M. Josuttis is well known for his best-selling de-facto standard bookThe C++ Standard Library - A Tutorial and Reference. He is an independent technical consultant who designs object-oriented software for the telecommunications, traffic, finance, and manufacturing industries. He is an active member of the C++ Standard Committee and a partner at System Bauhaus, a German group of prominent object-oriented system development experts. Josuttis has written several other books on object-oriented programming and C++.
Douglas Gregor is Senior Swift/C++/Objective-C Compiler Engineer at Apple. He holds a PhD in computer science from Rensselaer Polytechnic Institute, and did post-doctoral work at Indiana University.
Texte du rabat
This book has become and will remain the 'bible' on templates. It provides the most complete and accurate information on using templates in C++. It is a complete reference as well as a tutorial. It includes real-world examples.
Résumé
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.
Contenu
Preface xxiii
Acknowledgments for the Second Edition xxv
Acknowledgments for the First Edition xxvii
About This Book xxix
Part I: The Basics 1
Chapter 1: Function Templates 3
1.1 A First Look at Function Templates 3
1.2 Template Argument Deduction 7
1.3 Multiple Template Parameters 9
1.4 Default Template Arguments 13
1.5 Overloading Function Templates 15
1.6 But, Shouldn’t We . . . ? 20
1.7 Summary 21
Chapter 2: Class Templates 23
2.1 Implementation of Class Template Stack 23
2.2 Use of Class Template Stack 27
2.3 Partial Usage of Class Templates 29
2.4 Friends 30
2.5 Specializations of Class Templates 31
2.6 Partial Specialization 33
2.7 Default Class Template Arguments 36
2.8 Type Aliases38
2.9 Class Template Argument Deduction 40
2.10 Templatized Aggregates 43
2.11 Summary 44
Chapter 3: Nontype Template Parameters 45
3.1 Nontype Class Template Parameters 45
3.2 Nontype Function Template Parameters 48
3.3 Restrictions for Nontype Template Parameters 49
3.4 Template Parameter Type auto 50
3.5 Summary 54
Chapter 4: Variadic Templates 55
4.1 Variadic Templates 55
4.2 Fold Expressions 58
4.3 Application of Variadic Templates 60
4.4 Variadic Class Templates and Variadic Expressions 61
4.5 Summary 66
Chapter 5: Tricky Basics 67
5.1 Keyword typename 67
5.2 Zero Initialization 68
5.3 Using this-> 70
5.4 Templates for Raw Arrays and String Literals 71
5.5 Member Templates 74
5.6 Variable Templates 80
5.7 Template Template Parameters 83
5.8 Summary 89
Chapter 6: Move Semantics and enable_if 91
6.1 Perfect Forwarding 91
6.2 Special Member Function Templates 95
6.3 Disable Templates with enable_if 98
6.4 Using enable_if 99
6.5 Using Concepts to Simplify enable_if Expressions 103
6.6 Summary 104
Chapter 7: By Value or by Reference? 105
7.1 Passing by Value 106
7.2 Passing by Reference 108
7.3 Using std::ref() and std::cref() 112
7.4 Dealing with String Literals and Raw Arrays 115
7.5 Dealing with Return Values 117
7.6 Recommended Template Parameter Declarations 118
7.7 Summary 121
Chapter 8: Compile-Time Programming 123
8.1 Template Metaprogramming 123
8.2 Computing with constexpr 125
8.3 Execution Path Selection with Partial Specialization 127
8.4 SFINAE (Substitution Failure Is Not An Error) 129
8.5 Compile-Time if 134
8.6 Summary 135
Chapter 9: Using Templates in Practice 137
9.1 The Inclusion Model 137
9.2 Templates and inline 140
9.3 Precompiled Headers 141
9.4 Decoding the Error Novel 143
9.5 Afternotes 149
9.6 Summary 150
Chapter 10: Basic Template Terminology 151
10.1 “Class Template” or “Template Class”? 151
10.2 Substitution, Instantiation, and Specialization 152
10.3 Declarations versus Definitions 153
10.4 The One-Definition Rule 154
10.5 Template Arguments versus Template Parameters 155
10.6 Summary 156
Chapter 11: Generic Libraries 157
11.1 Callables 157
11.2 Other Utilities to Implement Generic Libraries 164
11.3 Perfect Forwarding Temporaries 167
11.4 References as Template Parameters 167
11.5 Defer Evaluations 171
11.6 Things to Consider When Writing Generic Libraries 172
11.7 Summary 173
Part II: Templates in Depth 175
Chapter 12: Fundamentals in Depth 177
12.1 Parameterized Declarations 177
12.2 Template Parameters 185
12.3 Template Arguments 192
12.4 Variadic Templates 200
12.5 Friends 209
12.6 Afternotes 213
Chapter 13: Names in Templates 215
13.1 Name Taxonomy 215
13.2 Looking Up Names 217
13.3 Parsing Templates 224
13.4 Inheritance and Class Templates 236
13.5 Afternotes 240
Chapter 14: Instantiation 243
14.1 On-Demand Instantiation 243
14.2 Lazy Instantiation 245
14.3 The C++ Instantiation Model 249
14.4 Implementation Schemes 255
14.5 Explicit Instantiation 260
14.6 Compile-Time if Statements 263
14.7 In the Standard Library 265
14.8 Afternotes 266
Chapter 15: Template Argument Deduction 269
15.1 The Deduction Process 269
15.2 Deduced Contexts 271
15.3 Special Deduction Situations 273
15.4 Initializer Lists 274
15.5 Parameter Packs 275
15.6 Rvalue References 277
15.7 SFINAE (Substitution Failure Is Not An Error) 284
15.8 Limitations of Deduction 286
15.9 Explic…