C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: Exception hierarchy

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Paul D. DeRocco
Guest





PostPosted: Thu Apr 01, 2004 7:49 am    Post subject: Re: Exception hierarchy Reply with quote



Quote:
"Alberto Barbati" <AlbertoBarbati (AT) libero (DOT) it> wrote

1) runtime_error and logic_error are highly dependent on the library
implementation as they both depend on std::string. Having language-level
features such as dynamic_cast and typeid depend so much on the library
implementation is not acceptable. For this reason the std::exception
class is so light-weight and have no other library dependencies.

That makes sense.

Quote:
2) throwing a runtime_error/logic_error requires the dynamic allocation
of one or more strings and it might be simply impossibile to do that in
those peculiar situations that requires "low-level" exceptions. This is
especially true for bad_alloc: if there's no memory to accomplish an
allocation request, there might be no memory for the string too.

The implementations I've used all have some pre-allocated space for the
temporary exception objects themselves, so the difficult part is allocating
the subsidiary object that contains the data. But that can be solved by
using a reference counting implementation like Gnu does, and initializing
the string from a pre-existing static one.

Quote:
3) it is not self-evident whether they should derive from runtime_error
or from logic_error

I would say bad_alloc is a runtime_error, and the others are logic_errors,
generally speaking.

Another missing feature of exceptions, in my view, is a virtual clone()
function. This would be useful because an exception object disappears as
soon as the catch block is exited, and it is often useful to save the
exception for later processing. About all you can save now is the what()
string, and Gnu doesn't even put enough info into the string to completely
identify the exception if the type information is gone.

--

Ciao, Paul D. DeRocco
Paul mailto:pderocco (AT) ix (DOT) netcom.com

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.