
Hello, Better is such a big word. You still have to say in which way it is better; readability, efficiency, simplicity, something else? ;-) I admit my solution is not perfect, but it does have certain advantages... First, you seem to use boost/typeof/typeof.hpp, which I failed to find in the boost version I currently use (stable 1.33.1). I didn't find the documentation in the full doc, only the BoostBook. Why do you need that library and is it absolutely necessary? I don't think it should from the concepts necessary to put the thing together. All you need, after all, is a destructor to call the code, and some variable passing (Boost.Bind is very wonderful). Also, I'm not a big fan of macros, even more when using IDs in them, I think they reduce readability. I prefer compilers to pre- compilers, if you know what i mean. In your case, adding a scope inside the SCOPE_XXX makes for more indentation, which is not necessarily A Good Thingie. I suggest at least putting those brackets inside the SCOPE_XXX defines. This is all, of course, a matter of taste. BTW, what happens if I typo the ID or just use the same in two different places (either in the same scope or inlined scopes). My solution is CopyConstructable. Many things become interesting when you can copy a chain of commands. It is also bidirectionnal. With a flag at construction, we could invert the order of execution. We could also reorder it in the middle (cannot think of a real use for this, though). BTW, did you check my code? You never told me what you thought of it... Hans PS: I don't think a vector of function calls have been made in boost. I may be wrong On 30-Mar-07, at 7:37 PM, Alexander Nasonov wrote:
Hans Larsen wrote:
Hi,
You've probably seen "modern" languages that incorporate the keyword finally, but nothing such exists in C++. I've come with a simple
I've just announced an update of the ScopeExit library. It's much better than the finally keyword ;-)
http://194.6.223.221/~nasonov/scope_exit-0.02/libs/scope_exit/doc/ html/
-- Alexander Nasonov http://nasonov.blogspot.com
You may delay, but time will not. -- Benjamin Franklin --
This quote is generated by: /usr/pkg/bin/curl -L http://tinyurl.com/veusy \ | sed -e 's/^document\.write(.//' -e 's/.);$/ --/' \ -e 's/<[^>]*>//g' -e 's/^More quotes from //' \ | fmt | tee ~/.signature-quote _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/ listinfo.cgi/boost