R
RishiD
Hi,
I am using an iterator on a list, I wanted to know is there a simple
way to erase() the current element the iterator is pointing to and move
the iterator forward one?
The only way I can think of doing this is making a temp iterator equal
to orig position, then erasing, and setting the original iterator to
temp iterator++
Basically asking if there is a way to do the code below in two steps
instead of three.
Thanks,
RishiD
// move private iterator forward and eliminate person
void movingForward()
{
list<Person>::iterator tempIter = privIter;
circle.erase(privIter);
privIter = tempIter++;
}
I am using an iterator on a list, I wanted to know is there a simple
way to erase() the current element the iterator is pointing to and move
the iterator forward one?
The only way I can think of doing this is making a temp iterator equal
to orig position, then erasing, and setting the original iterator to
temp iterator++
Basically asking if there is a way to do the code below in two steps
instead of three.
Thanks,
RishiD
// move private iterator forward and eliminate person
void movingForward()
{
list<Person>::iterator tempIter = privIter;
circle.erase(privIter);
privIter = tempIter++;
}