|
Boost : |
From: Alexander Nasonov (alnsn-boost_at_[hidden])
Date: 2005-11-11 00:53:06
David Abrahams <dave <at> boost-consulting.com> writes:
> Alexander Nasonov writes:
> > FILE* files[10] = {};
> >
> > BOOST_FINALLY_BEGIN( (files) )
> > {
> > for(int i = 0; i < 10; ++i)
> > if(files[i])
> > ::fclose(files[i]);
> > } BOOST_FINALLY_END
> Boost::lambda has for loops, neh?
Can someone rewrite my example using lambda and post it here?
> > I prefer not hiding catch(...) from a user.
>
> Practically speaking, destructors are much better than catch(...) for
> finally-like operations on many platforms. Several of them have a
> similar problem to Windows, where catch(...) catches asynchronous
> exceptions.
We were talking about catch(...) inside a destructor. How can you
compare which one is better if both are in use?
Scott McMurray wrote:
> Also, I think it would be best if your code wrapped the code in the
> destructor in a try block to eat all exceptions thrown.
> I don't know what your plans for using a function-try-block are, but
> AFAICT that construct is only useful for exception translation during
> data member initialization.
It's only to eliminate extra {} around try/catch block. If I throw away a
requirement for throw-spec after BOOST_FINALLY_BEGIN, I can add these additional
{} to BOOST_FINALLY_BEGIN/BOOST_FINALLY_END macros. Then function-try-block
would become try-block.
-- Alexander
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk