"Modern C++ Design" by AndreiAlexandrescu (ISBN 0201704315 )
See http://www.moderncppdesign.com/ One of the books in the CppInDepthSeries published by AddisonWesley.
"Mandatory" book for the following categories:
I haven't finished reading it yet, but it seems to be re-inventing well-known OO concepts in C++ at compile-time instead of run-time. It seems like a big waste of a programmer's time to use template meta programming to do stuff that could be done easily in Smalltalk via polymorphism, dynamic dispatch, etc.
That's nice, but this is a book on how to do these things in C++, and in ways that trade a compile-time processing cost for a reduction in run-time cost. So what if another language can do them at run-time? If a programmer has other reasons for using C++, then why would it be a waste of time to learn how to do these things in C++?
Another take: The book tells you how to use C++ to implement well-known OO concepts. That sounds nice to me -- I'd like a book that explains how to do OO programming in C++!
What's more interesting to me is how Lisp-like much of the techniques are. C++ templates are very much like a FunctionalProgrammingLanguage, so many of the techiques look a lot like reimplementing Lisp features using the template features of C++. Perhaps it's GreenspunsTenthRuleOfProgramming. The disheartening thing to me (as a C++ programmer and non-SmugLispWeenie) is how baroque the implementation has to be, mostly because of StaticTyping.
The first chapter of this book is called PolicyBasedClassDesign and what is surprising to me is that there is not yet a page on WikiWiki for this topic. The book also introduced a library called Loki which implements a lot of interesting things. Some of these are also available in different forms in the BoostLibraries.
Generic versions of VisitorPattern and AcyclicVisitor are discussed in Chapter 10 and implemented in Loki.
See also TemplateMetaprogramming CuriouslyRecurringTemplate
CategoryBook CategoryCpp CategoryCppTemplates CategoryMetaprogramming