add SWAP macro
This commit is contained in:
parent
cbcbd9e6c4
commit
2643cb0e3c
|
@ -35,6 +35,15 @@ extern "C" {
|
|||
# define UNREACHABLE() (assert(false))
|
||||
#endif
|
||||
|
||||
#define SWAP(type,a,b) \
|
||||
SWAP_HELPER__(type,GENSYM(tmp),a,b)
|
||||
#define SWAP_HELPER__(type,tmp,a,b) \
|
||||
do { \
|
||||
type tmp = (a); \
|
||||
(a) = (b); \
|
||||
(b) = tmp; \
|
||||
} while (0)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue