Check out example codes for "swap two elements of a vector". It will help you in understanding the concepts better.

Code Example 1

std::iter_swap(arr.begin()+pos1,arr.begin()+pos2);

Learn ReactJs, React Native from akashmittal.com