Advanced C++ Metaprogramming

by Piotr Likus on October 10, 2015
Overview
Item Reviewed

Advanced C++ Metaprogramming

Author
October 10, 2015
Book author(s)

Davide Di Gennaro

Publisher

Amazon

ISBN(s)

9781460966167

Pages

534

Publication year

2011

Overview

C++ metaprogramming is something that many people skip or avoid as most complicated part of the language. In fact it should be one of most important reasons to still use C++ today – not many languages have such an advanced solution for compile-time, static-typed computations. Current version of C++ (in 2015) has still some limits in template handling – but you can write solutions that ignore them and push the language to it’s limits. The book is full of “make something unreal” tips which you can use in your new data structure or algorithm implementation. Inside the book you will find explanations of some popular C++ idioms like SFINAE, S.C.A.R.Y initialization, tagging or type traits.

Which parts I found most useful? There is no such a part. Whole book, from first to last page is important and I would have problems finding parts which could be omitted. This is because the author does not use long descriptions like for example Scott Meyers. He just shows the code examples and provides necessary explanations. Maybe you can skip some of the topics if you are not interested now in them – but in the same time they can present tips that could be useful when applied to something different.

In summary, I will have to read this book again in the future – the tricks it contains are so specific that you can easy forget them, but still, when you read it, you feel it is something you will need. There is also third edition published by Apress that probably is rewritten as the author writes at his blog (see below) that at least one chapter could be written better. You need to remember that some of these solutions can be now obsolete in the presence of C++11 new additions (static_assert, enable_if), but most of the book is still valid today.

What you will learn

Anything you afraid to ask about C++ template programming. Lots of language-specific tricks that can be used for compile-time calculations, type information building and data structure definition.

Table of contents

Part I

  1. Templates

  2. Small Object Toolkit

Part II

  1. Static Programming

  2. Overload Resolution

  3. Interfaces

  4. Algorithms

  5. Code Generators

  6. Functors

  7. Opaque Type Principle

Part III

  1. Refactoring

  2. Debugging Templates

  3. C++0X

  4. Appendix A: Exercises

  5. Appendix B: Bibliography

Summary

If you have a need to push the limits of C++ templates, this book will open few doors for you. I recommend buying third edition or later to avoid mistakes.

Resources

Book home page: Advanced C++ Metaprogramming – erratas

Positives

* very useful & long list of C++ template tricks
* follows well-known idioms
* code descriptions cut to minimal

Negatives

* can be little outdated in the presence of C++11/14 (but not too much)

Rating
Our Rating
User Rating
Rate Here
Rating
Bottom Line

This book is a must for serious C++ programmer. Keep in mind it uses tricks which can be obsolete in future C++ versions.

Total Score
User Score
You have rated this
Fonts by Google Fonts. Icons by Fontello. Full Credits here »