yanglimingcn commented on code in PR #2643:
URL: https://github.com/apache/brpc/pull/2643#discussion_r1599287855


##########
src/butil/memory/scope_guard.h:
##########
@@ -83,6 +84,25 @@ ScopeGuard<Callback> MakeScopeGuard(Callback&& callback) 
noexcept {
     return ScopeGuard<Callback>{ std::forward<Callback>(callback)};
 }
 
-}
+namespace internal {
+// for SCOPE_EXIT.
+enum class ScopeExitHelper {};
+
+template<typename Callback>
+ScopeGuard<Callback>
+operator+(ScopeExitHelper, Callback&& callback) {
+    return MakeScopeGuard(std::forward<Callback>(callback));
+} // namespace internal
+} // namespace butil
+
+#define BAIDU_ANONYMOUS_VARIABLE(prefix) BAIDU_CONCAT(ptrfix, __COUNTER__)
+
+// The code in the braces of SCOPE_EXIT always executes at the end of the 
scope.
+// Variables used within SCOPE_EXIT are captured by reference.
+#define SCOPE_EXIT                                           \

Review Comment:
   嗯,如果用户不想要用引用的方式捕获变量,可以直接调用MakeScopeGuard



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to