Boost logo

Boost :

From: Hillel Y. Sims (hsims_at_[hidden])
Date: 2002-09-27 17:40:05

"David Abrahams" <dave_at_[hidden]> wrote in message
> I don't really like scopeguard-like things for such jobs, since the danger
> of the above is that you have to remember to throw;, while you need to
> remember to cancel the scopeguard. It's an even trade. Of course if you
> factor in Mr. Terekhov's favorite issue (weird entaglements with
> not-really-C++ platform "exceptions"), the scopeguard might be a better
> solution.

     try {
     catch(...) {


    ScopeGuard guard =

The ScopeGuard version is 1) fewer lines of code, 2) easier to test -- if
you forget to Dismiss(), you'll find out immediately during ordinary
testing, vs. missing the throw; in more difficult to test (possibly even
untested?) exception-handling code, 3) scales better (what if you have
three/four/etc. updates to synchronize?), 4) "not-really-C++" all you like,
but still exists as a real-world issue, especially if you are trying to
write safe portable code (besides, they could be implemented as "really-C++"
exceptions on a given platform too).


Hillel Y. Sims
FactSet Research Systems
hsims AT

Boost list run by bdawes at, gregod at, cpdaniel at, john at