Boost logo

Boost :

From: ÂÞ ÎÄèº (kelvenlaw20_at_[hidden])
Date: 2006-11-16 03:32:42


>Peter Dimov said: (by the date of Wed, 15 Nov 2006 19:18:22 +0200)
>
> > Janek Kozicki wrote:
> > > Peter Dimov said: (by the date of Wed, 15 Nov 2006 15:54:14
+0200)
> > >
> > >> e.dismiss();
> > >
> > > why this? destructor of e does the work. No need to e.dismiss()
> > > Dave pointed out that std::uncaught_exception() inside e's destructor
> > > can check the conditions upon which the destructor is called and to
> > > the necessary work depending on it.
> >
> > uncaught_exception may still return true in a destructor that is called
> > during an ordinary return.
> >
> > ~X: called during stack unwinding
> >
> > calls f()
> >
> > void f()
> > {
> > Y y;
> > } // ~Y is called here, uncaught_exception is true
>
>So I have an idea - maybe put catch{} block inside destructor? :)
>
>X::~X()
>{
> try
> {
> // try nothing. If exception is active, the catch() will get
activated :)
> }
> catch(boost::exception& e)
> {
> e.gotcha();
> throw; // wow. It is a throwing destructor. What do you think?
> }
>}
>
>I haven't tested that, maybe I'm just wrong :>
>
>--
>Janek Kozicki |
I do not think it is a good idea to throw exception in the destructor,
because the object is destructed, while you throw the exception.The best
way to confirm the data is that make sure all the object is release before
destruct.
I do not know it is the best answer for you!:)

_________________________________________________________________
ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà MSN Messenger: http://messenger.msn.com/cn


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk