Jump to ratings and reviews
Rate this book

Modern C++ Design: Generic Programming and Design Patterns Applied

Rate this book
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." -Herb Sutter

"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 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:


Policy-based design for flexibility Partial template specialization Typelists-powerful 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. 0201704315B11102003

351 pages, Kindle Edition

First published February 1, 2001

94 people are currently reading
1065 people want to read

About the author

Andrei Alexandrescu

11 books27 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
419 (47%)
4 stars
304 (34%)
3 stars
118 (13%)
2 stars
31 (3%)
1 star
10 (1%)
Displaying 1 - 28 of 28 reviews
Profile Image for Alasdair Craig.
287 reviews14 followers
May 24, 2017
I don't know who the intended audience is. Don't read this if you think it's about templates, it's more about making templates do clever tricks for you. And by clever I mean cryptic, obfuscated and questionable in their usefulness in the real world. I kept on thinking that the next chapter would be more relevant to me, but three quarters of the way through just gave up. I see no relevance to my work and personal programming.
Author 1 book3 followers
April 22, 2019
Книжка, в общем-то, читается вполне нормально даже спустя столько лет. Достаточно годная первая часть про Techniques. Первые три главы даже перечитал. Вторая часть местами ок, местами не очень. Читать про реализацию абстрактной фабрики можно из общего интереса, но как только появляются GenScatterHierarchy/GenLinearHierarchy сразу кажется, что что-то идёт не так. Как руководство к написанию production-кода стоит воспринимать с осторожностью, потому что кому-то это всё потом поддерживать.
Profile Image for Joshua.
4 reviews2 followers
February 26, 2014
Lots of clever tricks that would be terribly difficult to use and maintain in any medium sized code base.
Profile Image for Jacobo.
23 reviews15 followers
August 1, 2012
Este libro es sencillamente alucinante, de principio a fin. Es un libro para admirar al autor por la librería increíble que construye, poco a poco, capítulo tras capítulo, usando unas técnicas que van mucho más allá de la programación en C++ que muchos estamos acostumbrados a ver, usando metaprogramación para crear, en unas pocas líneas código, diseños que serían mucho menos efectivos o prácticamente imposibles de mantener de ninguna otra manera.

Doblemente alucinante al pensar que el libro está publicado en el año 2000, antes incluso que el estándar anterior al actual, y que, 12 años, después, sigue teniendo este potencial de dejar al lector tremendamente inquieto.

La advertencia es clara: leer este libro te cambia como programador de C++, y para bien sin duda. Un libro que estoy seguro volveré a leer.
Profile Image for Минчо Паскалев.
7 reviews1 follower
April 21, 2020
Great book, delving into the specifics of template meta programming (but not too deep, mind you). Although, you can find a lot of gems in it, beware - it is rather outdated, dealing with the ancient C++03!
There are a few chapters a few chapters about making a list of types (yes, types!) with templates (they are really similar to LISP lists); one chapter about writing an allocator for small objects and a neat implementation of the visitor pattern. For me these alone are enough to read the book!
25 reviews
July 11, 2022
Brings back nostalgia. The techniques taught are as of now completely out of date, but the amount of creativity and ingenuity of Alexandrescu in implementing useful structures using esoteric meta-programming techniques are without match. Necessary read for anyone interested in the weird side of C++. Also try to stay up to date and avoid the monstrousities showcased here, but if your codebase is old and there are no alternatives, then this book might prove immensely useful!
Profile Image for Benoit Blanchon.
Author 2 books7 followers
November 21, 2018
One of the best technical book I've read.
Great content and great writing style.
I wish I had read it earlier.
Profile Image for Haitham Gad.
8 reviews2 followers
May 20, 2015
Gives a lot of insights about the various aspects and tradeoffs pertaining to the implementation of generic design patterns in C++, as well as the motivation behind each pattern. Policy-based design, described and utilized abundantly in the book, is also a powerful design technique for building generic components. The book is a bit outdated though. For example, Typelists, the vehicle he uses to build many of his patterns, is no longer needed given the introduction of variadic templates in C++11.
6 reviews
Read
July 16, 2015
Read it front to cover, now it's time to read it again -- so much good stuff!

Most of the development I've done last decade has been in C++, so I thought I'd seen it all. Couldn't have been further from the truth - wow; there's so much more to learn! Imagine all this was out there while I was using Boost (but never dared to look inside).

Alexandrescu is a great narrator, so even though he treats some deep and technical stuff he never loses his reader and frequently succeeds in making his tricks look trivially easy.
19 reviews4 followers
July 7, 2010
If it was for the fact that many of the topics covered in the book were so advanced that they are not applicable to day to day software development, I'd give the book 5 stars.

I was introduced to generic programming and Andrei's book at a presentation by Martin Fowler. I have to share Fowler's view that Alexandrescu is at a level beyond most of us. However, even though I don't find the book applicable to my day to day job, I do find it stimulating and revisit it from time to time.
Profile Image for Sergey Zubov.
11 reviews1 follower
November 19, 2013
Если вы знаете как работают механизмы обобщенного программирования в языке C++, но не знаете как их применить, то эта книга для вас. Не смотря на то, что с момента издания прошло уже больше десятилетия и некоторые техники описанные в книге утратили свою актуальность с выходом C++11, основные принципы обобщенного программирования остаются прежними, поэтому книга актуальна и по сей день. Главное относится к изложенным идеям прагматично.
Profile Image for Jean-Luc.
278 reviews35 followers
July 12, 2008
Not the type of book you'd read w/out at least a few other C++ programming and software design books under your belt... Not to mention a couple years in the field to build up some experience. Still, if you've ever used the boost libraries, the first 4 chapters will really help you understand the design philosophies.
117 reviews1 follower
December 27, 2016
I was already quite proficient at C++, but using generics was still a bit of a mystery. This book helped me enormously in exploring what was possible. I remember how intellectually stimulating this book was, hence the five-star rating.

Haven't used this since 2005 I guess, when work switched to Java.
Profile Image for Jose Sanz.
Author 15 books18 followers
Read
September 23, 2021
I know this is an important book, usually mentioned as one of the books you must read for c++, but I think is intended for library developers. I you are a plain application developer this is too much. It would be nice to understand the tecniques, even if you are never going to use them, but I still think is not worth the effort.
Profile Image for Andreas.
631 reviews42 followers
March 30, 2020
Great book. It takes some time to understand the concepts but it's this kind of meta-programming that will save you later a lot of work.

Highly recommended for every advanced C++ programmer. This is not a book for beginners.
2 reviews
March 26, 2014
While some of his concepts are now a little outdated with C++11 (in the sense that it can now be implemented much easier) this is still a great book the shows the power and possibilities of C++ template meta-programming.
Profile Image for Vladimir.
29 reviews9 followers
February 22, 2016
As Scott Meyers once wrote that C++ is a confederation of 4 languages - C, Object-oriented C++, Templates and the STL.
This book is a must read to understand the template language of the confederation - if you want to write type-safe, minimum duplication code.
Profile Image for Zahir.
8 reviews1 follower
August 4, 2015
Needs great understanding of template machinary, but this is one of C++ In-Depth Series, and this book is nailing it. Provides neat and modern implementations for some GoF patterns in C++.
I'd also like to see some C++11 additions or modifications for the implementations too.
Profile Image for Rutvij.
4 reviews
July 22, 2016
Rather than direct application, what I learned from this book was how to think creatively while being bound by your tools. Alexandrescu is thoughtful, funny and very engaging. He starts off simple and builds a (sometimes messy) fortress. Overall a very fun and interesting book.
Profile Image for Danien.
44 reviews
March 11, 2010
Some good ideas and discussions, like policy-based design, but some overcomplicated ones like type lists.
1 review
July 21, 2011
Advanced book .. initially when i tried to read in coll days i had tough time understanding. If you are really experienced programmer you can understand easily.
Profile Image for Eugene Popovych.
13 reviews1 follower
February 11, 2015
Outdated a little bit, but still a classic. Sheds light on many modern C++ features.
1 review
August 23, 2016
Awesome book. Alexandrescu in that book defined Policy-based design and Typelists. One of watershed books in C++ world
Profile Image for Ken.
87 reviews1 follower
January 10, 2018
Some interesting thoughts on the mechanics of templates and using templates for policies, but the specific class implementations in the last two-thirds of the book are dated and not really worth it.
Displaying 1 - 28 of 28 reviews

Can't find what you're looking for?

Get help and learn more about the design.