Boost logo

Boost :

From: William Kempf (sirwillard_at_[hidden])
Date: 2000-11-07 14:35:02

--- In boost_at_[hidden], Thomas Maeder <maeder_at_g...> wrote:
> jbandela_at_u... wrote:
> >
> > Has anyone else seen the Generic Programming article this month on
> > CUJ Expert Forum? I personally was pretty impressed by it. I was
> > wondering if anybody else shares my opinion, and if in the future
> > or something like it could be incorporated into the boost library?
> It would be interesting to integrate the approach with the lambda

Some months back I wrote a class very similar to this for use in my
COM programming. It took any valid functor type as a call back (so
LL would work great with it... only my compiler doesn't like LL). In
addition it kept a "stack" of such callbacks instead of taking only a
single callback. This made it much nicer to work with when there
were multiple operations that would need to be rolled back. If
there's interest I can clean things up and boostify them for
submission into Boost.

Example useage of my class (name changes to be more in line with

void func()
   scope_guard guard;

   // roll back the add if an exception occurs
   guard.push(bind(remove_record, ...));

   // roll back the changes if an exception occurs
   guard.push(bind(update_record, ...));

   // illustrates dismissing a single operation
   scope_guard::cookie c1 = guard.push(bind(update_record, ...));

   // illustrates dismissing all registered operations

Bill Kempf

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