I'm trying to get information if below code is undefined behavior, I did read here.
In particular I want to be sure that iterator variable iter will be valid in cases where moved elements overlap destination range.
I think this is not good but can't confirm, and what would be better way to do this?
#include <vector> #include <iostream> int main() { // move 3, 4 closer to beginning std::vector<int> vec { 1, 2, 3, 4, 5, 6, 7 }; auto iter = std::move(vec.begin() + 2, vec.end() - 3, vec.begin() + 1); std::cout << *iter << std::endl; } also there is no reference to what this iter is supposed to point at?