A colleague emailed me this neat little trick that made me snodchortle.

Look at this C++ code:

int a = 1;
int b = 2;

a ^= b;
b ^= a;
a ^= b;

What does this code do?

What are the values of a and b respectively at the end?

What are the benefits of this approach and what are the disadvantages?