Note: Supplemental materials are not guaranteed with Rental or Used book purchases.
- ISBN: 9780201734843 | 0201734842
- Cover: Hardcover
- Copyright: 11/12/2002
With the greatly increased use of templates there is a real need in the C++ community for this information. This book is the next C++ classic acting as both a complete reference as well as a tutorial. It emphasizes the practical use of templates, and includes real-world examples.
David Vandevoorde is an engineer at the Edison Design Group Nicolai M. Josuttis is an independent technical consultant
Preface | p. xv |
Acknowledgments | p. xvii |
About This Book | p. 1 |
What You Should Know Before Reading This Book | p. 2 |
Overall Structure of the Book | p. 2 |
How to Read This Book | p. 3 |
Some Remarks About Programming Style | p. 3 |
The Standard versus Reality | p. 5 |
Example Code and Additional Informations | p. 5 |
Feedback | p. 5 |
The Basics | p. 7 |
Function Templates | p. 9 |
A First Look at Function Templates | p. 9 |
Argument Deduction | p. 12 |
Template Parameters | p. 13 |
Overloading Function Templates | p. 15 |
Summary | p. 19 |
Class Templates | p. 21 |
Implementation of Class Template Stack | p. 21 |
Use of Class Template Stack | p. 25 |
Specializations of Class Templates | p. 27 |
Partial Specialization | p. 29 |
Default Template Arguments | p. 30 |
Summary | p. 33 |
Nontype Template Parameters | p. 35 |
Nontype Class Template Parameters | p. 35 |
Nontype Function Template Parameters | p. 39 |
Restrictions for Nontype Template Parameters | p. 40 |
Summary | p. 41 |
Tricky Basics | p. 43 |
Keyword typename | p. 43 |
Using this-> | p. 45 |
Member Templates | p. 45 |
Template Template Parameters | p. 50 |
Zero Initialization | p. 56 |
Using String Literals as Arguments for Function Templates | p. 57 |
Summary | p. 60 |
Using Templates in Practice | p. 61 |
The Inclusion Model | p. 61 |
Explicit Instantiation | p. 65 |
The Separation Model | p. 68 |
Templates and inline | p. 72 |
Precompiled Headers | p. 72 |
Debugging Templates | p. 74 |
Afternotes | p. 85 |
Summary | p. 85 |
Basic Template Terminology | p. 87 |
"Class Template" or "Template Class"? | p. 87 |
Instantiation and Specialization | p. 88 |
Declarations versus Definitions | p. 89 |
The One-Definition Rule | p. 90 |
Template Arguments versus Template Parameters | p. 90 |
Templates in Depth | p. 93 |
Fundamentals in Depth | p. 95 |
Parameterized Declarations | p. 95 |
Template Parameters | p. 100 |
Template Arguments | p. 104 |
Friends | p. 113 |
Afternotes | p. 117 |
Names in Templates | p. 119 |
Name Taxonomy | p. 119 |
Looking Up Names | p. 121 |
Parsing Templates | p. 127 |
Derivation and Class Templates | p. 135 |
Afternotes | p. 139 |
Instantiation | p. 141 |
On-Demand Instantiation | p. 141 |
Lazy Instantiation | p. 143 |
The C++ Instantiation Model | p. 146 |
Implementation Schemes | p. 153 |
Explicit Instantiation | p. 159 |
Afternotes | p. 163 |
Template Argument Deduction | p. 167 |
The Deduction Process | p. 167 |
Deduced Contexts | p. 169 |
Special Deduction Situations | p. 171 |
Allowable Argument Conversions | p. 172 |
Class Template Parameters | p. 173 |
Default Call Arguments | p. 173 |
The Barton-Nackman Trick | p. 174 |
Afternotes | p. 177 |
Specialization and Overloading | p. 179 |
When "Generic Code" Doesn't Quite Cut It | p. 179 |
Overloading Function Templates | p. 183 |
Explicit Specialization | p. 190 |
Partial Class Template Specialization | p. 200 |
Afternotes | p. 203 |
Future Directions | p. 205 |
The Angle Bracket Hack | p. 205 |
Relaxed typename Rules | p. 206 |
Default Function Template Arguments | p. 207 |
String Literal and Floating-Point Template Arguments | p. 209 |
Relaxed Matching of Template Template Parameters | p. 211 |
Typedef Templates | p. 212 |
Partial Specialization of Function Templates | p. 213 |
The typeof Operator | p. 215 |
Named Template Arguments | p. 216 |
Static Properties | p. 218 |
Custom Instantiation Diagnostics | p. 218 |
Overloaded Class Templates | p. 221 |
List Parameters | p. 222 |
Layout Control | p. 224 |
Initializer Deduction | p. 225 |
Function Expressions | p. 226 |
Afternotes | p. 228 |
Templates and Design | p. 229 |
The Polymorphic Power of Templates | p. 231 |
Dynamic Polymorphism | p. 231 |
Static Polymorphism | p. 234 |
Dynamic versus Static Polymorphism | p. 238 |
New Forms of Design Patterns | p. 239 |
Generic Programming | p. 240 |
Afternotes | p. 243 |
Traits and Policy Classes | p. 245 |
An Example: Accumulating a Sequence | p. 245 |
Type Functions | p. 263 |
Policy Traits | p. 275 |
Afternotes | p. 284 |
Templates and Inheritance | p. 285 |
Named Template Arguments | p. 285 |
The Empty Base Class Optimization (EBCO) | p. 289 |
The Curiously Recurring Template Pattern (CRTP) | p. 295 |
Parameterized Virtuality | p. 298 |
Afternotes | p. 299 |
Metaprograms | p. 301 |
A First Example of a Metaprogram | p. 301 |
Enumeration Values versus Static Constants | p. 303 |
A Second Example: Computing the Square Root | p. 305 |
Using Induction Variables | p. 309 |
Computational Completeness | p. 312 |
Recursive Instantiation versus Recursive Template Arguments | p. 313 |
Using Metaprograms to Unroll Loops | p. 314 |
Afternotes | p. 318 |
Expression Templates | p. 321 |
Temporaries and Split Loops | p. 322 |
Encoding Expressions in Template Arguments | p. 328 |
Performance and Limitations of Expression Templates | p. 340 |
Afternotes | p. 341 |
Advanced Applications | p. 345 |
Type Classification | p. 347 |
Determining Fundamental Types | p. 347 |
Determining Compound Types | p. 350 |
Identifying Function Types | p. 352 |
Enumeration Classification with Overload Resolution | p. 356 |
Determining Class Types | p. 359 |
Putting It All Together | p. 359 |
Afternotes | p. 363 |
Smart Pointers | p. 365 |
Holders and Trules | p. 365 |
Reference Counting | p. 379 |
Afternotes | p. 394 |
Tuples | p. 395 |
Duos | p. 395 |
Recursive Duos | p. 401 |
Tuple Construction | p. 410 |
Afternotes | p. 415 |
Function Objects and Callbacks | p. 417 |
Direct, Indirect, and Inline Calls | p. 418 |
Pointers and References to Functions | p. 421 |
Pointer-to-Member Functions | p. 423 |
Class Type Functors | p. 426 |
Specifying Functors | p. 429 |
Introspection | p. 436 |
Function Object Composition | p. 445 |
Value Binders | p. 457 |
Functor Operations: A Complete Implementation | p. 471 |
Afternotes | p. 474 |
Appendixes | p. 475 |
The One-Definition Rule | p. 475 |
Translation Units | p. 475 |
Declarations and Definitions | p. 476 |
The One-Definition Rule in Detail | p. 477 |
Overload Resolution | p. 487 |
When Does Overload Resolution Kick In? | p. 488 |
Simplified Overload Resolution | p. 488 |
Overloading Details | p. 493 |
Bibliography | p. 499 |
Newsgroups | p. 499 |
Books and Web Sites | p. 500 |
Glossary | p. 507 |
Index | p. 517 |
Table of Contents provided by Syndetics. All Rights Reserved. |
What is included with this book?
The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.
The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.