Exceptional coding style
Tavi Cacina
octavian.cacina at outlook.com
Mon Jan 14 23:24:26 PST 2013
Am 15.01.2013 01:55, schrieb Stewart Gordon:
> vec.erase(std::remove(vec.begin(), vec.end(), val), vec.end());
>
> Gee, that's going to be typed correctly by every programmer every time!"
>
> It seems that even the writer of that piece hasn't typed it correctly -
> from what I can make out, that code would remove everything _except_ val
> from vec. Either that or it wouldn't work at all, since the vector
> returned by remove is no longer a plain vector iterator.
That piece of code is correct.
http://en.wikipedia.org/wiki/Erase-remove_idiom
More information about the Digitalmars-d
mailing list