
Is there an interest to write something like this int i = 2, j = 1; BOOST_FINALLY_BEGIN( (i)(j) ) { std::cerr << i + j << '\n'; } BOOST_FINALLY_END in a code to make sure that a code inside finally block is always executed when leaving a scope? Code is here: http://files.rsdn.ru/21403/finally.cpp Note that it depends on typeof. Preprocessed output is below: // Not thread-safe yet void* _finally_last_params = 0; int main() { int i = 2, j = 1; typedef typeof(i) _finally_typeof_46i; typedef typeof(j) _finally_typeof_46j; struct _finally_params_46 { _finally_typeof_46i & i ; _finally_typeof_46j & j ; } _finally_params_46 = { i, j }; _finally_last_params = &_finally_params_46; struct _finally_guard_46 { void* _finally_params; ~_finally_guard_46() { typedef struct _finally_params_46 params; params* p= static_cast<params*>(_finally_params); _finally_body(p -> i , p -> j , 0); } static void _finally_body( _finally_typeof_46i & i , _finally_typeof_46j & j , int) { // USER CODE HERE std::cerr << i + j << '\n'; } } _finally_guard_48 = { _finally_last_params }; } -- Alexander