Skip to content

C++ Templates The Complete Guide

Spend $50 to get a free DVD!

ISBN-10: 0201734842

ISBN-13: 9780201734843

Edition: 2003

Authors: David Vandevoorde, Nicolai M. Josuttis

List price: $79.99
Blue ribbon 30 day, 100% satisfaction guarantee!
Out of stock
what's this?
Rush Rewards U
Members Receive:
Carrot Coin icon
XP icon
You have reached 400 XP and carrot coins. That is the daily max!


This book will be the next C++ classic. Although templates have been part of C++ for well over a decade, they still lead to misunderstanding, misuse, and controversy. At the same time, they are increasingly found to be powerful instruments for the development of cleaner, faster, and smarter software. This has made templates one of the hottest topics in the C++ community. This book will be both a complete reference as well as a tutorial. It will emphasize the practical use of templates, and will include real-world examples. Every working C++ programmer will need a copy of this book for his or her library.
Customers also bought

Book details

List price: $79.99
Copyright year: 2003
Publisher: Addison Wesley Professional
Publication date: 11/12/2002
Binding: Hardcover
Pages: 560
Size: 7.50" wide x 9.25" long x 1.25" tall
Weight: 2.244
Language: English

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
The Basics
Function Templates
A First Look at Function Templates
Argument Deduction
Template Parameters
Overloading Function Templates
Class Templates
Implementation of Class Template Stack
Use of Class Template Stack
Specializations of Class Templates
Partial Specialization
Default Template Arguments
Nontype Template Parameters
Nontype Class Template Parameters
Nontype Function Template Parameters
Restrictions for Nontype Template Parameters
Tricky Basics
Keyword typename
Using this->
Member Templates
Template Template Parameters
Zero Initialization
Using String Literals as Arguments for Function Templates
Using Templates in Practice
The Inclusion Model
Explicit Instantiation
The Separation Model
Templates and inline
Precompiled Headers
Debugging Templates
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
Names in Templates
Name Taxonomy
Looking Up Names
Parsing Templates
Derivation and Class Templates
On-Demand Instantiation
Lazy Instantiation
The C++ Instantiation Model
Implementation Schemes
Explicit Instantiation
Template Argument Deduction
The Deduction Process
Deduced Contexts
Special Deduction Situations
Allowable Argument Conversions
Class Template Parameters
Default Call Arguments
The Barton-Nackman Trick
Specialization and Overloading
When "Generic Code" Doesn't Quite Cut It
Overloading Function Templates
Explicit Specialization
Partial Class Template Specialization
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
Templates and Design
The Polymorphic Power of Templates
Dynamic Polymorphism
Static Polymorphism
Dynamic versus Static Polymorphism
New Forms of Design Patterns
Generic Programming
Traits and Policy Classes
An Example: Accumulating a Sequence
Type Functions
Policy Traits
Templates and Inheritance
Named Template Arguments
The Empty Base Class Optimization (EBCO)
The Curiously Recurring Template Pattern (CRTP)
Parameterized Virtuality
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
Expression Templates
Temporaries and Split Loops
Encoding Expressions in Template Arguments
Performance and Limitations of Expression Templates
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
Smart Pointers
Holders and Trules
Reference Counting
Recursive Duos
Tuple Construction
Function Objects and Callbacks
Direct, Indirect, and Inline Calls
Pointers and References to Functions
Pointer-to-Member Functions
Class Type Functors
Specifying Functors
Function Object Composition
Value Binders
Functor Operations: A Complete Implementation
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
Books and Web Sites