STL implements a generic std::swap function to swap 2 values. It can be presented in the following way:
template void swap (T&am
XOR swap is really only a gimmick and can fail in certain cases (e.g. both variables are references to the same object).
XOR swap is also not particularly efficient as it has serial dependencies so it will always take at least three instruction cycles. Using a straightforward swap with a temporary has fewer dependencies, allowing for some parallelism on modern superscalar CPUs - on some CPUs it can even be implemented in one instruction, but even without special instructions it may well execute in two cycles.