瀏覽代碼

Update swap for one evaluation

Kajetan Johannes Hammerle 3 月之前
父節點
當前提交
e456fd0936
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      include/core/Utility.h

+ 5 - 3
include/core/Utility.h

@@ -48,9 +48,11 @@ i64 getNanos(void);
 // TODO: replace typeof with auto when available
 #define swap(a, b)                                                             \
     do {                                                                       \
-        typeof(*(a)) tmp = *(a);                                               \
-        *(a) = *(b);                                                           \
-        *(b) = tmp;                                                            \
+        typeof(a) aPointer = (a);                                              \
+        typeof(b) bPointer = (b);                                              \
+        typeof(*aPointer) tmp = *aPointer;                                     \
+        *aPointer = *bPointer;                                                 \
+        *bPointer = tmp;                                                       \
     } while(0)
 
 #endif