-----Original Message----- From: David Abrahams [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 20, 2002 1:40 PM To: Boost mailing list Subject: Re: [boost] Do we need a boost_exception class or idiom?
>"Fernando Cacciola" <[EMAIL PROTECTED]> writes: >> I'm not sure if a boost exception class is *needed*, but I see no problem in >> having one. >> Anyway, IIF such an exception class is defined, I *strongly* encourage (as I >> did in the past) that it provides: >> >> virtual void raise() const >> { >> #ifndef BOOST_NO_EXCEPTIONS >> throw *this ; >> #endif >> } >> >> and that boost libraries throw such exceptions *only* by calling .raise(): >> i.e. never with a throw expression directly in the user code. >1. Why should this be a virtual function? The dynamic type of an > exception object is never used in a throw expression. I can think of one reason; if you are going to add a clone() method call to the exception hierarchy. Then you could save a copy of the exception object and rethrow it using the virtual method call. This is useful when you want to pass an exception across threads. It's also useful if you are wrapping a C interface that includes callbacks. Johan _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost