Nicolai M. Josuttis: solutions in time  C++ Templates: Errata for the 1st Printing

C++ Templates - The Complete Guide

Errata for the 1st Printing
Jan 26, 2003

This is the errata of the 1st printing of the book C++ Templates by David Vandevoorde and Nicolai M. Josuttis.It covers all errors that were found until the 2nd printing came out. Thus, you will find additional errors in the erratas for the following editions.
The errata is organized in the following way:
- The first part lists technical errors
- The second part lists typos
- We also have a supplementation


Errors

Page 45, Section 5.2
The example is a bit confusing because exit() is called without any argument and the standard exit() expects an integer argument for the exit status. In fact, we don't say anything wrong ("calls external exit() or error"); that is, either you provide a global exit() function with no parameters or this call is an error. Nevertheless, it would probably better to avoid this unexpected form of an exit() function and use a different name.

In any case you should remove "(such as the standard exit())."

Page 49, Section 5.3, basics/stack6assign.hpp and
Page 54, Section 5.4, basics/stack8.hpp:
In the implementation of the assignment operator
     Stack<T2> tmp(op2);
should be declared as follows:
    Stack<T2,CONT2> tmp(op2);

Page 52, Section 5.4, basics/stack8.hpp:
The header file for allocators has to be <memory> instead of <allocator>.

Page 132, Section 9.3.3:
Two typename are missing and twice N has to be used instead of T. Thus, class Weird has to be declared as follows:

   template<typename T, int N> 
   class Weird {
   public:     void case1 (typename Shell<T>::template In<N>::template Deep<N>* p) {         p->template Deep<N>::f(); // inhibit virtual call        }     void case2 (typename Shell<T>::template In<N>::template Deep<N>& p) {         p.template Deep<N>::f(); // inhibit virtual call        } };

Page 312, Section 17.4:
Using IfThenElse<> leads to a number of instantiations that is even proportional to the square root of N. Thus, replace "log2(N)" by "sqrt(N)."

Page 366, Section 20.1.1:
At the bottom of the page, replace "return result;" by: "delete ptr;"

Page 425 and 426, Section 22.3:
The syntax of pointer-to-member functions requires some more parenthesis than we wrote. Therefore:
On page 425, replace
  void call_memfun(D obj, void D::*pmf())
  {
    obj.*pmf();
  }
by the following:

  void call_memfun(D obj, void (D::*pmf)())
  {
    (obj.*pmf)();
  }
On the same page, replace
  void D::*pmf_a()  = &D::mf2;
  void B2::*pmf_b() = (void (B2::*)())pmf_a;
by the following:
  void (D::*pmf_a)() = &D::mf2;
  void (B2::*pmf_b)() = (void (B2::*)())pmf_a;
And on page 426, replace
  obj.*pmf(...)
  ptr->*pmf(...)
by the following:
  (obj.*pmf)(...)
  (ptr->*pmf)(...)

Page 477, Section A.3.1:
The second bullet says:
     "... and with the static specifier"
but it should be
     "... and without the static specifier"
(There is essentially the same remark in a correct form repeated on the beginning of the next page.)


Typos

Page 19: s/Template functions/Function templates/

Page 48: s/stack of ints/stack of strings/

Page 61: s/.c, or .hxx/.c, or .cxx/

Page 76: s/be omitted/be emitted/

Page 91: s/precicely/precisely/

Page 96: s/class Collection::Node {/class Collection::Handle {/

Page 102: s/Container<T, MyAllocator>/Container<int, MyAllocator>/

Page 103: s/&Lexer<Buf>::storage/&Lexer<Buf>::storage[0]/

Page 108: s/List<Assocation*>/List<Association*>/

Page 109: s/C<void (*)(int), &f>* c3;/C<void (*)(int), f>* c3;/

Page 114: s/class class/class/

Page 115: s/friend/friend void/ (five times)

Page 127: s/C a; // OK: same as ``C<T> a;''/C* a; // OK: same as ``C<T>* a;'' /

Page 127: semicolon missing at the end of the declaration of class C

Page 128: s/B<(1>0)>::result/Invert<(1>0)>::result/

Page 145: s/zero of negative/zero or negative/

Page 159: s/When closure is been achieved/When closure has been achieved/

Page 172: s/class D : B<T> {/class D : public B<T> {/

Page 182: s/T* p = &a[0];/T* p = &(*a)[0];/

Page 182: s/T* q = &b[0];/T* q = &(*b)[0];/

Page 182: s/--k != 0;/k-- != 0;/

Page 192: s/void S<char**>::print()/void S<char**>::print() const/

Page 196: s/f(0)/g(0)/

Page 198: s/void Outer<void>::print()/void Outer<void>::print() const/ (twice)

Page 201: s/should either be/should be either/

Page 202: s/to have more parameters/to have more or fewer parameters/

Page 210: s/Bracket<T>::address/Bracket<str>::address/

Page 210: s/Bracket<T>::bytes/Bracket<str>::bytes/

Page 216: s/Array<typeof(x+y)>;/Array<typeof(x[0]+y[0])>;/

Page 216: s/Array<typeof(exp(x, y))>/Array<typeof(exp(x[0], y[0]))>/

Page 216: s/virtual Base clone();/virtual Base* clone();/

Page 216: s/
virtual Derived clone();/virtual Derived* clone();/

Page 216: s/have type Base/have type Base*/

Page 217: s/We should note at this point, that/We should note at this point that/

Page 220: s/std::type<T>::has_member_type<"Index">/!std::type<T>::has_member_type<"Index">/

Page 231: s/these mechanism/these mechanisms/

Page 233, 234, 237, 239: s/inhomogeneous/heterogeneous/

Page 238: s/both forms of polymorphisms/both forms of polymorphism/

Page 239: s/both forms of inheritance/both forms of polymorphism/

Page 243: s/functionally such as/functionality such as/

Page 243: s/Iterator i1(s);/Iterator i1(c1);/

Page 243: s/Iterator i2(b);/Iterator i2(c2);/

Page 249: s/assume T()/assume AccT()/

Page 250: s/assume T()/assume AccT()/

Page 250: s/Type T may/Type AccT may/

Page 256: s/change is total += *start/change is total += *beg/

Page 258: s/advantegous/advantageous/

Page 262: s/assume T() actually creates a zero value/assume VT() actually creates a zero value/

Page 266: s/invalid for function types/invalid for class types/

Page 281: s/T tmp(a);/T tmp(*a);/

Page 302: s/twice the corresponding value/three times the corresponding the value/

Page 305: s/The latter represent/These optional parameters represent/

Page 314: after "in both vectors" insert: "(for the sake of simplicity, we do not consider complex arithmetic in our example)"

Page 314: s/if each vectors has/if each vector has/

Page 314: s/T result = 0;/T result = T();/

Page 329: s/wether/whether/

Page 354: s/without an user-defined conversion/without a user-defined conversion/

Page 358: s/typically, enum_check(int,int)/typically, enum_check(int)/

Page 373: s/do()/do_something()/ (twice)

Page 374: s/result,release()/result.release()/

Page 403: s/q4.v2().v1()/q4.v2().v2().v1()/

Page 410: s/Tuple<> in general derives from Tuple<>/in general, Tuple<> is built from Tuple<>/

Page 419: s/modify answer too/modify param too/

Page 423: s/refers to to/refers to/

Page 465: s/near-optimimal/near-optimal/

Page 476: s/instantation/instantiation/

Page 478: s/static counter/static int counter/ (twice)

Page 481: s/explained in this appendix/explained in this subsection/

Page 495: s/Machine& machine/Machine* machine/


Supplementations

Page 76, Section 6.6.1
At the end of the page you can add the following paragraph:

Note that STLFilt by Leor Zolman provides a way to decrypt the
STL error messages for several compilers
(see http://www.bdsoft.com/tools/stlfilt.html).


Home of the C++ Templates book