The Second Edition of the book is now available!

For more information, please see STL Resources at Rensselaer. The information on this page refers to the first edition.

Errata (in First Printing Only)

D.R. Musser and Atul Saini,
STL Tutorial and Reference Guide: C++ Programming with the Standard Template Library,
Addison-Wesley, Reading, MA, 1996.


These errata were corrected between the first and second printings. To determine which printing you have, see the last line of the copyright page (back of title page).

All errata in source code examples have been corrected in the online Source Code Resources for the book (accessible from the book's page).

p.10, middle of page: The return type of operator< should be bool

p. 11, line 5 of the first code segment: insert "iterator position," after "insert("

p. 18, Example 1-2, change char* string1 to char string1[]

p. 24, line 9: replace "1.5.2" by "1.6.2"

p. 36, line 10: replace "equality checking with ==" with "inequality checking with !=";
line 11: replace "inequality checking, !=" with "equality checking, =="

p. 51, line 12 of Example 4-1, replace &a[100] by &a[10].

p. 64, line -6: replace lst.begin() += n with lst.begin() + n
line -4: replace += with +

p. 77, lines -9 and -8: replace "binary" by "unary"; line -7: replace "unary" by "binary"; lines -3 and -1: delete "binary"

p. 81, Section 5.2.6, line 7: replace last1 with first2

p. 82, Section 5.3, line 4: replace "others" with "other"

p. 92, Section 5.3.11, line 7: replace "do no overlap" with "do not overlap"

p. 106, Section 5.4.5, line 1: replace "four" with "five"

p. 108, line -6: change [first, last) to [first, last - 1);
line -2: insert [first, last - 1) after "range"

p. 115, Example 5-34: change x1[i] = i; to x1[i] = i + 1;

p. 130, line -6: replace "Chapter 8" with "Chapter 9"

p. 131, line -2: replace "functions" with "function"

p. 132, line 7: insert "a" before "vector"

p. 135, line -3: replace "total ordering relation" by "strict weak ordering relation (see Section 5.4)"

p. 136, line 12: add another ) at the end of the formula

p. 137, line 4: insert "edit" after "we"

p. 139, lines 7 - 10: change to "Nevertheless, when it does occur, it can invalidate all iterators and references into the deque, so we must be careful not to write code that depends on iterators or references remaining valid while insertions are occurring."
Footnote 6: change to: "In the HP implementation no references are invalidated when reallocation occurs, but they would be if deques were implemented as a single block of memory, with the data in the middle and able to grow in either direction."

p. 143, line 6: add reverse_iterator to the list of types.

p. 152, line -8: replace "multiset" with "multimap"

p. 156, line -2: replace "O(N)" with "O(log N)"

p. 165, lines -10 thru -8: This sentence should read, "The first parameter is the type of the keys to be stored, the second is the type of objects to be associated with the keys, the third is the comparison function to be used in determining order, and the fourth is..."

p. 166, replace last sentence (extending through third line of p. 167) with "One other way to accomplish this replacement (departing for the moment from the subject of insertion) is

(*i).second = t;

where i is a map<Key, T>::iterator such that (*i).first == k."

p. 169, line 4: replace with map<long, double, less<long> > x, y;
line 6: replace with map<long, double, less<long> >::iterator ix, iy;

p. 211, line -2: replace "first" by "second"

p. 236, line -13: replace "Appendix C" with "Appendix A"

p. 238, second line of struct CompWestX: insert const after bool operator()(...);
in comment after void outputWest ...: insert of after west point

p. 242, line -2: replace "Section on page 184" with "Section 11.3 on page 187"

p. 278, Section 19.3.8, line 5: replace with iterator insert(iterator position, const T& x = T())
line 9: delete = T()

p. 283, Section 19.4.8, line 5: replace with iterator insert(iterator position, const T& x = T())
line 9: delete = T()

p. 289, Section 19.5.8, line 5: replace with iterator insert(iterator position, const T& x = T())
line 9: delete = T()

p. 320, line 3 of 19.12.3: Delete the sentence "The order of removal..."

p. 321, line 5 of 19.12.5: Delete "const,"

p. 325, line -2: for_each should have return type Function

p. 329: Both search functions should have return type ForwardIterator1

p. 331: copy should have return type OutputIterator
copy_backward should have return type BidirectionalIterator2

p. 332: swap_ranges should have return type ForwardIterator2

p. 340: partition and stable_partition should have return type BidirectionalIterator

p. 358: Both partial_sum functions should have return type OutputIterator

p. 359: Both adjacent_difference functions should have return type OutputIterator

p. 359, line -4: Insert "places *first in *result and" before "returns result + N."

p. 366, line 1: template <class Arg, class Result> should be template <class Arg1, class Arg2, class Result>;
line 5: pointer_to_binary_function<Arg, Result> should be pointer_to_binary_function<Arg1, Arg2, Result>

p. 378, lines -3 and -1: replace e.x with max(e.x, w.x)

p. 379, lines 2 and 4: replace w.x with min(e.x, w.x)

p. 380: replace last 2 assignment statements of body of function rectangle::rectangle with sw = b; ne = a;

The following acknowledgement was added to the Preface in the Second Printing: We are greatly indebted to the following people who brought to our attention errors in the first printing: Franz-Dieter Berger, Joseph Bergin, Stephen D. Evans, Mike Gursky, Roger House, Russell Johnston, Bruce Jolliffe, Cathy Kimmel Joly, Mehdi Jazayeri, Alexander Konstantinou, Jonathan Miller, John I. Moore, Jr., Saul J. Rosenberg, Andrew Savige, Shankar N. Swamy, Chris Uzdavinis, and Steve Vinoski.

There are additional errata.


musser@cs.rpi.edu