BOOK / SOURCE & READING RECORD
Modern C++ Design: Generic Programming and Design Patterns Applied
Andrei Alexandrescu
1st edition, 2001
Modern C++ Design: Generic Programming and Design Patterns Applied
Fully read the readable body text and textual code of chapters 1–11 and Appendix A of the 2001 first edition: policies, techniques, typelist, small-object allocator, generalized functors, singleton, smart pointers, factory, abstract factory, visitor, multimethods, and threading discussion. Private full-text extraction totaled 16,122 lines, read continuously in segments with supplementary reading of the truncated range 216–554; also read the publisher’s chapters 1, 7, 8, and 11 for cross-checking. C++98 and platform threading techniques in the book are understood as historical material, not as recommended C++20 implementations.
Edition, actual reading range, and original sources →Sources
- Chapter 1 Policy-Based Class Design
Complete Chapter 1, book pages 3–21.
- Chapter 7 Smart Pointers
The entire body of 7.1–7.14 of the online print version was read.
- Chapter 8 Object Factories
Complete Chapter 8, book pages 197–218.
- Chapter 11 Multimethods
Complete Chapter 11, book pages 263–300.
- Author’s book page
Book description and purchase guidance; not the full book.
Policies are interchangeable choices, not template decoration
Chapter 1 §§1.5, 1.9, 1.12; Chapter 7 ownership-policy discussion; Chapter 8 §8.5 error-handling policy.
Policy-based design truly separates independent decisions, rather than rewriting every member function as a template. The host is responsible for maintaining the overall flow; a policy is responsible for one nameable point of variation. If two policies must know each other’s internal state, they are no longer orthogonal. The original book implements composition via multiple inheritance and C++98 techniques, but those are merely the mechanisms of the time. Modern code can express the required calls through member composition and concepts, without copying historical implementations of handwritten smart pointers, destructive copy, or safe-bool. An error-handling policy may choose to reject or truncate, but should not secretly change the capacity-checking rules. Generalization should also have a stopping condition: when there is no actual second choice, an ordinary function is usually easier to maintain than a policy framework.
Related fundamentals
Concepts and requires: Constraining Callable InterfacesTemplate deduction: match parameters first, then instantiate codeSmart Pointers: Choosing an Ownership Vocabulary