do std::swap() only if exchange was successfull