
24 Mar
2006
24 Mar
'06
2:46 p.m.
Wouldn't it be nice to extend shared_ptr to support transaction-like semantics? Or is it possible already? Sometimes it's needed to execute code on exit only until we haven't reached some point (of "no return"): { shared_ptr<void> cr_guard(static_cast<void*>(0), bind(rollback_fun, x, y)); [...some critical part which should call rollback_fun on failure only...] //don't call rollback_fun if we get here cr_guard.commit(); [...any code that follows...] } Thanks! Wish you well! -=-=-=-=-=-=-=-=-=- Denis G. Priyomov