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.


  1. You missed a word on page 104: How safe is *it* to replace a macro that defines an integer with a constant ...

    Good book, although I'm finding it rather frightening as a not so advanced C++ programmer.

  2. Good catch, thanks.
    The topic itself is borderline, because it requires some paradigm change in the programmer; I have seen BIG companies which are scared to death by metaprogramming, so while they claim to hire the smartest people in the galaxy, they contradict themselves by completely banning any c++ technique which is more advanced than "int i = 0" :)
    The truth is probably somewhere in the middle: not every problem can be optimally solved with metaprogramming, but if used wisely, it's an arsenal that will save you a lot of time.

    If you like the book, remember to post a review on