Эх сурвалжийг харах

Update swap for one evaluation

Kajetan Johannes Hammerle 3 сар өмнө
parent
commit
e456fd0936

+ 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