Preface:
Chapter 1:
Chapter 2:
pg 35 s/bad_stack()/Bad_pop()/
pg 36 s/s_set/s_ref/
Chapter 3:
pg 49 s/20.4.1/20.3.7/
Chapter 4:
Chapter 5:
Chapter 6:
pg 129 s/throws a bad_alloc exception./ throws a bad_alloc exception (see 19.4.5 for an alternative)./
Chapter 7:
Chapter 8:
pg 180 s/::fill()/::fill(char c)/ twice
Chapter 9:
pg 199 s/these are not errors/the call of f() is not an error/
pg 212 s/expr()/prim()/ twice
pg 212 s/expr.c/prim.c/
Chapter 10:
pg 231 s/*const/*/ twice and replace the sentence "The const makes it clear ..." by "However, this is not an ordinary variable; it is not possible to take the address of this or to assign to this." (this is a change in formulation to match a standards change - which has no effect on any code)
Chapter 11:
pg 262 s/pointer to function/pointer to member/
pg 262 After "[Stroustrup,1994]." add "The ternary conditional expression operator, ?: cannot be overloaded either."
Chapter 12:
pg 311 s/mem_fct/mem_fun/ (standards change)
Chapter 13:
pg 347 s/c.re/c.real()/ and s/c.im/c.imag()/
pg 348 s/c.re/c.real()/ and s/c.im/c.imag()/ twice
Chapter 14:
pg 368 To simplify, replace the bodies of the copy constructors and assignment operators by "; // copy, then a.ptr=0"
Chapter 15:
pg 407 add "public:" before the using-declarations in class BB.
Chapter 16:
pg 457 replace the suggestion to change capacity through assignment by: To give memory back to the system, a small trick is needed:
vector tmp = v; // copy of v with default capacity v.swap(tmp); // now v has the default capacityChapter 17:
pg 476 s/stack< int >/stack< int,vector< int> >/
pg 478 s/{ }/{ make_heap(c.begin(),c.end(),cmp); } // see 18.8/
pg 479 s/priority_queue< string, Nocase> pq;/priority_queue< string, vector< string>, Nocase> pq;/
pg 479 replace g() by:
typedef priority_queue< string, vector< string>, String_cmp> Pqueue; void g(Pqueue& pq) // pq uses String_cmp() for comparisons { Pqueue pq2(String_cmp(nocase)); pq = pq2; // ok: pq and pq2 are of the same type, pq now also uses String_cmp(nocase) }
pg 501 s/max_load< /max_load<= /
Chapter 18:
pg 520 s/public binder2nd< less< T>, T>/public binder2nd< less< T> >/
pg 522 s/, const Record&/, const char*/
pg 522 s/, const Record&/, long/
pg 526 change the first example tp
void f(vector< string>& text) { vector< string>::iterator p = adjacent_find(text.begin(),text.end()); if (p!=text.end() && *p=="the") { // I duplicated "the" again! text.erase(p); // ... } }
pg 526 add "typename" before iterator_traits< In>" twice
pg 538 change the call of random_shuffle to:
Urand r(52); random_shuffle(dc.begin(),dc.end(),r);Chapter 19:
pg 568 s/out_of_memory/std::bad_alloc/
pg 569 s/v = p/v = p-size()/
pg 576 a better version of temporary_dup():
template< class T, class A> T* temporary_dup(vector< T,A>& v) { pair< T*,ptrdiff_t> p = get_temporary_buffer< T>(v.size()); if (p.second != v.size()) { // check that enough memory was available if (p.first != 0) return_temporary_buffer(p.first); return 0; } copy(v.begin(),v.end(),raw_storage_iterator< T*,T>(p)); return p.first; }
pg 576 s/destroy_temporary_buffer/return_temporary_buffer/
pg 576 replace the last paragraph by: "An operator new() or operator new[]() with an empty exception-specification (14.6) cannot signal memory exhaustion by throwingstd::bad_alloc. Instead, if allocation fails they return 0. A new-expression (6.2.6.2) tests the value returned by an allocator with an empty exception-specification; if the returned value is 0, no constructor is invoked and the new-expression returns 0. In particular, the nothrow allocators return 0 to indicate failure to allocate rather than throwing bad_alloc. For example:" (late standards change)
Chapter 20:
Chapter 21:
pg 619 the getline() example would be better written like this:
char word[MAX_WORD][MAX_LINE]; // MAX_WORDS arrays of MAX_LINE char each int i = 0; while(cin.getline(word[i++],MAX_LINE,'\n') && i< MAX_WORD); // ...
pg 643 s/file[8]/file[9]/
pg 643 After "(see 21.10[13])." add "Attempting to seek beyond the beginning or the end of a file puts the stream into the bad() state."
pg 644 add "A sync() on a buffer attached to an ostream flushes the buffer to output." to the end of the paragraph starting "Flushing an istream".
pg 647 s/rdbuf().in_avail()/rdbuf()->in_avail()/
Chapter 22:
pg 671 s/void operator*=(const valarray< T>& val)/void operator*=(const T& val)/
pg 680 s/a.re/a.real()/ and s/a.im/a.imag()/
pg 681 Change the last example to: Curiously, the assignments don't offer the same protection as the constructors. For example:
void f(complex< float> cf, complex< double> cd, complex< long double> cld, complex< int> ci) { complex< double> c1 = cf; // fine complex< double> c2 = cd; // fine complex< double> c3 = cld; // error: possible truncation complex< double> c4(cld); // ok: explicit conversion complex< double> c5 = ci; // error: no cnversion c1 = cld; // ok, but beware: possible truncation c1 = cf; // ok c1 = ci; // ok }(recent standards change)
Chapter 23:
Chapter 24:
pg 749 s/p[sz-1]/p[sz]/
Appendix A:
Appendix B:
pg 818 s/several times/several times in a single translation unit/
pg 819 Add as the 3rd paragraph: " The implicit conversion of string literal to a (non-const) char* is deprecated. Use named arrays of char or avoid assignment of string literals to char*s (5.2.2)."
Appendix C:
pg 853 s/void f1(int)/int f1(int)/
pg 853 s/int f2()/void f2()/
Preface:
Chapter 1:
Chapter 2:
pg 42 swap "next input" and "next output" in comments
Chapter 3:
pg 63 s/to read strings from input/for each string read from input/
Chapter 4:
Chapter 5:
Chapter 6:
Chapter 7:
pg 145 s/initialized n times/initialized in each call of f()/
pg 151 s/and sec8.2.9.2//
Chapter 8:
Chapter 9:
pg 210 s/driver.c/main.c/
pg 212 s/driver.c/main.c/
pg 215 s/is it/it is/ second paragraph
Chapter 10:
pg 222 s/nicollo/niccolo/ with an accent grave over the last o.
pg 250 s/There is no way/ Except by using an initializer list (5.2.1, 18.6.7), there is no way/
pg 256 s/destructor class/destructor calls/
Chapter 11:
pg 279 s/or a friend/or a nonmember friend/
Chapter 12:
Chapter 13:
Chapter 14:
Chapter 15:
Chapter 16:
Chapter 17:
pg 495 s/to_string< char >/to_string< char,char_traits< char >,allocator< char > >/
pg 501 s/and Rehash/and Resize/
Chapter 18:
Chapter 19:
Chapter 20:
pg 586 s/at any give time/at any given time/
pg 602 s/rather to/to/ in [14]
Chapter 21:
pg 633 s/cladd/class/
pg 633 s/io_base/ios_base/
pg 640 s/are called a stringstreams/are called stringstreams/
Chapter 22:
Chapter 23:
Chapter 24:
Chapter 25:
Appendix A:
Appendix B:
Appendix C: