In C++, Is there a nice way of automatically running some routine when a function return or scoped routine goes outside?
Using goto statement seems to help, but it misses when an exception is thrown and not treated by catch or finally statement. Unfortunately, finally statement cannot be used in C++. RAII is another way of doing it, but it forces me to define a class every time, that is cumbersome than finally statement.