THE READING ROOM / BOOK GUIDE
Modern C++ Design
A book about generic programming in C++ that treats templates as a design tool, showing how policy classes and compile-time techniques can produce flexible, reusable libraries.
About the book
Andrei Alexandrescu builds the book around a specific thesis: C++ templates let library designers assemble behavior from interchangeable parts at compile time, avoiding the runtime cost of flexibility. The subject is generic programming in C++, approached as a design discipline rather than a syntax tour.
The work is known for introducing and developing policy-based design, in which a class's behavior is composed from small policy classes chosen by the user. It also covers type lists, compile-time assertions, and the machinery behind smart pointers and object factories. These appear as reusable components and as examples of a way of thinking about library interfaces. The emphasis falls on how to structure code so that variation is explicit and checked by the compiler.
Because the book is a design text rather than a language reference, it assumes the reader already knows C++ syntax and is ready to consider trade-offs in interface design. The material reflects the language as it stood when the book was written, which matters for how the examples read today.
How to read it
Approach the book as a sequence of design problems. Each technique answers a question about how to make a library component configurable without runtime cost, and the reasoning behind the choices carries more lasting value than any single idiom. Read the code examples closely and try to reconstruct why a particular structure was chosen before moving on.
The difficulty is real. Template metaprogramming demands patience with compiler errors and with code that looks unlike ordinary C++. Readers unfamiliar with templates will want a solid intermediate grasp first. The prose is direct and technical, so slow reading of the central chapters pays off more than skimming for recipes.
Who it suits
This book suits C++ programmers who write or maintain libraries and want to understand the design reasoning behind policy-based composition and compile-time techniques. It also helps developers who encounter heavily templated code and want to read it with more confidence. Readers seeking an introduction to the language itself should look elsewhere.
Reading considerations
The examples predate later revisions of C++, so some techniques have been superseded by newer language features. Treat the book as a source of design ideas and historical context, and check current practice before adopting any idiom in new code.
Follow the HN conversation
29 different recommenders are recorded in the upstream dataset. These are AI-classified source counts, not an independent rating.
Search HN comments about this book ↗
Explore videos on the same subject ↗
Book notes prepared with DeepSeek, using catalogue records and Open Library subject information. They are reading guidance, not a personal review or a verified chapter-by-chapter account. Book details can vary by edition. HN data methodology · Book metadata and covers.
