What does the profiler say? This can clearly vary from one
implementation to another (although only by a constant
factor—the complexity is required to be the same).
For that matter: has the profiler shown you are loosing too much
time here? The idiomatic way of writing this is:
a.erase( std::remove( a.begin(), a.end(), 8 ), a.end() );
Unless the profiler clearly says that this is a bottleneck, you
should write it in the idiomatic way, so that C++ programmers
recognize immediately what is happening, and don't waste time
recognizing that you're doing the same thing, and wondering why
you didn't do it in the idiomatic way.