Enter your mobile number or email address below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.
To get the free app, enter your mobile phone number.
Advanced C++ Metaprogramming Paperback – June 14, 2011
The Amazon Book Review
Author interviews, book reviews, editors picks, and more. Read it now
Customers who bought this item also bought
What other items do customers buy after viewing this item?
About the Author
Davide Di Gennaro loves to introduce himself as a mathematician, but a better definition would be a philosopher. After studying history of art and functional analysis for some years, he switched to algorithm design and C++. He has been showing the marvels of metaprogramming techniques since the late nineties: as nobody could really understand him, he was eventually nicknamed "the professor".
He works for big companies, where his real identity is ignored, and he spends his free time as a photographer.
Someone said that "he makes the impossible possible". --This text refers to an alternate Paperback edition.
Top customer reviews
But as soon as I read chapters 2 and 3 I realized this book is very different.
The first chapters explain in a clear way all that most people need to know about templates and template metafunctions,
and provide the reader with a very practical set of ideas that can immediately be implemented in the code you're working on.
For example, I started using static assertions and tagging almost immediately.
Then the real meat starts, with chapter 4 explaining in detail how to write metafunctions and then proceeding to overload resolution in chapter 5.
Before reading this, I thought this was mostly relevant to compiler writers, but Di Gennaro's explanation of how to exploit SFINAE was really useful
to me, in fact I started using only_if in my code on the same day I read the section.
After this, Advanced C++ Metaprogramming really gets "Advanced" and explains many practical ways of programming with templates,
ensuring that the most amount of computation is executed at compile time. There is a very good section on Lambda expressions, though I've not had the chance to use them yet.
Besides the tools that this book teaches, I think its biggest strength is that difficulty progression is so well calibrated that by the time I finished the book I really have become a better programmer. My way of thinking about my code has changed. Now I see new possibilities, and I try to see if things can be done at compile time using templates.
I will definitely put this book next to my other all-time favourite, Inside the C++ Object Model by Lippman.
Advanced C++ Metaprogramming has the potential to become a classic.
Ultimately it has changed my mind in believing that meta-programming has no place in production development. I had read C++ Templates, Modern C++ Design, and I also looked into Boost MPL. The pieces didn't quite click for me with the resources I referenced before I found this book.
I read through the first few chapters intrigued by the techniques, but still did not see where to apply the concepts.
When I found a problem that I thought could be solved effectively with meta-programming, I found myself returning primarily to this book. The other template resources that I mentioned are great references. This book seemed to provide the content for me to make the leap from learning about meta-programming, to applying meta-programming into robust production solutions.
At first I found the format of the book a bit odd and cumbersome like the reviewers that gave low scores. However, I quickly got passed that once I became familiar with how the book is organized.
This is a complex subject. I would not assume that just because you know C++ and how to use STL that this book will make much sense to you. I had no context for much of the content in the book until I set out to solve a problem and kept reading over the different techniques until I found something that I thought might work.
Meta-programming in C++ forces you to approach problems from a different perspective. If you are not strong or at least familiar with functional programming styles, I would expect to struggle with the concepts presented in the book at first. Chapters 3 and 4 are excellent for understanding how to get started.
If you don't own a book on C++ templates, I would start out with "C++ Templates" by Vandevoorde and Josuttis.
If you would like a gentle introduction to meta-programming, start with "Modern C++ Design" by Alexandrescu.
I never bought "C++ Template Meta-programming" by Abrahams because it is highly dependent on Boost.MPL.
After all of those, if you would like a book to tie all of the pieces together and take you beyond, I believe this book does a great job in that role.
Of course, there are several books available in terms of C++ template metaprogramming. However, this book impressed me very much, its coverage and depth of the contents written there. This book must be the best!
I hope that after completing this book, I should be able to write much more efficient and type-safer, extensible code. And I'm now a sort of convinced that I can.
Most recent customer reviews
Not the syntax, but the design idea.Read more
If you use templates you should get it.
The only tiny issue with the book it needs some proof reading.