swap vectors in c++ code example Example: swap two elements of a vector Click to copystd::iter_swap(arr.begin()+pos1,arr.begin()+pos2);