From: Zbigniew Kostrzewa Date: Mon, 22 Jul 2013 07:54:18 +0000 (+0200) Subject: Inline scope guard factory function. X-Git-Tag: submit/tizen_2.2/20130927.091100^2~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1511eab34b0c8f20b9d3f10e63351f5fd357757d;p=platform%2Fframework%2Fweb%2Fwrt-commons.git 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 --- 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__]()