added a macro to execute a codeblock when the scope is left
execution of multiple classes follows the default c++ stack order of destruction (later blocks are executed first) e.g.: { ARMARX_ON_SCOPE_EXIT { bar(); }; ARMARX_ON_SCOPE_EXIT { foo(); }; } //will execute: foo(); bar();
can be used to declare cleanup at the point of creation: { foo(); //nedds cleanup cfoo(); ARMARX_ON_SCOPE_EXIT{cfoo();}; ...//<<< bar(); //nedds cleanup cbar(); ARMARX_ON_SCOPE_EXIT{cbar();}; } if everything works both cleanup functions are called. if code at //<<< throws, only the first cleanup function is executed.