Wednesday, October 3, 2012

Book review (in German)

"Wer Templates auf einem hohen Niveau meistern möchte, für den ist "Advanced C++ Metaprogramming" Pflichtlektüre"

Thursday, July 26, 2012

Monday, June 11, 2012

Section 5.2.2

This section was an unfortunate mix of unexpressed ideas, a couple of mistakes and a poor structure.
I'm reposting the entire section here, hopefully it should be better.


Casual readers, please don't take this file as a meaningful sample of the quality of the book.

Tuesday, May 8, 2012

Sunday, April 15, 2012

Fresh typos

Section 6.4.2

There's a missing &:

should be:


The code for rebuild says:

const vtable* oldvt = vt;
vt = vtable_singleton<void>::get(); 
(vt->construct)(storage_, src);
vt = newvt;

But it should be:

const vtable* oldvt = vt;
vt = vtable_singleton<void>::get(); 
(newvt->construct)(storage_, src);
vt = newvt;

The pointer has been replaced by a dummy for exception safety, so obviously vt will do nothing. 
Note that you should not swap lines #4 and #5

Section 6.3.5

There's a pointer to a type called fptbl_t, which does not exist.
It's actually called virtual_function_table (fptbl stands Function Pointer TaBLe)

There's an incorrect function call, spelled table.del(p). But table is a pointer, so it should read: (table->del)(p)

Section 6.3.6

The function safe_cast, has an argument called p but the code calls it src.

Section 5.2.1

The class string_traits contains typedefs argument_type and char_type, but for compactness, they are later referred to as arg_t and char_t.

Sunday, April 1, 2012

Typos that survived in the second revision

I'm showing the section numbers, instead of pages, because they are valid in both revisions.
  1. In section 4.6.7 about template rotation, there's some confusion between a template parameter called Dn and D9: the intent is that D9 is the last in the series, so it should be called Dn and D8 is thus Dn-1.
  2. In section 4.6.6 there's a spurious comma: template <P1, P2, = default...> should read template <P1, P2 = default...> 
  3. In section 4.3.1 [[CONDITION]] is mis-spelled as [[CONDITION]

Wednesday, March 14, 2012


I keep receiving the same questions over and over, so I decided to publish the official answers here (but I tend to reply to individual messages anyway, when feasible).

Q: How do I tell if I have the first revision or the second?
A: In the first page, you can see the list of revisions (the last is the current)

First revision: 2011-05-15 
Second revision: 2012-02-07

Q: Is the second revision on sale?
A: YES, and it should be on sale everywhere; the book is printed on demand.

Q: What are the differences between rev.1 and rev.2?
A: Mostly cosmetic: I changed some styles in the template, fixed all the typos and all the problems that are mentioned in this site, added an index and added a couple of paragraphs. The differences are not enough to call it "second edition", that's why I prefer the name "rev.2".

Q: Your fixes didn't involve C++11. In rev.2 you still say: "the next standard", etc.
A: Yes, this is a book published in early 2011, and a revision does not change this fact. rev.2 is "how the book should have been since the beginning", not "how the book would be today".

Q: But you don't mention variadic templates...
A: Yes, it's correct and on purpose. I believe C++0x is not something that you can just mention, and the focus of the book is on C++03.

Q: If I send you a photo, can I have a pdf?
A: Generally not. I published a similar offer, stating very clearly that it was valid for about one week. The idea was to give a cheap upgrade to rev.2 to all the people who bought rev.1 just before rev.2 was on sale. If you think this general principle holds true in your case (so: you have the paper book rev.1, and you bought approximately late February 2012), write me anyway and we can discuss.

Q: Is there any other way to get a pdf?
A: YES. As promised in the book, if you find a (new) typo and you explicitly ask for it, I'll send you the pdf.

Monday, February 27, 2012

New Table of Contents

The second revision is on sale, even if Amazon didn't update the "look inside" preview yet.
Here's the new table of contents.

Friday, February 24, 2012

PDF Offer Officially Expired

I just sent the PDF to all the readers who requested it.
Since the majority asked not to publish their photo, I decided to publish none of them.

Enjoy the second revision.

Thursday, February 16, 2012

Second revision available soon

It's not really a second edition, it's jut a revised version, which also includes feedback from the readers.
Visually more appealing, less typos and a couple of additional paragraphs.

If bought the book, write me an email with your photo holding the book, and I will send you back the pdf of the new revision. Offer valid until February 24 (excluded).

On February 24, I'll collect all the eligible recipients and send the file.
Please, state explicitly in the email if you allow the photo to be published on this site.