About swap, in C++, we can swap two by std::swap(x, y);. x and y are passed into swap as reference.
swap
std::swap(x, y);
x
y
reference
But
You could just directly write
a, b = (b, a)