Boost logo

Boost Users :

From: Aaron W. LaFramboise (aaronrabiddog51_at_[hidden])
Date: 2005-01-21 16:36:06


Jonathan Turkanis wrote:

> Since you don't want to write a special class for RAII, it sounds like a job for
> scope_guard + lambda. scope_guard is currently an implementation detail in
> multi_index, but will soon move to detail. The lambda expressions for control
> stuctures

scope_guard is exactly what I was looking for here.

Its too bad, though, that the syntax for it really isn't that great.
One thing I don't like to see in a design of a reusable component is
something that requires a lot of structure that doesn't have anything to
do with the problem domain.

In any case, would it be possible to move scope_guard to a place where
users may legitimately use it, rather than detail? Is there a
particular reason that arbitrary code shouldn't use it, or that its
interface may change in the future, any more than any other documented
Boost interface?

> I don't see why you need boost::function

The lambda expression needs to be stored somewhere. The actual
automatic variable can't be templatized based on the type of the functor
without being profane, so some sort of tool like boost::function or
boost::any should be required.

scope_guard pretty much reimplements what boost::function provides by
itself.

Aaron W. LaFramboise


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net