swap in c++ vector code example
Example 1: swap two elements of a vector
std::iter_swap(arr.begin()+pos1,arr.begin()+pos2);
Example 2: C++ Vector swap syntax
vector<T>().swap(x); // clear x reallocating
Example 3: swap vector c++
vector1.swap<vector2>;
//time complexity: O(1)