Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <typename F>
- struct ScopeExit {
- ScopeExit(F f) : f(f) {}
- ~ScopeExit() { f(); }
- F f;
- };
- template <typename F>
- ScopeExit<F> MakeScopeExit(F f) {
- return ScopeExit<F>(f);
- };
- #define SCOPE_EXIT(code) \
- auto STRING_JOIN2(scope_exit_, __LINE__) = MakeScopeExit([=](){code;})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement