Modern C++ Design: Generic Programming and Design Patterns Applied / Edition 1by Andrei Alexandrescu
Modern C++ Design is an important book. Fundamentally, it demonstrates ‘generic patterns’ or ‘pattern templates’ as a powerful new way of creating extensible designs in C++a new way to combine templates and patterns that you may never have dreamt was possible, but is. If your work involves C++ design and coding, you should/b>… See more details below
Modern C++ Design is an important book. Fundamentally, it demonstrates ‘generic patterns’ or ‘pattern templates’ as a powerful new way of creating extensible designs in C++a new way to combine templates and patterns that you may never have dreamt was possible, but is. If your work involves C++ design and coding, you should read this book. Highly recommended.
What’s left to say about C++ that hasn’t already been said? Plenty, it turns out.
From the Foreword by John Vlissides
In Modern C++ Design, Andrei Alexandrescu opens new vistas for C++ programmers. Displaying extraordinary creativity and programming virtuosity, Alexandrescu offers a cutting-edge approach to design that unites design patterns, generic programming, and C++, enabling programmers to achieve expressive, flexible, and highly reusable code.
This book introduces the concept of generic componentsreusable design templates that produce boilerplate code for compiler consumptionall within C++. Generic components enable an easier and more seamless transition from design to application code, generate code that better expresses the original design intention, and support the reuse of design structures with minimal recoding.
The author describes the specific C++ techniques and features that are used in building generic components and goes on to implement industrial strength generic components for real-world applications. Recurring issues that C++ developers face in their day-to-day activity are discussed in depth and implemented in a generic way. These include:
- Policy-based design for flexibility
- Partial template specialization
- Typelistspowerful type manipulation structures
- Patterns such as Visitor, Singleton, Command, and Factories
- Multi-method engines
For each generic component, the book presents the fundamental problems and design options, and finally implements a generic solution.
In addition, an accompanying Web site, http://www.awl.com/cseng/titles/0-201-70431-5, makes the code implementations available for the generic components in the book and provides a free, downloadable C++ library, called Loki, created by the author. Loki provides out-of-the-box functionality for virtually any C++ project.
Get a value-added service! Try out all the examples from this book at www.codesaw.com. CodeSaw is a free online learning tool that allows you to experiment with live code from your book right in your browser.
Table of Contents
Foreword by Scott Meyers.
Foreword by John Vlissides.
1. Policy-Based Class Design.
The Multiplicity of Software Design.
The Failure of the Do-It-All Interface.
Multiple Inheritance to the Rescue?
Templates Bring Hope.
Policies and Policy Classes.
Destructors of Policy Classes.
Optional Functionality Through Incomplete Instantiation.
Combining Policy Classes.
Customizing Structure with Policy Classes.
Compatible and Noncompatible Policies.
Decomposing a Class in Policies.
Partial Template Specialization.
Local Classes 28 2.4 Mapping Integral Constants to Types.
Detecting Convertibility and Inheritance at Compile Time.
A Wrapper Around type_info.
NullType and EmptyType.
The Need for Typelists.
Linearizing Typelist Creation.
Appending to Typelists.
Erasing a Type from a Typelist.
Replacing an Element in a Typelist.
Partially Ordering Typelists.
Class Generation with Typelists.
Typelist Quick Facts.
4. Small-Object Allocation.
The Default Free Store Allocator.
The Workings of a Memory Allocator.
A Small-Object Allocator.
The Fixed-Size Allocator.
The SmallObjAllocator Class.
A Hat Trick.
Simple, Complicated, Yet Simple in the End.
Small-Object Allocator Quick Facts.
5. Generalized Functors.
The Command Design Pattern.
Command in the Real World.
C11 Callable Entities.
The Functor Class Template Skeleton.
Implementing the Forwarding Functor::operator().
Build One, Get One Free.
Argument and Return Type Conversions.
Handling Pointers to Member Functions.
Real-World Issues I: The Cost of Forwarding Functions.
Real-World Issues II: Heap Allocation.
Implementing Undo and Redo with Functor.
Functor Quick Facts.
6. Implementing Singletons.
Static Data + Static Functions != Singleton.
The Basic C11 Idioms Supporting Singleton.
Enforcing the Singleton's Uniqueness.
Destroying the Singleton.
The Dead Reference Problem.
Addressing the Dead Reference Problem (I):.
Addressing the Dead Reference Problem (II):.
Implementing Singletons with Longevity.
Living in a Multithreaded World.
Putting It All Together.
Working With SingletonHolder.
SingletonHolder Class Template Quick Facts.
7. Smart Pointers.
Smart Pointers 101.
Smart Pointers' Storage.
Smart Pointer Member Functions.
The Address-of Operator.
Implicit Conversion to Raw Pointer Type.
Equality and Inequality.
Checking and Error Reporting.
Smart Pointers to const and const Smart Pointers.
Smart Pointers and Multithreading.
Putting It All Together.
SmartPtr Quick Facts.
8. Object Factories.
The Need for Object Factories.
Object Factories in C11: Classes and Objects.
Implementing an Object Factory.
Using Object Factories with Other Generic Components.
Factory Class Template Quick Facts.
CloneFactory Class Template Quick Facts.
9. Abstract Factory.
The Architectural Role of Abstract Factory.
A Generic Abstract Factory Interface.
A Prototype-Based Abstract Factory Implementation.
AbstractFactory and ConcreteFactory Quick Facts.
Overloading: The Catch-All Function.
An Implementation Refinement: The Acyclic Visitor.
A Generic Implementation of Visitor.
Back to the “Cyclic” Visitor.
Visitor Generic Component Quick Facts.
What Are Multimethods?
When Are Multimethods Needed?
Double Switch-on-Type: Brute Force.
The Brute-Force Approach Automated.
Symmetry with the Brute-Force Dispatcher.
The Logarithmic Double Dispatcher.
FnDispatcher and Symmetry.
Double Dispatch to Functors.
Converting Arguments: static_cast or dynamic_cast?
Constant-Time Multimethods: Raw Speed.
BasicDispatcher and BasicFastDispatcher as Policies.
Double Dispatcher Quick Facts.
Appendix A. Minimalist Multithreading Library.
A Critique of Multithreading.
Atomic Operations on Integral Types.
Locking Semantics in Object-Oriented Programming.
Optional volatile Modifier.
Semaphores, Events, and Other Good Things.
and post it to your social network
Most Helpful Customer Reviews
See all customer reviews >