
Hiall, I recall there have been sevral attempts at a boostified version of Andrei A. ScopeGuard. I want to start using this functionality and was wondering a) if there is any consensus about best/most boost-consistent implementation b) if there is there is a version in the library approval pipeline (or some definite plans for including this functionality in boost) thanks, max. This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.

"Max Khesin" <MKhesin@liquidnet.com> wrote:
I recall there have been sevral attempts at a boostified version of Andrei A. ScopeGuard. I want to start using this functionality and was wondering a) if there is any consensus about best/most boost-consistent implementation b) if there is there is a version in the library approval pipeline (or some definite plans for including this functionality in boost) thanks,
Multi index container library includes ScopeGuard (almost verbatim from Andrei) until some boost-wide solution appears. /Pavel

"Pavel Vozenilek" <pavel_vozenilek@hotmail.com> wrote in message news:c831jt$474$1@sea.gmane.org...
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? Andrei

"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

"Andrei Alexandrescu (See Website for Email)" wrote: [...]
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?
Destructors shall have implicit throw() exception specification. std::unexpected() shall be invoked at throw point (there shall be no unwinding at all). Two-phase EH is the way to go. regards, alexander. -- http://groups.google.com/groups?selm=40A4A365.85EC6B78%40web.de

"Max Khesin" <MKhesin@liquidnet.com> wrote:
I recall there have been sevral attempts at a boostified version of Andrei A. ScopeGuard. I want to start using this functionality ....
I came over TnFOX library: it contains ScopeGuard mechanism as well as ability to create guards conditionally. http://tnfox.sourceforge.net/TnFOX/html/group__rollbacks.html (section Groups). Such feature is very useful. /Pavel
participants (4)
-
Alexander Terekhov
-
Andrei Alexandrescu (See Website for Email)
-
Max Khesin
-
Pavel Vozenilek