(1) is the correct option.
(2) doesn't compile, and I have no idea what was your intent there.
(3) is pointless. Firstly, it can overflow and cause undefined behavior. There's a similar technique called XOR swap, that's not prone to overflows: a ^= b ^= a ^= b;
, but it's mostly a clever trick with no practical use. Wikipedia suggests to avoid it for performance reasons.