yes..i understand..basically if I wanted to remove 10, the last element on the list
and i incremented it, I am going out of bounds..which...
thanks :P
yes..i understand..basically if I wanted to remove 10, the last element on the list
and i incremented it, I am going out of bounds..which...
thanks :P
You ended that sentence with a preposition...Bastard!
Yeah, I get the concept of remove and remove_if, as for the code, I'm not sure why it's pointless. The concept simply was, erase the thing being pointed to (5), take the returned iterator, which is one after the erased one (6), decriment it (4), continue, for loop header goes through, 4 --> 6, else you get the side-effect of erasing 5, then it's 6, then for loop makes i 7, 6 gets skipped.
I'm not sure what that sequence point stuff is based on the first 2 sentences of that wikpedia, nor how it only applies to C and C++. Pretty much any programming language the order in which you do things matters...if it didn't programming would be much different..that's like the premise of logic, obviously B cannot happen before A if the condition is A. Think I'm missing something, there..
EDIT:
Yeah, that does work, but it creates another problem, that's what if the element is first in the list, then decrementing it makes it invalid. So I wouldn't say the code is pointless, but it does create other problems..
/EDIT
If your list is only 5 long, then after you erase, the iter will be pointing to the end() iterator. You increment it, it's invalid, you can't dereference it.
If your list is more than 5 (or you're not erasing the last element) I see no reason anything is wrong. Should only happen with the max element.