Boost logo

Boost :

From: Eyal Farago (eyalfa_at_[hidden])
Date: 2002-06-06 01:45:37

The destructor of boost::details::scoped_lock is not virtual, I'm not sure but this looks like a problem.
I'm not exactly familiar with the 'bind to const reference' rule, but it seems to me that in this case the object returned by make_scope_guard is manipulated through reference to base and therefore destroyed this way. I know that on vc6.5 the correct d'tor is called but I don't know if this is standart behavior.


-----Original Message-----
From: Joe Swatosh [mailto:joe-swatosh_at_[hidden]]
Sent: Thursday, June 06, 2002 3:17 AM
To: boost_at_[hidden]
Subject: [boost] Boostifying ScopeGuard

Petru Marginean and Andrei Alexandrescu wrote a handy group of classes that will call a function when a "guard" object goes out of scope (unless the "guard" has been "dismissed"), that they documented in a CUJ "C++ Experts Forum" column. The article is available online:

With their permission, I've attempted to "boostify" this group of classes. I have uploaded these files to the "vault" (together they are fewer than 200 lines so I hope not compressing them isn't too big a deal). The code has been tested with VC6SP5, VC7, and Borland 5.5.

I realized that much of the code in the original was for binding arguments to the function to be called and so could be replaced by boost::bind. Other than that I renamed things to be more like the naming conventions on the boost website, and simplified where possible.

I recognize that this is basically a primitive "smart resource" and that smart resources have been discussed a lot lately especially in the context of smart pointers. These classes are just so simple and useful that I want to propose something _now_ to fill the gap. This much too small to be a boost library by itself and I'm not sure where it might fit, so here it is to talk about.

Joe Swatosh [mailto:joe-swatosh_at_[hidden]]
3305 Main St. Suite 201
Vancouver, WA 98663
Unsubscribe & other changes:

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