From 01eb8253196672c969a39587e90b49321a182428 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:19:14 +0200 Subject: 5.1 --- zen/scope_guard.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'zen/scope_guard.h') diff --git a/zen/scope_guard.h b/zen/scope_guard.h index cc2f31e6..86d22c91 100644 --- a/zen/scope_guard.h +++ b/zen/scope_guard.h @@ -8,6 +8,8 @@ #ifndef ZEN_SCOPEGUARD_8971632487321434 #define ZEN_SCOPEGUARD_8971632487321434 +#include + //best of Zen, Loki and C++11 namespace zen @@ -21,7 +23,7 @@ namespace zen //Scope Exit /* - ZEN_ON_BLOCK_EXIT(::CloseHandle(hDir)); + ZEN_ON_SCOPE_EXIT(::CloseHandle(hDir)); */ class ScopeGuardBase @@ -56,7 +58,7 @@ public: { fun_(); } - catch (...) {} + catch (...) { assert(false); } } private: @@ -72,6 +74,6 @@ ScopeGuardImpl makeGuard(F fun) { return ScopeGuardImpl(fun); } #define ZEN_CONCAT_SUB(X, Y) X ## Y #define ZEN_CONCAT(X, Y) ZEN_CONCAT_SUB(X, Y) -#define ZEN_ON_BLOCK_EXIT(X) zen::ScopeGuard ZEN_CONCAT(dummy, __LINE__) = zen::makeGuard([&](){X;}); (void)ZEN_CONCAT(dummy, __LINE__); +#define ZEN_ON_SCOPE_EXIT(X) zen::ScopeGuard ZEN_CONCAT(dummy, __LINE__) = zen::makeGuard([&]{ X; }); (void)ZEN_CONCAT(dummy, __LINE__); #endif //ZEN_SCOPEGUARD_8971632487321434 -- cgit