What's inside
Introduction
Goals
Chapters
Exercises
Exercise solutions
Source code
Compilers
Language standards
Seminars,CD-ROMs
&consulting
Errors
About the cover
Acknowledgements
I:Building Stable Systems
1:Exception Handing
Traditional error handling
Throwing an exception
Catching an exception
The try block
Exception handlers
Termination
and resumption
Exception matching
Catching any exception
Rethrowing an exception
Uncaught exceptions
Cleaning UP
Resource management
Making everything
an object
auto_ptr
Function-level try blocks
Standard exceptions
Exception specifications
Better exception
specifications?
Exception specifications
and inheritance
When not to use
exception specifications
Exception safety
Programming with exceptions
When to avoid exceptions
Typical uses of exceptions
Overhead
Summary
Exercises
2:Defensive Programming
Assertions
A simple Unit test framework
Automated testing
The TestSuite Framework
Test suites
The test framework code
Debugging techniques
Trace macros
Trace file
Finding memory leaks
Summary
Exercises
II:The Standard C++ Library
3:Strings in Depth
What's in a string?
Creating and initializing
C++ strings
Operating on strings
Appending,inserting,and
concatenating strings
Replacing string
characters
Concatenation using nonmember
overloaded operators
Searching in strings
Finding in reverse
Finding first/last of
a set of characters
Removing characters
from strings
Comparing strings
Strings and
character traits
A String application
Summary
Exercises
4:Iostreams
Why iostreams?
Iostreams to the rescue
Inserters and extractors
Common usage
Line-oriented input
Handling stream errors
File iostreams
A File-Processing
Example
Open modes
Iostream buffering
Seeking in iostreams
String iostreams
Input string streams
Output string streams
Output stream formatting
Format flags
Format fields
Width,fill,and precision
An exhaustive example
Manipulators
Manipulators with
arguments
Creating manipulators
Effectors
Iostream examples
Maintaining class library
soutce code
Detecting compiler errors
A simple data logger
Internationalization
Wide Streams
Locales
Summary
Exercises
5:Templates in Depth
Template parameters
Non-type
template parameters
Default template
arguments
Template template
parameters
The typename keyword
Using the template
Keyword as a hint
Member Templates
Function template issues
Type deduction of function
template arguments
Function template
overloading
Taking the address
of a generated
function template
Applying a function
to an STL sequence
Partial ordering of
function templates
Template specialization
Explicit specialization
Partial Specialization
A Practical example
Preventing template
code bloat
Name lookup issues
Names in templates
Templates and friends
Template programming idioms
Traits
Policies
The curiously recurring
template pattern
Template metaprogramming
Compile-time
Programming
Expression templates
Template compilation models
The inclusion model
Explicit instantiation
The separation model
Summary
Exercises
6:Generic Algorithms
A first look
Predicates
Stream iterators
Algorithm complexity
Function objects
Classification of
function objects
Automatic creation of
function objects
Adaptable function objects
More function
object examples
Function pointer adaptors
Writing your own
function object adaptors
A catalog of STL algorithms
Support tools for
example creation
Filling and generating
Counting
Manipulating sequences
Searching and replacing
Comparing ranges
Removing elements
Sorting and operations
on sorted ranges
Heap operations
Applying an operation to
each element in a range
Numeric algorithms
General utilities
Creating your own
STL-style algorithms
Summary
Exercises
7:Generic Containers
Containers and iterators
STL reference
documentation
A first look
Containers of strings
Inheriting from
STL containers
A Plethora of iterators
Iterators in
reversible containers
Iterator categories
Predefined iterators
The basic sequences
Vector,list,deque
Basic sequence operations
vector
deque
Converting between
sequences
Checked random-access
list
Swapping sequences
Set
A completely
reusable tokenizer
Stack
Queue
Priority queues
Holding bits
bitset<n>
vector<bool>
Associative containers
Generators and fillers
for associative containers
The magic of maps
Multimaps and
duplicate keys
Multisets
Combining STL containers
Cleaning UP
containers of pointers
Creating your own containers
STL extensions
Non-STL containers
Summary
Exercises
III:Special Topics
8:Runtime Type Identification
Runtime casts
The typeid operator
Casting to
intermediate levels
void pointers
Using RTTI
with templates
Multiple inheritance
Sensible uses for RTTI
A trash recycler
Mechanism and
overhead of RTTI
Summary
Exercises
9:Multiple Inheritance
Perspective
Interface inheritance
Implementation inheritance
Duplicate subobjects
Virtual base classes
Name lookup issues
Avoiding MI
Extending an interface
Summary
Exercises
10:Design Patterns
The pattern concept
Prefer composition
to inheritance
Classifying patterns
Features,idioms,
patterns
Simplifying Idioms
Messenger
Collecting Parameter
Singleton
Variations on Singleton
Command:choosing
the operation
Decoupling event handling
with Command
Object decoupling
Proxy:fronting for
another object
State;changing
object behavior
Adapter
Template Method
Strategy:choosing the
algorithm at runtime
Chain of Responsibility
trying a sequence of strategies
Factories:encapsulating
object creation
Polymorphic factories
Abstract factories
Virtual constructors
Builder:creating
complex objects
Observer
The"inner class"idiom
The observer example
Multiple dispatching
Multiple dispatching
with Visitor
Summary
Exercises
11:Concurrency
Motivation
Concurrency in C++
Installing ZThreads
Defining Tasks
Using Threads
Creating responsive
User interfaces
Simplifying with
Executors
Yielding
Sleeping
Priority
Sharing limited resources
Ensuring the
existence of objects
Improperly accessing
resources
Controlling access
Simplified coding
with Guards
Thread local storage
Terminating tasks
Preventing iostream
collision
The ornamental garden
Terminating
when blocked
Interruption
Cooperation between threads
Wait and signal
Producer-consumer
relationships
Solving threading problems
with queues
Broadcast
Deadlock
Summary
Exercises
A:Recommended Reading
General C++
Bruce's books
Chuck's books
In-depth C++
Design Patterns
B:Etc
Index