| |
| |
Preface | |
| |
| |
Acknowledgments | |
| |
| |
| |
About This Book | |
| |
| |
| |
What You Should Know Before Reading This Book | |
| |
| |
| |
Overall Structure of the Book | |
| |
| |
| |
How to Read This Book | |
| |
| |
| |
Some Remarks About Programming Style | |
| |
| |
| |
The Standard versus Reality | |
| |
| |
| |
Example Code and Additional Informations | |
| |
| |
| |
Feedback | |
| |
| |
| |
The Basics | |
| |
| |
| |
Function Templates | |
| |
| |
| |
A First Look at Function Templates | |
| |
| |
| |
Argument Deduction | |
| |
| |
| |
Template Parameters | |
| |
| |
| |
Overloading Function Templates | |
| |
| |
| |
Summary | |
| |
| |
| |
Class Templates | |
| |
| |
| |
Implementation of Class Template Stack | |
| |
| |
| |
Use of Class Template Stack | |
| |
| |
| |
Specializations of Class Templates | |
| |
| |
| |
Partial Specialization | |
| |
| |
| |
Default Template Arguments | |
| |
| |
| |
Summary | |
| |
| |
| |
Nontype Template Parameters | |
| |
| |
| |
Nontype Class Template Parameters | |
| |
| |
| |
Nontype Function Template Parameters | |
| |
| |
| |
Restrictions for Nontype Template Parameters | |
| |
| |
| |
Summary | |
| |
| |
| |
Tricky Basics | |
| |
| |
| |
Keyword typename | |
| |
| |
| |
Using this-> | |
| |
| |
| |
Member Templates | |
| |
| |
| |
Template Template Parameters | |
| |
| |
| |
Zero Initialization | |
| |
| |
| |
Using String Literals as Arguments for Function Templates | |
| |
| |
| |
Summary | |
| |
| |
| |
Using Templates in Practice | |
| |
| |
| |
The Inclusion Model | |
| |
| |
| |
Explicit Instantiation | |
| |
| |
| |
The Separation Model | |
| |
| |
| |
Templates and inline | |
| |
| |
| |
Precompiled Headers | |
| |
| |
| |
Debugging Templates | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Summary | |
| |
| |
| |
Basic Template Terminology | |
| |
| |
| |
"Class Template" or "Template Class"? | |
| |
| |
| |
Instantiation and Specialization | |
| |
| |
| |
Declarations versus Definitions | |
| |
| |
| |
The One-Definition Rule | |
| |
| |
| |
Template Arguments versus Template Parameters | |
| |
| |
| |
Templates in Depth | |
| |
| |
| |
Fundamentals in Depth | |
| |
| |
| |
Parameterized Declarations | |
| |
| |
| |
Template Parameters | |
| |
| |
| |
Template Arguments | |
| |
| |
| |
Friends | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Names in Templates | |
| |
| |
| |
Name Taxonomy | |
| |
| |
| |
Looking Up Names | |
| |
| |
| |
Parsing Templates | |
| |
| |
| |
Derivation and Class Templates | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Instantiation | |
| |
| |
| |
On-Demand Instantiation | |
| |
| |
| |
Lazy Instantiation | |
| |
| |
| |
The C++ Instantiation Model | |
| |
| |
| |
Implementation Schemes | |
| |
| |
| |
Explicit Instantiation | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Template Argument Deduction | |
| |
| |
| |
The Deduction Process | |
| |
| |
| |
Deduced Contexts | |
| |
| |
| |
Special Deduction Situations | |
| |
| |
| |
Allowable Argument Conversions | |
| |
| |
| |
Class Template Parameters | |
| |
| |
| |
Default Call Arguments | |
| |
| |
| |
The Barton-Nackman Trick | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Specialization and Overloading | |
| |
| |
| |
When "Generic Code" Doesn't Quite Cut It | |
| |
| |
| |
Overloading Function Templates | |
| |
| |
| |
Explicit Specialization | |
| |
| |
| |
Partial Class Template Specialization | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Future Directions | |
| |
| |
| |
The Angle Bracket Hack | |
| |
| |
| |
Relaxed typename Rules | |
| |
| |
| |
Default Function Template Arguments | |
| |
| |
| |
String Literal and Floating-Point Template Arguments | |
| |
| |
| |
Relaxed Matching of Template Template Parameters | |
| |
| |
| |
Typedef Templates | |
| |
| |
| |
Partial Specialization of Function Templates | |
| |
| |
| |
The typeof Operator | |
| |
| |
| |
Named Template Arguments | |
| |
| |
| |
Static Properties | |
| |
| |
| |
Custom Instantiation Diagnostics | |
| |
| |
| |
Overloaded Class Templates | |
| |
| |
| |
List Parameters | |
| |
| |
| |
Layout Control | |
| |
| |
| |
Initializer Deduction | |
| |
| |
| |
Function Expressions | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Templates and Design | |
| |
| |
| |
The Polymorphic Power of Templates | |
| |
| |
| |
Dynamic Polymorphism | |
| |
| |
| |
Static Polymorphism | |
| |
| |
| |
Dynamic versus Static Polymorphism | |
| |
| |
| |
New Forms of Design Patterns | |
| |
| |
| |
Generic Programming | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Traits and Policy Classes | |
| |
| |
| |
An Example: Accumulating a Sequence | |
| |
| |
| |
Type Functions | |
| |
| |
| |
Policy Traits | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Templates and Inheritance | |
| |
| |
| |
Named Template Arguments | |
| |
| |
| |
The Empty Base Class Optimization (EBCO) | |
| |
| |
| |
The Curiously Recurring Template Pattern (CRTP) | |
| |
| |
| |
Parameterized Virtuality | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Metaprograms | |
| |
| |
| |
A First Example of a Metaprogram | |
| |
| |
| |
Enumeration Values versus Static Constants | |
| |
| |
| |
A Second Example: Computing the Square Root | |
| |
| |
| |
Using Induction Variables | |
| |
| |
| |
Computational Completeness | |
| |
| |
| |
Recursive Instantiation versus Recursive Template Arguments | |
| |
| |
| |
Using Metaprograms to Unroll Loops | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Expression Templates | |
| |
| |
| |
Temporaries and Split Loops | |
| |
| |
| |
Encoding Expressions in Template Arguments | |
| |
| |
| |
Performance and Limitations of Expression Templates | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Advanced Applications | |
| |
| |
| |
Type Classification | |
| |
| |
| |
Determining Fundamental Types | |
| |
| |
| |
Determining Compound Types | |
| |
| |
| |
Identifying Function Types | |
| |
| |
| |
Enumeration Classification with Overload Resolution | |
| |
| |
| |
Determining Class Types | |
| |
| |
| |
Putting It All Together | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Smart Pointers | |
| |
| |
| |
Holders and Trules | |
| |
| |
| |
Reference Counting | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Tuples | |
| |
| |
| |
Duos | |
| |
| |
| |
Recursive Duos | |
| |
| |
| |
Tuple Construction | |
| |
| |
| |
Afternotes | |
| |
| |
| |
Function Objects and Callbacks | |
| |
| |
| |
Direct, Indirect, and Inline Calls | |
| |
| |
| |
Pointers and References to Functions | |
| |
| |
| |
Pointer-to-Member Functions | |
| |
| |
| |
Class Type Functors | |
| |
| |
| |
Specifying Functors | |
| |
| |
| |
Introspection | |
| |
| |
| |
Function Object Composition | |
| |
| |
| |
Value Binders | |
| |
| |
| |
Functor Operations: A Complete Implementation | |
| |
| |
| |
Afternotes | |
| |
| |
Appendixes | |
| |
| |
| |
The One-Definition Rule | |
| |
| |
| |
Translation Units | |
| |
| |
| |
Declarations and Definitions | |
| |
| |
| |
The One-Definition Rule in Detail | |
| |
| |
| |
Overload Resolution | |
| |
| |
| |
When Does Overload Resolution Kick In? | |
| |
| |
| |
Simplified Overload Resolution | |
| |
| |
| |
Overloading Details | |
| |
| |
Bibliography | |
| |
| |
Newsgroups | |
| |
| |
Books and Web Sites | |
| |
| |
Glossary | |
| |
| |
Index | |