[Effective-cpp] Item 1: Uses and Abuses of vector

White Wolf wolof at freemail.hu
Wed Oct 27 10:54:37 EDT 2004


effective-cpp-bounces at accu.org wrote:
> OOPS!!!  I meant to write "I would NOT use . . ."  sorry about that.
> 
>> On another point raised, I would use this sort of loop for a vector
>> that I intend to modify, especially if the modification involved
>> removing items.  I learned this the difficult way, once trying to
>> iterate through a vector to remove elements, and at times, the
>> removal would blow the "end iterator" away.

I believe that the problem is that in real life "I" (you - in your text)
means the 50 developers at any given time working on a project and "intend
to" means the next 10 years or how much the codebase is going to be used.
That was the reason why I was wondering why do you (you as all people who
are using this idea) think that end() is calculated and it takes so much CPU
that it is worth the risk you have just described above.  Especially in the
light of end() (on many implementations) just returning a member variable.

Attila





More information about the Effective-cpp mailing list