Boost:ScopeExit
Execute arbitrary code at scope exit.
Example
#include <boost/scope_exit.hpp>
#include <iostream>
int main( void )
{
    int a = 3;
    BOOST_SCOPE_EXIT( (&a) )
    {
        std::cout << a << std::endl;
    }
    BOOST_SCOPE_EXIT_END;
    return 0;
}