On 15/01/2013 10:20, FG wrote:
<snip>
All thanks to a terrible naming decision...
It's not remove but move_to_end. Why call it remove?

It doesn't necessarily move them to the end, going by
http://www.cplusplus.com/reference/algorithm/remove/
"The relative order of the elements not removed is preserved, while the elements past the new end of range are still valid, although with unspecified values."

Just looking at the sample implementation there....

    if (!(*first == value)) *result++ = *first;

places each non-removed value in its place in the final state of the container, but doesn't do anything particular with the value where it was taken from. In a C++11 implementation, I would expect it to become

    if (!(*first == value)) *result++ = std::move(*first);

Stewart.

Reply via email to