23 class ScopeGuardHelper {
27 explicit ScopeGuard(T closure) : closure_(
std::move(closure)) {}
29 ~ScopeGuard() { closure_(); }
32 ScopeGuard(ScopeGuard&&) =
default;
33 ScopeGuard(
const ScopeGuard&) =
delete;
34 ScopeGuard& operator=(
const ScopeGuard&) =
delete;
35 ScopeGuard& operator=(ScopeGuard&&) =
delete;
43 ScopeGuard<T> operator<<(T closure) {
44 return ScopeGuard<T>(std::move(closure));
48 #define _SG_MACRO_CONCAT2(a, b) a##b 49 #define _SG_MACRO_CONCAT(a, b) _SG_MACRO_CONCAT2(a, b) 50 #define _SG_ANONYMOUS(prefix) _SG_MACRO_CONCAT(prefix, __COUNTER__) 52 #define SCOPE_EXIT auto _SG_ANONYMOUS(_scope_guard_) = core::ScopeGuardHelper() << [&]() Generic utilities.
Definition: exception.h:24