Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. template <typename F>
  2. struct ScopeExit {
  3. ScopeExit(F f) : f(f) {}
  4. ~ScopeExit() { f(); }
  5. F f;
  6. };
  7.  
  8. template <typename F>
  9. ScopeExit<F> MakeScopeExit(F f) {
  10. return ScopeExit<F>(f);
  11. };
  12.  
  13. #define SCOPE_EXIT(code) \
  14. auto STRING_JOIN2(scope_exit_, __LINE__) = MakeScopeExit([=](){code;})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement