£¨²Î¿¼ÔÊ鿱ÎóÐÅÏ¢£©
ÖÐÎÄ°æÊÇ°´ÕÕ³ö°æÉçÌṩµÄÌرð°æµÚ1´ÎÓ¡Ë¢·ÒëµÄ£¬ºóÀ´ÓÖ¸ù¾ÝµÚ15´ÎÓ¡Ë¢×öÁËËùÓпÉÄܵĸüÕý£¨³ö°æÉçÔÚ×îºó¸¶Ó¡Ç°×öÁËÐí¶à¹¤×÷£©£¬´ó²¿·Ö¸üÕýÒѾ·´Ó³ÔÚÄ¿Ç°µÄÖÐÎÄÒë±¾ÖУ¬µ«»¹ÊÇÓÐЩºÜ³¤µÄ³ÌÐò¶ÎÎÞ·¨·ÅÈë¡£
ÔÚÖÐÎÄ·Òë±¾½»¸åÖ®ºóÎÒÕûÀíÁËÕâ¸öÎļþ£¬ÔÚÆäÖл㼯ÁËÓ¢ÎÄÌرð°æµÚ1´ÎÓ¡Ë¢Ö®ºóµÄÖ÷Òª¸üÕý¡£ÖÐÎı¾³ö°æºó£¬Ò»Î»Î´¾ßÃûµÄÍøÓÑÌîÈëÁ˶ÔÓ¦µÄÖÐÎÄÒ³Â룬²¢½«Ëü·¢µ½Ç廪´óѧµÄBBSÉÏ£¬Ò²·¢¸øÎÒÒ»·Ý¡£ÎÒÓÖ×Ðϸ¼ì²éÁËÆäÖеÄÒ³ÂëºÍÆäËûÐÅÏ¢£¬×öÁËһЩÐ޸ģ¨°üÀ¨½«Ò»Ð©Ó¢ÎÄÒëΪÖÐÎÄ£©£¬ÏÖ½«Ëü·ÅÔÚÕâÀ¹©¹ØÐÄÕâЩÐÅÏ¢µÄÈËÃDzο¼¡£
¡¾×îиüУ¬2002Äê8ÔÂ20ÈÕ¡¿ÕâÀïÁ´½ÓµÄÒ³ÖÐ×ܽáÁËÖÐÎı¾Öз¢ÏÖµÄÈô¸É´íÎ󣨰üÀ¨ÔÊé´íÎóºÍÔÊéиüÕý£©¡£
¸üÕýÏîÐÎʽ˵Ã÷£º
1) s/xxxx/yyyy/ ±íʾ½«ÔÀ´µÄ xxxx Ì滻Ϊ yyyy£»
2) (pg xx/yyLnn)±íʾӢÎÄÔ°æµÚxxÒ³ºÍÖÐÎÄ°æµÚyyÒ³µÚnnÐУ¬L-11±íʾµ¹ÊýµÚ11ÐС£ÓÐЩÏîÄ¿ÓÃÆäËû·½Ê½ËµÃ÷¡£
3) (pg xx/yyLnn*)´ú±íÖÐÎÄ°æÏàÓ¦µÄµØ·½ÒѾ±»¸ÄÕý¹ýÀ´ÁË¡£
-------------------------------------------------------------------------------
×¢£ºÓÉÓÚÖÐÎÄ°æÔÚ½»¸åʱÒѾ¾¡¿ÉÄܸüÕýÁËһЩ´íÎ󣬶øÄÇЩ´íÎó¾ÍûÓаüÀ¨ÔÚÕâÀï¡£Òò´ËÕâ¸ö¿±Îó±í²»ÄÜÍêÈ«°üÀ¨Ó¢ÎÄÔ°æÓ°Ó¡Ê飨¸ß½Ì³ö°æÉçÓ°Ó¡±¾ÖУ©µÄËùÓдíÎó£¬ÈçÓû¿±Îó¸ÃÊ飬Çë¼û
http://www.research.att.com/~bs/3rd_errata.html
»òÕ߲ο¼Ïà¹ØÒ³ÃæÖеÄÐÅÏ¢¡£
(pg 55/48L-11*) s/Entry& e =/const Entry& e =/
(pg 76/69*) Àý×ӵĸüºÃ°æ±¾£¨ÔÀ´È± #include < iostream>£©£º
#include < limits>
#include < iostream>
int main()
{
std::cout << "largest
float == " << std::numeric_limits< float>::max()
<< ", char is signed == " << std::numeric_limits< char>::is_signed
<< '\n';
}
(pg 129/115) 6.2.6.2µÚÒ»¸öÀý×Ó¼Ó×¢ÊÍ:
void* operator new(size_t);
// Ϊµ¥¸ö¶ÔÏó·ÖÅä¿Õ¼ä
void operator delete(void* p);
// Èç¹û (p) ÔòÊÍ·ÅÓà operator new() ·ÖÅäµÄ¿Õ¼ä
void* operator new[](size_t);
// ΪÊý×é·ÖÅäµÄ¿Õ¼ä
void operator delete[](void* p);
// Èç¹û (p) ÔòÊÍ·ÅÓÉ operator new[]() ·ÖÅäµÄ¿Õ¼ä
(pg 193/172) 8.3.3.1µÚÒ»¸öÀý×Ó£¬ÔÚÿ¸öcatch×Ó¾äÀï¼ÓÓï¾ä "++Driver::no_of_errors;"
(pg 202/180) ÖÐÎÄ180Ò³µÚÒ»¸ö³ÌÐòÀý×Ó¡£¸Ä½øΪ:
#ifdef __cplusplus // ½öΪ C++ ±àÒëÆ÷
(9.2.4)
namespace std { //
±ê×¼¿â¶¨ÒåÔÚÃû×Ö¿Õ¼ä std Àï (8.2.9)
extern "C" {
// stdio º¯Êý¾ßÓÐ C Á¬½Ó (9.2.4)
#endif
/* ... */
int printf(const char*, ...);
/* ... */
#ifdef __cplusplus
}
}
// ...
using std::printf; // ʹ printf ÔÚÈ«¾ÖÃû×Ö¿Õ¼äÀï¿ÉÓÃ
// ...
#endif
(pg 251/224) 10.4.7×îºóµÄÀý×Ó¸ÄΪ£º
void g()
{
vector< Table> v(10);
// ²»±Ø delete
vector< Table>* p = new vector< Table>(10);
// ÓÃÆÕͨ delete ¶ø²»ÊÇ delete[]
delete p;
}
£¨Using a container, such as vector, is simpler than writing a new/delete
pair. Furthermore, vector provides exception safety (Appendix E).£©
ÓÃÒ»¸öÈÝÆ÷£¬ÀýÈç vector£¬±È×Ô¼ºÐ´Ò»¶Ô new/delete ¼òµ¥µÃ¶à¡£½øÒ»²½Ëµ£¬
vector »¹ÌṩÁËÒ쳣ʱ°²È«ÐÔ£¨¸½Â¼E£©¡£
(pg280/250) µÚÒ»¸öÀý×ÓÌ滻Ϊ£º
class AE { /* ... */ }; // ²»ÊÇ Y µÄÓÑÔª
namespace N {
class X { /* ... */ };
// Y µÄÓÑÔª
class Y {
friend class X;
friend class Z;
friend class AE;
};
class Z { /* ... */ };
// Y µÄÓÑÔª
}
(pg 288/257L-13*) s/return b;/return f;/
(pg 335/299L12*) s/const char[12]/const char v[12]/
(pg 346/308L-11L-12*) s/}/};/ ÔÚµÚÒ»¸öÀý×ÓÀï³öÏÖÁ½´¦
(pg 380/338L11*) s/delete p;/delete pe;/
(pg 422/374) µÚ15.6½Ú¸Ä½øµÄÀý×Ó:
void Employee::operator delete(void* p, size_t s)
{
if (p) { // ½öÔÚ p!=0 ʱÏú»Ù£¬¼ûµÚ 6.2.6¡¢6.2.6.2
½Ú
// ¼Ù¶¨ `p' Ö¸Ïòͨ¹ý Employee::operator
new() ·ÖÅäµÄ `s' ¸ö×ֽڵĴ洢
// ÊÍ·ÅËüÒÔ±ãÁíÐÐʹÓÃ
}
}
(pg 433/384*) ÓÐ¹Ø Input/Output µÄÍ·Îļþ±í:
<cctype> ×Ö·û·ÖÀຯÊý µÚ20.4.2½Ú
(pg 434/385) s/fabs(),// µÚ¶þ¸ö±í¸ñÏÂÃ棬ȥµô¡£
(pg 457/406) s/vector tmp/vector<...> tmp/ // ÕâÀïµÄ...±íʾij¸öÀàÐÍ
×îºÃ½«Õâ¸öÀý×Ó¸ÄΪ£º
{
vector<...> tmp = v;
v.swap(tmp);
}
Òѱ£Ö¤ v ÔÀ´Õ¼Óô洢ÄÜÁ¢¼´ÊÍ·Å¡£
(pg 485) s/value_type;/value_type,/
(pg 493/437) bitset µÄ¹¹Ô캯ÊýµÄ²ÎÊýÐèҪת»»µ½ string:
bitset< 10> b4(string("1010101010"));
// 1010101010
bitset< 10> b5(string("10110111011110",4));
// 0111011110
bitset< 10> b6(string("10110111011110",2,8));
// 0011011101
bitset< 10> b7(string("n0g00d"));
// Å׳ö invalid_argument
bitset< 10> b8 = string("n0g00d");
// ´íÎó: ²»´æÔÚ string µ½ bitset µÄת»»
(pg 496/439Ò³ÖмäµÄÀý×ÓÖм䲿·Ö) s/size_t/ptrdiff_t/ Á½´Î
(pg 496/439)
ÔÚ c_array µÄ¶¨ÒåÖ®ºó¼Ó:
¡°ÎªÁËÓëÊý×éµÄ¼æÈÝÐÔ£¬ÎÒÓÃÓзûºÅµÄ ptrdiff_t £¨16.1.2½Ú£©¶ø²»ÊÇÎÞ·ûºÅµÄ
size_t ×÷ΪϱêµÄÀàÐÍ¡£½« size_t ÓÃÓÚ c_array µÄϱêʱ¿ÉÄܵ¼ÖÂ΢ÃîµÄáªÒåÐÔ¡£¡±
"For compatibility with arrays, I use the signed ptrdiff_t (16.1.2)
rather
than the unsigned size_t as the subscript type. Using size_t could
lead to
subtle ambiguities when using [] on a c_array."
(pg 524/464L8*) s/operator()(const Club&)/operator()(const Club&) const/
(pg 535/473L5*)
s/sort(off.begin(),off.end(),Person_lt)/off.sort(off,Person_lt)/
(pg 536/474L16*)
s/class located_in {/class located_in : public unary_function< Club,bool>/
(pg 536/474L25*) s/output_iterator/ostream_iterator/
(pg 538/475×îÏÂÃæ) ½«µÚ¶þ¸öʵÀý»»Îª£º
¶ÔÓÚµ÷Óà random_shuffle(b,e,r)£¬½«ÓÃÐòÁÐÖеÄÔªËظöÊý×÷Ϊ²ÎÊýÈ¥µ÷ÓÃÒ»¸öËæ»úÊýÉú³ÉÆ÷
r(b-e)£¬¸ÃÉú³ÉÆ÷±ØÐë²úÉúλÓÚ·¶Î§ [0,b-e) ÖеÄÖµ¡£ Èç¹û My_rand ÊÇÕâÑùµÄÒ»¸öÉú³ÉÆ÷£¬ÎÒÃǾͿÉÒÔÓÃÈçÏ·½Ê½È¥Ï´Ò»µþÆË¿ËÅÆ£º
void f(deque< Card>& dc, My_rand& r)
{
random_shuffle(dc.begin(),dc.end(),r);
// ...
}
(pg 563/497Öмä) s/d<curr-c->begin()/d< -(curr-c->begin())/ Á½´¦
(pg 596/526L11*) ÔÚÀà basic_string Àï¼ÓÈ룺
void clear(); // ɾ³ýËùÓÐ×Ö·û
(pg 599/529L3L4*) ¸üÕý×¢ÊÍ£º
size_t strspn(const char* p, const char* q);
// number of char in p before a char not in q
// ÔÚ p ÖгöÏÖ²»ÊôÓÚ q µÄ×Ö·û֮ǰµÄ×Ö·û¸öÊý
size_t strcspn(const char* p, const char* q);
// number of char in p before a char in q
// ÔÚ p ÖгöÏÖÊôÓÚ q µÄ×Ö·û֮ǰµÄ×Ö·û¸öÊý
(pg 600-601/529-530*) À©³äÃèÊöת»»º¯ÊýµÄÒ»½Ú£¨ÖÐÒë±¾ÒѾ¸üÕý£©£º
ÔÚ < stdlib.h> ºÍ < cstdlib> À±ê×¼¿âΪ½«±íʾÊýÖµµÄ×Ö·û´®×ª»»ÎªÊýÖµÌṩÁË
һЩºÜÓÐÓõĺ¯Êý¡£ÀýÈ磺
double atof(const char* p); // ´Ó
p[] µ½ double (``alpha to
floating'')
double strtod(const char* p, char** end);
// ´Ó p[] µ½ double (``string to double'')
int atoi(const char* p);
// ´Ó p[] µ½ int£¬¼Ù¶¨Êý»ùΪ 10
long atol(const char* p);
// ´Ó p[] µ½ long£¬¼Ù¶¨Êý»ùΪ 10
long strtol(const char* p, char** end, int b);
// ´Ó p[] µ½ long£¬¼Ù¶¨Êý»ùΪ b
ÕâЩº¯Êý½«ºöÂÔÇ°µ¼µÄ¿Õ°×£¬Èç¹ûÊäÈë´®²¢²»±íʾÊýÖµÔò·µ»Ø0¡£ÀýÈ磺atoi("seven")
µÄֵΪ 0¡£
If end is non-zero in a call strtol(p,end,b), the position of the first
unread character in the input string is made available by assigning
it to
*end.
If b==0, a number is interpreted the way a C++ integer literal is (4.4.1);
for example, a 0x prefix means hexadecimal, 0 means octal, etc.
If is undefined what happens if atof(), atoi(), or atol() converts a
value
that cannot be represented as its respective return type. If the input
string for strtol() represents a number that cannot be represented
as a long
int or if the input string for strtod() represents a number that cannot
be
represented as a double, errno (16.1.2, 22.3) is set to ERANGE and
an
appropriately huge or tiny value is returned.
Except for the error handling, atof(s) is equivalent to strtod(s,0),
atoi(s)
is equivalent to int(strtol(s,0,10)), and atol(s) is equivalent to
strtol(s,0,10).
(pg 619/545)
ÔÚij´¦¼ÓÈ룺¡°Èç¹ûÒ»¸ö get() »òÕß getline() º¯ÊýûÓдÓÁ÷ÖжÁµ½ÖÁÉÙÒ»¸ö×Ö·û£¬¾Í»áµ÷ÓÃ
setstate(failbit)¡£ÕâÑù£¬Ëæºó´ÓÕâ¸öÁ÷¶ÁÈ뽫ʧ°Ü£¨»òÕßÅ׳öÒ»¸öÒì³££¨21.3.6½Ú£©£©¡£
£¨somewhere add "If a get() or getline() function doesn't read
and remove at least one character from the tream, setstate(failbit) is
called, so that subsequent reads from the stream will fail (or an exception
is thrown (21.3.6))." £©
½«¸ÃÒ³µÚÒ»¸öʵÀýÐÞ¸ÄΪ£¨also modify the example to:£©£º
void subtle_error()
{
char buf[256];
while (cin) {
cin.get(buf,256);
// read a line
cout << buf;
// print a line
// Oops: forgot to remove
'\en' from cin - the next get() will fail
}
}
(pg 621/547L15*) s/badbit/failbit/
(pg 623/548L-16*) ½«Òì³£´¦ÀíÆ÷»»Îª£º
catch(ios_base::failure) {
// ¿ÉÒÔ£ºÓöµ½Îļþ½áÊø
break;
}
(pg 632/556L16*) s/noskipws()/unsetf(ios_base::skipws)/
(pg 633/557L9*) s/smanip& m)/const smanip& m)/
(pg 635/558L-10*) s/<< d << endl;/<< 1.41421 << endl;/
(pg 646/568L-7L-10*) s/eptr/egptr/ Á½´¦
(pg 669/587L-1) s/int i/size_t i/
(pg 671/590) ÖÐÒë±¾µÚ¶þ¸ö³ÌÐòʵÀý£¨Ó¢ÎÄ671Ò³×îºóÄǸöʵÀý£©Óõ½·Ç±ê×¼ÌØÕ÷¡£¸üºÃµÄÀý×ÓÊÇ£º
v_even *= v_odd;
// ³ËÆðÿ¶ÔÔªËز¢´æÈëżÊýϱêµÄÔªËØÀï
v_odd = 0;
// ½«dµÄÆæÊýϱêÔªËØÖÃ0
(pg 674/592ÖмäÁ½¸öforÓï¾äÀï) s/int i/size_t i/ Á½´¦
(pg 683/600) ¸üºÃµÄ operator*():
valarray< double> operator*(const Matrix& m, valarray< double>&
v)
{
valarray< double> res(m.dim2());
for (size_t i = 0; i< m.dim2(); i++) {
const Cslice_iter< double>&
ri = m.row(i);
res[i] = inner_product(ri,ri.end(),&v[0],double(0));
}
return res;
}
(pg 684/600) ¸üºÃµÄ operator*():
valarray< double> operator*(valarray& v, const Matrix& m)
{
valarray< double> res(m.dim1());
for (size_t i = 0; i< m.dim1(); i++) {
const Cslice_iter< double>&
ci = m.column(i);
res[i] = inner_product(ci,ci.end(),&v[0],double(0));
}
return res;
}
(pg 788/690*) s/Circle*/Circle/ Á·Ï° 2.
(pg 788690*) s/Shape*/Shape/ Á·Ï° 2.
¸½Â¼A
(pg 808/707*) s/extern const volatile clock;/extern const volatile
long clock;/
(pg 809/708) ÔÚ class-head Öн«
class-key nested-name-specifier template template-id base-clause(opt
»»Îª£º
class-key nested-name-specifier(opt template-id base-clause(opt
(pg 811/710)
s/indentifier(opt) = template-name/indentifier(opt)
= id-expression/
(pg 811/710) ÔÚ "template-argument:" À s/template-name/id-expression/
(pg 851/744) ½«µÚÒ»¸öÀý×Ó»»Îª£º
void Z2::f(Y1* py1, Y2* py2, Y3* py3)
{
X* px = py1; // ¿ÉÒÔ: X ÊÇ Y1 µÄÒ»¸ö¹«ÓûùÀà
py1->a = 7; // ok
px = this; // ¿ÉÒÔ: X ÊÇ Y2 µÄÒ»¸ö±£»¤»ùÀà,
ÇÒ Z2 ÓÉ Y2 ÅÉÉú
a = 7; // ok
px = py2; // ´íÎó: X ÊÇ Y2 µÄÒ»¸ö±£»¤»ùÀà,
ÇÒ Z2 ÓÉ Y2 ÅÉÉú£¬
// µ«ÎÒÃǼȲ»ÖªµÀ py2 ÊÇÒ»¸ö Z2, Ò²²»ÖªµÀÈçºÎÔÚ·Ç Z2 ¶ÔÏóÖÐʹÓà Y2::X
py2->a = 7; // ´íÎó: Z2 ²»ÖªµÀÔõÑùÔÚ·Ç Z2
¶ÔÏóÖÐʹÓà Y2::a
px = py3; // ´íÎó: X ÊÇ Y3 µÄÒ»¸ö˽ÓûùÀà
py3->a = 7; // ´íÎó
}
(pg 858/750L9*) ÔÚ "void k(" ֮ǰ¼Ó "template< class T> "
(pg 867/757L-3*) s/template Calls_foo< Shape*>::constraints();/
template void Calls_foo< Shape*>::constraints(Shape*);/
(pg 871/761L11*) s/istream& fout/ostream& fout/ Á½´¦
(pg 876/765L10*) s/print_locale names/print_locale_names/
(pg 880/768L-5*) ÐÞ¸ÄÀý×ÓÀïµÄ×¢ÊÍ:
sort(v.begin(),v.end());
// ÅÅÐòÖÐÓà < ±È½ÏÔªËØ
(pg 890/777L14*) s/cs2+size()/cs2+s2.size()/
(pg 890/777L-5L-3*) s/cs2+cs2.size()/cs2+s2.size()/ Á½´¦
(pg 891/777L-1*) s/cs2+cs2.size()/cs2+s2.size()/
(pg 893/780L19*) s/: numpunct< char>(r) { }/: std::numpunct< char>(r) { }/
(pg 894/780L-10*) ĬÈϸñʽºÍ¾«¶ÈϵÄÊä³ö£º
style A: 12345678 *** 1.23457e+06
style B: 12 345 678 ***
1,23457e+06
(pg 895/781L-18*) s/: num_put/: std::num_put/
(pg 895/781L-13*) s/&s[pos]/s.begin()+pos/
(pg 896/782L16*) s/fill()/this->fill()/
(pg 898/784L6*) s/eos,state/eos,*this,state/
(pg 899/785L7~11*) s/amount/amount=/ ÔÚÊä³öÖÐÓÐ5´¦
(pg 904/789L27*) s/d = dd/m = dd/
(pg 904/789) Ò»¸ö¸üºÃµÄÊäÈ뺯Êý£º
istream& operator>>(istream& s, Money& m)
{
istream::sentry guard(s);
// ¼û 21.3.8
if (guard) try {
ios_base::iostate state
= 0; // ºÃ
istreambuf_iterator<
char> eos;
string str;
use_facet< money_get< char> >(s.getloc()).get(s,eos,true,state,str);
if (state==0 || state==ios_base::eofbit)
{ // Ö»ÔÚ get() ³É¹¦Ê±ÉèÖÃÖµ
long int i = strtol(str.c_str(),0,0); // Ϊ strtol(), ¼û20.4.1
if (errno==ERANGE)
state |= ios_base::failbit;
else
m = i; // Ö»ÔÚµ½µ½ long int µÄת»»³É¹¦Ê±ÉèÖÃÖµ
s.setstate(state);
}
}
catch (...) {
handle_ioexception(s);
// ¼û D.4.2.2
}
return s;
}
ÎÒÓà get() ¶ÁÈëµ½Ò»¸ö string ÀÒòΪ¶ÁÈëµ½Ò»¸ö double ¶øºóÔÙת»»µ½
long int ¿ÉÄܵ¼Ö¶ªÊ§¾«¶È¡£
£¨I use the get() that reads into a string because reading into a double
and
then converting to a long int could lead to loss of precision.£©
(pg 909/794L1*) ×¢ÊÍ£º
s/sloppy: no protection against buffer overflow/
sloppy: hope strftime () will never produce more than
20 characters/
(pg 910/794*) ÔÚ D.4.4.4 Ç°¼Ó£º
ͬʱÌṩÁË time_put µÄÒ»¸ö _byname °æ±¾ (D.4, D.4.1)£º
template < class Ch,
class Out = ostreambuf_iterator< Ch> >
class std::time_put_byname
: public time_put< Ch,Out> { /* ... */ };
(pg 912/796L16*) s/Month(x.tm_mon)+1/Month(x.tm_mon+1)/
(pg 912/796*) ½«D.4.4.4×îºóÒ»¶Î»»Îª£º
ͬʱÌṩÁË time_get µÄÒ»¸ö _byname °æ±¾ (D.4, D.4.1)£º
template < class Ch,
class In = istreambuf_iterator< Ch> >
class std::time_get_byname
: public time_get< Ch,In> { /* ... */ };
(pg 915/798*) s/const { curr=p;/{ curr=p;/ Ò³ÖмäÁ½¸ösetµÄ¶¨Òå
(pg 915/798L-15*) s/Date_format< char>::/Date_format::/
(pg 915/799L5*) s/(f.put( ... .failed)/(f.put( ... .failed())/
(pg 916/799L-4*) s/Month(x.tm_mon)+1/Month(x.tm_mon+1)/
(pg 916/800L4L6*) s/std::time_get< Ch>/std::time_get< Ch,In>/ Á½´¦
(pg 917/800) ¸üºÃµÄ getval():
template< class Ch, class In>
In Date_in< Ch,In>::getval(In b, In e, ios_base& s, ios_base::iostate&
r,
int* v, Vtype* res) const
// read part of Date: number, day_of_week,
or month. Skip whitespace
// and punctuation.
{
const ctype< Ch>& ct = use_facet< ctype<
Ch> >(s.getloc());
// ctype is defined in D.4.5
Ch c;
*res = novalue; // no value found
for (;;) { // skip
whitespace and punctuation
if (b == e) return e;
c = *b;
if (!(ct.is(ctype_base::space,c)
|| ct.is(ctype_base::punct,c)))
break;
++b;
}
if (ct.is(ctype_base::digit,c)) {
// read integer without regard
int i = 0;
// for numpunct
do { // turn digit from arbitrary
character set into decimal value:
static char const digits[] = "0123456789";
i = i*10 + find(digits,digits+10,ct.narrow(c,' '))-digits;
c = *++b;
} while (ct.is(ctype_base::digit,c));
*v = i;
*res = unknown; // an integer,
but we don't know what it represents
return b;
}
if (ct.is(ctype_base::alpha,c)) { // look for name
of month or day of week
basic_string< Ch> str;
while (ct.is(ctype_base::alpha,c))
{ // read characters into string
str += c;
if (++b == e) break;
c = *b;
}
tm t;
basic_stringstream< Ch>
ss(str);
typedef istreambuf_iterator<
Ch> SI; // iterator type for ss' buffer
get_monthname(ss.rdbuf(),SI(),s,r,&t);
// read from in-memory stream
// buffer
if ((r&(ios_base::badbit|ios_base::failbit))==0)
{
*v= t.tm_mon;
*res = month;
r = 0;
return b;
}
r = 0; // clear state
before trying to read a second time
get_weekday(ss.rdbuf(),SI(),s,r,&t);
// read from in-memory stream
if ((r&ios_base::badbit)==0)
{ // buffer
*v = t.tm_wday;
*res = dayofweek;
r = 0;
return b;
}
}
r |= ios_base::failbit;
return b;
}
(pg 919/801L-6*) ½«
template< class Ch, class
In = istreambuf_iterator< Ch> >
In Date_in::do_get_date(
Ì滻Ϊ
template< class Ch, class
In>
In Date_in< Ch,In>::do_get_date(
×¢Ò⣺ÖÐÒë±¾Ð޸ĺó×îºó¶ªÁËÒ»¸ö >¡£
(pg 919/802L13*) s/order = dateorder();/order = date_order();/
(pg 919/802Ò³Öв¿*) s/tmp->tm_mday = val[1];/tmp->tm_mday = val[2];/
(pg 922/804) Ò»¸ö¸üºÃµÄ count_spaces():
int count_spaces(const string& s, const locale& loc)
{
const ctype< char>& ct = use_facet< ctype<
char> >(loc);
int i = 0;
for (string::const_iterator p = s.begin(); p !=
s.end(); ++p)
if (ct.is(ctype_base::space,*p))
++i; // whitespace as defined by ct
return i;
}
(pg 922/804*)
s/loc.is(space|punct,c)/ct.is(ctype_base::space|ctype_base::punct,c)/
ÔÊ鿱Îó¸øµÄÊÇ ct.is£¬Ëƺõ»¹ÊÇÓ¦¸ÃÓà loc.is¡£ÖÐÎÄÒë±¾ÓõÄÊÇloc.is¡£
(pg 922-923/805L3L14*) s/std::ctype/std::ctype< Ch>/ Á½´¦
(pg 924/806L7*) s/widen(narrow('x')) == 'x'/widen(narrow('x' ,0)) == 'x'/
(pg 928/809L-6*) ÔÚ while Óï¾äÇ°¼Ó "char ch;"
(pg 931/812*) s/to_str(Season) ... of s/to_str(Season x) ... of x/
(pg 932/812*) ½« to_str() ¸ÄΪ£º
const string& Season_io::to_str(Season x) const
{
return m->get(cat,x,"no-such-season");
}
(pg 939/818L-20*) s/rand()/(rand())/
(pg 944/822L-5*) ½«
void destroy_elements() { for (T* p = v; p!=space; ++p) p->~T(); }
¸ÄΪ£º
void destroy_elements() { for (T* p = v; p!=space; ++p) p->~T(); space=v;
}
(pg 945/824) ÔÚE3.3µÚ¶þ¸öÀý×ÓÖ®ºó¼ÓÈë:
È»¶ø£¬Ä¬È쵀 swap() ʵÏÖ²»ÊʺÏÎÒÃǶÔvector_base µÄÐèÒª£¬ÒòΪËü½«¸³Öµ²¢Ïú»ÙÒ»¸ö
vector_base¡£ Ϊ´ËÎÒÃÇÌṩһ¸öרÃÅ»¯£º
template void swap(vector_base& a, vector_base& b)
{
swap(a.a,b.a); swap(a.v,b.v); swap(a.space,b.space);
swap(a.last,b.last);
}
(pg 952/829L-1*,830L9)
s/T& vector< T,A >::emergency_exit()/void vector< T,A >::emergency_exit()/
±¾Ò³ÓÉôÃ×ÚÑཨÁ¢ºÍά»¤£¬±£ÁôËùÓÐȨÀû¡£
ÕâÀïµÄ²ÄÁÏ¿É×ÔÓɵØÓÃÓÚ¸öÈËѧϰ»òÆÕͨ½Ìѧ»î¶¯¡£ÆäËû·½Ê½µÄʹÓÃÓ¦ÊÂÏȵõ½×÷ÕßÊéÃæÈÏ¿É¡£ |