Have you tried to replace them?
#include <algorithm> // ... swap(first, second);
(In C ++ 0x, #include significantly smaller <utility> header is enough.)
Moreover, if I have another iterator pointing to the same value as first , I want it to be correct too (keep it on the same value).
Just override other after replacement:
swap(first, second); other = first;
source share