Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > c++ question re...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 14 Topic 43729 of 48044
Post > Topic >>

c++ question regarding exception safety

by unix.sh@[EMAIL PROTECTED] Mar 6, 2008 at 08:48 AM

In Section E.3.5. of the book 'the c++ programming language 3rd
edtion' by Bjarne Stroustrup, why it needs to add the check: 'if (v)'
in the vector_base destrctor of the vector_base implmentation.

In my understanding, if this statement failed(v=alloc.allocate(n)) in
the contrstructor, the destrctor will never be called. So no check
needed in the destructor.

But according to the book, Bjarned says clearly in the book(p. 950,
Section E.3.5)

Note that this attempt to write safer code complicates the invariant
for the class: It is no longer
guaranteed that v points to allocated memory. Now v might be 0 .

I am confused now.

Thanks for your help,

Michael
 




 14 Posts in Topic:
c++ question regarding exception safety
unix.sh@[EMAIL PROTECTED]  2008-03-06 08:48:52 
Re: c++ question regarding exception safety
"Alf P. Steinbach&qu  2008-03-06 18:33:25 
Re: c++ question regarding exception safety
unix.sh@[EMAIL PROTECTED]  2008-03-06 10:05:47 
Re: c++ question regarding exception safety
"Alf P. Steinbach&qu  2008-03-06 19:21:36 
Re: c++ question regarding exception safety
James Kanze <james.kan  2008-03-07 02:41:39 
Re: c++ question regarding exception safety
"Alf P. Steinbach&qu  2008-03-07 17:43:02 
Re: c++ question regarding exception safety
James Kanze <james.kan  2008-03-07 02:48:11 
Re: c++ question regarding exception safety
James Kanze <james.kan  2008-03-07 13:27:26 
Re: c++ question regarding exception safety
"Alf P. Steinbach&qu  2008-03-07 22:56:45 
Re: c++ question regarding exception safety
James Kanze <james.kan  2008-03-08 01:39:02 
Re: c++ question regarding exception safety
"Alf P. Steinbach&qu  2008-03-08 16:34:43 
Re: c++ question regarding exception safety
James Kanze <james.kan  2008-03-08 12:41:39 
Re: c++ question regarding exception safety
"Alf P. Steinbach&qu  2008-03-09 00:08:19 
Re: c++ question regarding exception safety
James Kanze <james.kan  2008-03-09 05:09:22 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Oct 15 22:39:34 CDT 2008.