You can use std::swap here http://www.cplusplus.com/reference/algorithm/swap/
(Or is there some reason why we cannot use it?)