Good point. Actually, I simplified the function declaration for the purposes of the queston. The end vector is also supplied as a parameter to the function.
However, the function is indeed aware of the list and simply defaults to the beginning of the list if itStartPos parameter is NULL.
I guess your right - I'm going to have to drop the default parameter here and update each call to the function. Serves me right for using a hack to assign NULL to it in the first place. Damn this new strict checking!!!
So I see. This is causing me some real headaches!!!
Is there no assignement that can be made to the iterator which means its invalid?
I used to assign NULL to iterators to mean they wern't being used.
Then I could simply check its NULL status and act accordingly.
There must be a way of saying an iterator is invalid.
If I assign it the value of vectorlist.end() I could test against that - but does initial end assignment remain valid after things are added to the vector list?
Always NULL the pointer after deleting it. Otherwise you could (if you're not very, very careful) try to delete the same pointer twice, which will result in an access violation.
Deleting a NULL pointer however is perfectly safe.
Another reason for doing that is that the address used for the recently-deallocated memory may still be valid in your address space and while not technically valid for use, accessing it might not cause an IPF or Access Violation. For example:
The above code may not crash even though the pointer is technically invalid.
By setting it to NULL, you just about guarantee that accessing it will cause an Access Violation (at least if on Win32 and if the access range of the pointer is < 4096, because that hits the reserved "NULL pointer page" which causes an instant exception, IIRC).
-=- JamesIf you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)