瀏覽代碼

common: common_funcs: Add R_UNLESS_NOLOG for scenarios that should not log.

bunnei 5 年之前
父節點
當前提交
4577dcd5f9
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      src/common/common_funcs.h

+ 8 - 0
src/common/common_funcs.h

@@ -104,6 +104,14 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
         }                                                                                          \
     }
 
+/// Evaluates a boolean expression, and returns a result unless that expression is true.
+#define R_UNLESS_NOLOG(expr, res)                                                                  \
+    {                                                                                              \
+        if (!(expr)) {                                                                             \
+            return res;                                                                            \
+        }                                                                                          \
+    }
+
 #define R_SUCCEEDED(res) (res.IsSuccess())
 
 /// Evaluates an expression that returns a result, and returns the result if it would fail.