> and doesn't use an temporary variable (thus faster):
I very much doubt it.
Every time I've tried these "cute" methods, all they do is confuse the compiler optimiser (as well as the average reader).
Also, signed integer overflow / underflow produces undefined behaviour.
Stick to using a temporary - it always works, it works with any type and the compiler optimiser will see what you are doing. With any luck, it will rearrange the following code to effectively eliminate the swap from ever happening.
Here's just one way in which clever tricks outwit the programmer
Code:
#include <stdio.h>
void swapper ( int *a, int *b ) {
*a ^= *b;
*b ^= *a;
*a ^= *b;
}
int main ( ) {
int a = 10, b = 20;
printf( "%d %d\n", a, b );
swapper( &a, &b );
printf( "%d %d\n", a, b );
swapper( &a, &a ); /* with itself */
printf( "%d %d\n", a, b );
return 0;
}