
Maxim Yanchenko <maximyanchenko <at> yandex.ru> writes:
I vote to accept the library into Boost.
Thanks.
A couple of general comments after reading other reviews.
1. The fact that the library takes all arguments by reference looks unavoidable. If it allowed passing by value (i.e. making copies) - the copy constructors can throw, and this exception will be thrown after you made the change to your container/whatever you'd like to rollback, and before you setup the rollback action. So you can't guarantee that your rollback action will be executed.
Very good point. It makes me think that ScopeExit and local functions have different defaults for passing arguments. Agruments should be passed by value to a local function to avoid dangling references when the function outlives the scope. So, my current favorite is BOOST_SCOPE_EXIT( cref(c) ref(r) val(v) ). IMO, it looks more natural than (a)(b)(c). More verbose but this verbosity has a purpose.
So, in case you need a copy - it's much safer to create this copy before making the change to your container/whatever. It will also express your intention more clearly.
I should document it. -- Alexander