From 770afcd2fe07c7588e11dd4549e59670dac9afda Mon Sep 17 00:00:00 2001 From: "pius.lee" Date: Tue, 10 Feb 2015 12:53:01 +0900 Subject: [PATCH] [Common] fix scope exit macro enable to use multiple in a scope. Change-Id: Idd8dd5cb346c485c442211127ee1072b74a60aee Signed-off-by: pius.lee --- src/common/scope_exit.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/scope_exit.h b/src/common/scope_exit.h index 62353c75..fda1b455 100644 --- a/src/common/scope_exit.h +++ b/src/common/scope_exit.h @@ -106,8 +106,10 @@ operator+(__dummy, F&& f) * // do 3rd operation with unit and possibly quit function * } */ +#define _SYNTAX_CONCAT(A, B) A ## B +#define SYNTAX_CONCAT(A, B) _SYNTAX_CONCAT(A, B) #define SCOPE_EXIT \ - auto SCOPE_EXIT_##__LINE__ = ::common::__dummy{} + [&]() noexcept + auto SYNTAX_CONCAT(SCOPE_EXIT_, __LINE__) = ::common::__dummy{} + [&]() } // namespace common -- 2.34.1