How can you not be romantic about XOR?
I posted this gist 13 years ago... Know, it's time to think about it.
// Swap with no extra memory
template <class T>
void swap(T& a, T& b) {
a ^= b;
b ^= a;
a ^= b;
}
How can you not be romantic about XOR?
I posted this gist 13 years ago... Know, it's time to think about it.
// Swap with no extra memory
template <class T>
void swap(T& a, T& b) {
a ^= b;
b ^= a;
a ^= b;
}