is not defined by the standard. Do...
offtopic tip
Don't do...
Code:
listIter < this->elementList.end( )
...in the
for-loop. At every iteration,
end() needs to be recalculated.
Do:
Code:
std::vector<element*>::iterator ItEnd;
ItEnd = elementList.end( );
for (listIter = elementList.begin( ); listiter != ItEnd; ++listIter)
{ }
- Observe
!=.
Any iterator
it < vector::end() is undefined since
end() is a pointer *past* the last element. So this comparison makes technically no sense.
- Observe
++listiter
Your element object *may* create an internal temporary object and therefore *may* add runtime overhead due to copy constructor calls and destructor calls. Using the pre-increment operator prevents this.