59b Subj : Re: BC5.02 STL question To : borland.public.cpp.borlandcpp From : MarvinAvery Date : Tue Jun 01 2004 11:19 am "Ed Mulroy [TeamB]" wrote in message news:40bb7961$2@newsgroups.borland.com... > When used only to increment, no use of the value: > > Post increment can call a copy constructor and may have other side > effects depending upon the details of the object involved. > > For an integer where the value is not used in the statement the > overhead is small but still bad compared to pre-increment. That is > probably why the compiler writers decided to make the optimizer detect > the situation and generate code for pre-increment. > I'll have to rtemember this. > > Assuming that all that is being done only involves the vector itself > so no side effects came into play then yes, the overhead of iterator > vs index is small. However that small overhead can add up to a large > number of CPU cycles if operations are done on large vectors or many > iterative or looping operations done on vectors. for_each uses > iterators and is usually a bit more efficient. > Right. I understand what you are saying. For my code, the vectors are pretty small so it shouldn't make much of a difference; but I will remember this if, in future, I end up using large vectors. Really usefull information. Thanks. -- Marvin Avery marvin.avery@sdc-dsc.gc.ca . 0