#define SCOPE_EXIT(...)\ struct SE##__LINE__##_{~SE##__LINE__##_(){__VA_ARGS__;}}se##__LINE__##_
The version in Facebook Folly was cleaned up because of C++11, but this wasn’t a new technique five years ago.