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

The C++ Standard Library - A Tutorial and Reference

Errata for the 22nd and later printings
Last update: April 14, 2013

This is the errata for the 22nd 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: 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 100/101, Section 5.4.1
In the example code at the bottom of page 100 and top of page 101, using compose_f_gx_hx and bind2nd, there is a serious bug: pos might become coll.end() when find_if() gets called. But then we switch over *pos, which is not a valid call when pos equals coll.end(). Thus, you have to check for coll.end() first and then only if pos!=coll.end() we can switch over the value of *pos.


Page 105, Section 5.5.1
In stl/copy3.cpp, the following include directive for the iterator adapters is missing:

#include <iterator>


Page 232, Section 6.10.2
The copy constructor is not specified with explicit. So strike explicit at the beginning of the second declaration of this page.


Page 247, Section 6.10.9
The constructor for beg, end, and alloc was never specified for associative containers. Thus, strike sets, multisets, maps, multimaps for the last but one constructor.


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 523, Section 11.3.8
In all the descriptions of find_last_of() and find_last_not_of() 4 times replace "starting at index idx" by "searching backward starting at index idx".


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 96: after "Of course, you could do both in one statement: s/max_element/min_element/

Page 151: in Table 6.3: s/c.reserve()/c.reserve(num)/

Page 236: s/key_compare container::key_comp ()/key_compare container::key_comp () const/

Page 236: s/value_compare container::value_comp ()/value_compare container::value_comp () const/

Page 294: s/collection of persons)/collection of Persons)/


Home of the C++ Library book