From 1511eab34b0c8f20b9d3f10e63351f5fd357757d Mon Sep 17 00:00:00 2001 From: Zbigniew Kostrzewa Date: Mon, 22 Jul 2013 09:54:18 +0200 Subject: [PATCH] Inline scope guard factory function. [Issue#] N/A [Problem] N/A [Cause] N/A [Solution] Inlining this function should improve efficiency. [SCMRequest] N/A [Verification] 1. Build respository. 2. Run command: `wrt-commons-tests-core --output=text --regexp='ScopeGuard*'` Change-Id: I24d7ce9ad26411997829b6feb3a59326b60cb7c2 --- modules/core/include/dpl/scope_guard.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/core/include/dpl/scope_guard.h b/modules/core/include/dpl/scope_guard.h index 2471937..21a7b0c 100644 --- a/modules/core/include/dpl/scope_guard.h +++ b/modules/core/include/dpl/scope_guard.h @@ -81,7 +81,7 @@ class ScopeGuard }; template -ScopeGuard::type> +inline ScopeGuard::type> MakeScopeGuard(FunctionType&& function) { return ScopeGuard::type>( @@ -92,7 +92,7 @@ namespace detail { enum class ScopeGuardOnExit {}; template -ScopeGuard::type> +inline ScopeGuard::type> operator+(detail::ScopeGuardOnExit, FunctionType&& function) { return ScopeGuard::type>( @@ -101,7 +101,9 @@ operator+(detail::ScopeGuardOnExit, FunctionType&& function) } } -// FIXME provide support for compilers not supporting variadic macros +// FIXME provide support for compilers not supporting variadic macros; +// instead of using variadic macros (for compatibility) we could +// capture all by '&' (only referenced variables would be captured) #define DPL_SCOPE_EXIT(...) \ auto DPL_ANONYMOUS_VARIABLE(DPL_SCOPE_EXIT_STATE) \ = ::DPL::detail::ScopeGuardOnExit() + [__VA_ARGS__]() -- 2.34.1