Boost logo

Boost :

Subject: Re: [boost] [inspect] exceptions (FW: [Boost-users] no exceptions)
From: Brian Wood (woodbrian77_at_[hidden])
Date: 2011-03-25 17:36:03


Robert Kawulak:
> You can eliminate the try/catch from the code. For example, instead of:
>
> try {
> // do sth dangerous using cmpRead
> } catch(...) {
> cmpRead = 0;
> throw;
> }
>
> write:
>
> auto tmp = cmpRead;
> cmpRead = 0;
> // do sth dangerous using tmp
> cmpRead = tmp;

Hi, Robert,

Thanks for that. I tried it. The implementation is available
here -- http://webEbenezer.net/misc/rcb.hh . It's one line shorter
than the version with the try/catch, but it adds 3 minor statements
to the non-error path. On Fedora 14 with g++ 4.5.1 one of my
executables increased in size by over 500 bytes when using
the version without a try/catch. On Windows 7 with MSVC++ 10
there wasn't any size difference in the executable. I find the
try/catch version easier to understand though.

-- 
Brian Wood
Ebenezer Enterprises
http://webEbenezer.net

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