diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:19:14 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:19:14 +0200 |
commit | 01eb8253196672c969a39587e90b49321a182428 (patch) | |
tree | 4a3b71d7913de519744466c9227fda6461c4f0b5 /zen/scope_guard.h | |
parent | 5.0 (diff) | |
download | FreeFileSync-01eb8253196672c969a39587e90b49321a182428.tar.gz FreeFileSync-01eb8253196672c969a39587e90b49321a182428.tar.bz2 FreeFileSync-01eb8253196672c969a39587e90b49321a182428.zip |
5.1
Diffstat (limited to 'zen/scope_guard.h')
-rw-r--r-- | zen/scope_guard.h | 8 |
1 files changed, 5 insertions, 3 deletions
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 <cassert> + //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<F> makeGuard(F fun) { return ScopeGuardImpl<F>(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 |