add SWAP macro
This commit is contained in:
parent
cbcbd9e6c4
commit
2643cb0e3c
|
@ -35,6 +35,15 @@ extern "C" {
|
||||||
# define UNREACHABLE() (assert(false))
|
# define UNREACHABLE() (assert(false))
|
||||||
#endif
|
#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)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue