Re: [gtkmm] Gtkmm iterators



Roger,

erase() invalidates iterators pointing to elements after 
the point of deletion.

Never access an element through an invalid iterator; 
the effect is undefined and quite likely disastrous.

hope this helps, 
Vlad


On Thu, Dec 18, 2003 at 10:54:05AM +0000, Roger Leigh wrote:
> I'm using a Gtk::MenuShell::MenuList::iterator to look through the
> items in an OptionMenu and then erase items I no longer want:
> 
>       	  Gtk::MenuShell::iterator cur = items().begin();
> 	  while (cur != items().end())
> 	    {
>               [checks here]
> 		  if ([check was valid])
> 		    {
> 		      items().erase(cur);
> 		    }
> 		}
> 	    }
> 
> Question: is the iterator invalidated by the erase()?
> 
> Do the same iterator semantics apply to all other lists based on
> GLib::HelperList<>?
> 
> 
> Many thanks,
> Roger
> 
> -- 
> Roger Leigh
> 
>                 Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
>                 GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list

-- 
______________________________________________________
Vladislav Grinchenko    e-mail (w): vgrinche integ com
Software Engineer            (h): 3rdshift comcast net
Integral Systems, Inc.

   Focus on quality, and productivity will follow.
______________________________________________________



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]