
"Andrei Alexandrescu wrote:
Multi index container library includes ScopeGuard (almost verbatim from Andrei) until some boost-wide solution appears.
What does it/should it do if the guard function throws an exception? Is there some try/catch in ScopeGuard's destructor?
I was never sure what to do there. You can't pass an error out, you can't throw... and to keep the library general, you can't do something like logging or writing to cerr. Any ideas?
The implementation in multi index container does not contain try/catch. My personal opinion is to keep it this way: - adding try/catch would add overhead, significant for simple operations - now it has (nearly) the same semantics as old fashioned manual handling: ON_BLOCK_EXIT(foo); behaves like hand written: if (!my_flag) foo(); Overload can be added: ScopeGuard<nothrow> = makeGuard<nothrow>(..) ON_BLOCK_EXIT_NOTHROW(...) for other cases. /Pavel