Use .data() instead of &x[0]
Use std::swap