Modern C++ Design: Generic Programming and Design Patterns AppliedAddison-Wesley Professional, 2001 - 323 Seiten 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 components--reusable design templates that produce boilerplate code for compiler consumption--all 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:
|
Inhalt
PolicyBased Class Design | 3 |
12 The Failure of the DoItAll Interface | 4 |
13 Multiple Inheritance to the Rescue? | 5 |
14 The Benefit of Templates | 6 |
15 Policies and Policy Classes | 7 |
16 Enriched Policies | 12 |
18 Optional Functionality Through Incomplete Instantiation | 13 |
19 Combining Policy Classes | 14 |
The Phoenix Singleton | 137 |
Singletons with Longevity | 139 |
68 Implementing Singletons with Longevity | 142 |
69 Living in a Multithreaded World | 145 |
610 Putting It All Together | 148 |
611 Working with SingletonHolder | 153 |
612 Summary | 155 |
Smart Pointers | 157 |
110 Customizing Structure with Policy Classes | 16 |
111 Compatible and Incompatible Policies | 17 |
112 Decomposing a Class into Policies | 19 |
113 Summary | 20 |
Techniques | 23 |
22 Partial Template Specialization | 26 |
23 Local Classes | 28 |
24 Mapping Integral Constants to Types | 29 |
25 TypetoType Mapping | 31 |
26 Type Selection | 33 |
27 Detecting Convertibility and Inheritance at Compile Time | 34 |
28 A Wrapper Around type_info | 37 |
29 NullType and EmptyType | 39 |
210 Type Traits | 40 |
211 Summary | 46 |
Typelists | 49 |
32 Defining Typelists | 51 |
33 Linearizing Typelist Creation | 52 |
34 Calculating Length | 53 |
35 Intermezzo | 54 |
36 Indexed Access | 55 |
37 Searching Typelists | 56 |
38 Appending to Typelists | 57 |
39 Erasing a Type from a Typelist | 58 |
310 Erasing Duplicates | 59 |
311 Replacing an Element in a Typelist | 60 |
312 Partially Ordering Typelists | 61 |
313 Class Generation with Typelists | 64 |
314 Summary | 74 |
315 Typelist Quick Facts | 75 |
SmallObject Allocation | 77 |
41 The Default Free Store Allocator | 78 |
43 A SmallObject Allocator | 80 |
44 Chunks | 81 |
45 The FixedSize Allocator | 84 |
46 The SmallObjAllocator Class | 87 |
47 A Hat Trick | 89 |
48 Simple Complicated Yet Simple in the End | 92 |
49 Administrivia | 93 |
410 Summary | 94 |
Components | 97 |
Generalized Functors | 99 |
51 The Command Design Pattern | 100 |
52 Command in the Real World | 102 |
53 C++ Callable Entities | 103 |
54 The Functor Class Template Skeleton | 104 |
operator | 108 |
56 Handling Functors | 110 |
57 Build One Get One Free | 112 |
58 Argument and Return Type Conversions | 114 |
59 Handling Pointers to Member Functions | 115 |
510 Binding | 119 |
511 Chaining Requests | 122 |
Heap Allocation | 124 |
514 Implementing Undo and Redo with Functor | 125 |
515 Summary | 126 |
Implementing Singletons | 129 |
61 Static Data + Static Functions Singleton | 130 |
62 The Basic C++ Idioms Supporting Singletons | 131 |
63 Enforcing the Singletons Uniqueness | 132 |
64 Destroying the Singleton | 133 |
65 The Dead Reference Problem | 135 |
72 The Deal | 158 |
73 Storage of Smart Pointers | 160 |
74 Smart Pointer Member Functions | 161 |
75 OwnershipHandling Strategies | 163 |
76 The Addressof Operator | 170 |
77 Implicit Conversion to Raw Pointer Types | 171 |
78 Equality and Inequality | 173 |
79 Ordering Comparisons | 178 |
710 Checking and Error Reporting | 181 |
711 Smart Pointers to const and const Smart Pointers | 182 |
712 Arrays | 183 |
713 Smart Pointers and Multithreading | 184 |
714 Putting It All Together | 187 |
715 Summary | 194 |
Object Factories | 197 |
81 The Need for Object Factories | 198 |
Classes and Objects | 200 |
83 Implementing an Object Factory | 201 |
84 Type Identifiers | 206 |
85 Generalization | 207 |
86 Minutiae | 210 |
87 Clone Factories | 211 |
88 Using Object Factories with Other Generic Components | 215 |
89 Summary | 216 |
811 CloneFactory Class Template Quick Facts | 217 |
Abstract Factory | 219 |
92 A Generic Abstract Factory Interface | 223 |
93 Implementing AbstractFactory | 226 |
94 A PrototypeBased Abstract Factory Implementation | 228 |
95 Summary | 233 |
Visitor | 235 |
102 Overloading and the CatchAil Function | 242 |
The Acyclic Visitor | 243 |
104 A Generic Implementation of Visitor | 248 |
105 Back to the Cyclic Visitor | 255 |
106 Hooking Variations | 258 |
107 Summary | 260 |
108 Visitor Generic Components Quick Facts | 261 |
Multimethods | 263 |
111 What Are Multimethods? | 264 |
Brute Force | 265 |
11 4 The BruteForce Approach Automated | 268 |
115 Symmetry with the BruteForce Dispatcher | 273 |
116 The Logarithmic Double Dispatcher | 276 |
117 FnDi spatcher and Symmetry | 282 |
static_cast or dynamic_cast? | 285 |
Raw Speed | 290 |
1111 BasicDispatcher and BasicFastDispatcher as Policies | 293 |
1112 Looking Forward | 294 |
1113 Summary | 296 |
1114 Double Dispatcher Quick Facts | 297 |
A Minimalist Multithreading Library | 301 |
A1 A Critique of Multithreading | 302 |
A2 Lokis Approach | 303 |
A4 Mutexes | 305 |
A5 Locking Semantics in ObjectOriented Programming | 306 |
A6 Optional volatile Modifier | 308 |
A7 Semaphores Events and Other Good Things | 309 |
311 | |
313 | |
Andere Ausgaben - Alle anzeigen
Modern C++ Design: Generic Programming and Design Patterns Applied Andrei Alexandrescu Eingeschränkte Leseprobe - 2001 |
Modern C++ Design: Generic Programming And Design Patterns Applied Alexandrescu Keine Leseprobe verfügbar - 2001 |
Häufige Begriffe und Wortgruppen
Abstract Factory AbstractProduct algorithm application atexit base class BaseLhs BaseLhs& BasicDispatcher behavior bool callback Chapter char Chunk class BaseRhs class hierarchy class template class TList Clone Command pattern compile-time compiler concrete ConcreteFactory const constructor copy create deallocation default define delete derived design pattern destructor DocElement DocElementVisitor double dispatcher dynamic cast dynamic_cast example FixedAllocator Functor FunctorImpl GenLinearHierarchy GenScatterHierarchy implementation inheritance instantiation interface invoke locking Loki member function memory multimethods multiple multithreading mutex NullType object factory object of type operator operator delete OpNewFactoryUnit overload partial template specialization pInstance_ pointee object pointee_ policy classes polymorphic problem raw pointer Rectangle Rectangle& reference counting result ResultType runtime semantics SetLongevity Shape Singleton Singleton object SingletonHolder SmallObjAllocator SmallObject smart pointer static StaticDispatcher struct template class template parameter template<typename thread ThreadingModel type identifier type_info typedef typedef typename typelist unsigned virtual function visited Widget WidgetManager
Verweise auf dieses Buch
Developing Software with UML: Object-oriented Analysis and Design in Practice Bernd Oestereich Keine Leseprobe verfügbar - 2002 |
Generative Programming and Component Engineering: 4th International ... Robert Glück Eingeschränkte Leseprobe - 2005 |