iterator invalidation trouble
From: Alexander Stippler (stip_at_mathematik.uni-ulm.de)
Date: 12/29/03
- Next message: Dan W.: "Re: MFC: How to draw a semi-transparent shape?"
- Previous message: Victor Bazarov: "Re: How to create 'pressed' buttons impression?"
- Next in thread: Gianni Mariani: "Re: iterator invalidation trouble"
- Reply: Gianni Mariani: "Re: iterator invalidation trouble"
- Reply: Ron Natalie: "Re: iterator invalidation trouble"
- Reply: Howard Hinnant: "Re: iterator invalidation trouble"
- Reply: Jeff Schwab: "Re: iterator invalidation trouble"
- Reply: Alexander Stippler: "Re: iterator invalidation trouble"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Dec 2003 18:22:31 +0100
Hi,
I've got trouble with some well known issue. Iterator invalidation. My
situation:
for (it=v.begin(); it!=v.end(); ++it) {
f(*it);
}
Under some circumstances, f may alter the container by removing the current
item. Thus the iterator it gets invalid. My question is, if there is a way
to handle this specific case. The problem is that the for loop is user
code, and the user should not even notice that v changed, so I cannot
simply introduce a second iterator inside the for loop. The iterator it
should simply go on iterating with the following item, if *it is deleted.
*it is defininitely the only item which can be deleted by f.
I think this problem is rather general. Are there any threads online on
"robust iterators for c++"? Is there a trick for my situation?
regards,
alex
- Next message: Dan W.: "Re: MFC: How to draw a semi-transparent shape?"
- Previous message: Victor Bazarov: "Re: How to create 'pressed' buttons impression?"
- Next in thread: Gianni Mariani: "Re: iterator invalidation trouble"
- Reply: Gianni Mariani: "Re: iterator invalidation trouble"
- Reply: Ron Natalie: "Re: iterator invalidation trouble"
- Reply: Howard Hinnant: "Re: iterator invalidation trouble"
- Reply: Jeff Schwab: "Re: iterator invalidation trouble"
- Reply: Alexander Stippler: "Re: iterator invalidation trouble"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]