
AMDG Christian Holmquist <c.holmquist <at> gmail.com> writes:
Let's say I have two Worlds, and would like to add one person into each of these.I would prefer to write that like:
boost::scope_guard guard; World world1, world2;
world1.addPerson(guard, Person(...)); world2.addPersion(guard, Person(...));
guard.commit();
With the current proposal I don't see how I this could be done, since there is no visible notion of a context keeping the guards.
For my own work i've written a simple scope_guard that holds a std::vector<boost::function>, where I add all lambda expressions to be invoked unless I call scope_guard::commit(). This works but the lambda mess remains.
That isn't exception safe because 1) push_back can throw 2) function::function can throw You can think of the bool commit as the context keeping the guards. Unless you set it all the ScopeExit rollback actions will be executed exactly as in your example. In Christ, Steven Watanabe