|
|
|
|
|
by anematode
61 days ago
|
|
It's not quite the same as XOR swap, but a trick I've found handy is conditionally swapping values using XOR: int a, b;
bool cond;
int swap = cond ? a ^ b : 0;
a ^= swap;
b ^= swap;
If cond is highly unpredictable this can work rather nicely. |
|