The third argument to std::remove
is a const
reference. You are changing the value of the element refered to as you move elements around, leading to undefined behaviour.
This would be well behaved:
auto elem = vec.front(); // copy front element
vec.erase(std::remove(std::begin(vec), std::end(vec), elem),
std::end(vec));
Output:
1, 1, 1,