Nicolai M. Josuttis: solutions in time  The C++ Standard Library: Errata for 14th and later printings

The C++ Standard Library - A Tutorial and Reference

Errata for the 14th and later printings
Jan 4, 2005

This is the errata for the 14th and later printings of the book The C++ Standard Library by Nicolai M. Josuttis. It extends the errata for the previous printings.
Please, note the
- hints for Visual C++ users.
- hints for GCC/G++ users.

The errata is organized in the following way:
- The first part lists technical errors
- The second part lists typos

Please note: Please note: This list may portray the book as containing many errors but keep in mind it has about 800 pages with about 240.000 words along with numerous tables and code examples. I am not perfect and it is unreasonable to expect significantly fewer bugs. To cite one reader: "Thanks again and I'm going to write a short review of the book for Amazon contradicting whoever said it had lots of errors."


Errors

Page 140, Section 5.11.2:
The auxiliary insert() function does not work because the last row always restores coll to its original contents. The function has to be implemented as follows:

 template <class T, class Cont, class Iter>
 void insert (Cont& coll, const Iter& pos, const T& value)
 {
     Cont tmp(coll);             // copy container and all elements
     try {
         coll.insert(pos,value); // try to modify the copy
     }
     catch (...) {               // in case of an exception
         coll.swap(tmp);         // - restore original container
         throw;                  // - an rethrow the exception
     }
 }

Page 141, Section 5.12:
When I write that "the STL is designed as a framework that may be extended in almost any direction," I should talk about one important way of extensibility that is not supported: The STL does not support public inheritance of its classes. For performance reasons no method is declared to be virtual. Thus, if you want to extend STL classes you should always wrap them by introducing them as members or use private inheritance.

And, of course, an index entry for "STL and inheritance" would be appropriate.


Page 155, Section 6.2.3:
Replace:
The C++ Standard Library does not state clearly whether the elements of
a vector are required to be in contiguous memory. However, it is the intention that this is guaranteed
and it will be fixed due to a defect report.
By:
The C++ Standard Library requires that the elements of a vector are in contiguous memory.


Page 196, Section 6.6.2:
In Table 6.26 replace all occurences of Elem by Val (e.g.: map<Key,Elem> should be map<Key,Val>).


Page 273, Section 7.4.2
In iter/backins.cpp, the following include directive for class back_iterator is missing:

#include <iterator>


Page 274, Section 7.4.2
In iter/frontins.cpp, the following include directive for class front_iterator is missing:

#include <iterator>


Page 276, Section 7.4.2
In iter/inserter.cpp, the following include directive for class insert_iterator is missing:

#include <iterator>


Page 352, Section 9.5.3
The return type of find_first_of() is ForwardIterator1 (twice).


Page 382, Section 9.7.2
In the first bullet, replace op(elem,e) by op(e,elem).


Page 466, Section 10.4.2
For operators <<= and >>= for bitsets you should replace the last bullets as follows:

For <<=:

For >>=:


Page 471, Chapter 11
Saying that the type of string literals is const char* is not quite right. Strictly speaking, the original type of a literal such as "hello" is const char[6]. However, this type automatically converts ("decays") to const char*, so that you can almost always use (and see) const char* in declarations. However, when working with templates the difference might matter because for reference template parameters decay doesn't occur (see our template book ;-).


Page 514, Section 11.3.7
I left out the version of string::assign() that takes two InputIterator types, similar to the string::append() method you have on page 516:

string& string::assign (InputIterator beg, InputIterator end)


Page 747, Index

Insert:

Note: Page numbers in bold indicate the location of the definition of the
item. Page numbers in the normal type face are other pages of interest. If
the entry appears in source code the page numbers are in the italic type
face.


Typos

Page 150, Table 6.2: s/c.~vector<Elem>()/c.~vector()/

Page 162, Table 6.9: s/c.~deque<Elem>()/c.~deque()/

Page 167, Table 6.12: s/c.~list<Elem>()/c.~list()/

Page 482, Table 11.2: s/size_type num/size_type num/ (just the font)

Page 719: s/equivalent to isalpha()&&isdigit()/equivalent to isalpha()||isdigit()/

Page 719: s/equivalent to isalnum()&&ispunct()/equivalent to isalnum()||ispunct()/


Home of the C++ Library book