<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 8, 2011, at 10:21 AM, Chad Rosier wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><blockquote type="cite"><br class="Apple-interchange-newline">Unless there's something non-obvious (which could be commented, if<br></blockquote><blockquote type="cite">that's the case) you could use the iterator returned by erase:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">for (iterator it = begin(), ie = end(); it != ie; ) {<br></blockquote><blockquote type="cite">if ((*it)->getOption().matches(Id)) {<br></blockquote><blockquote type="cite">  it = Args.erase(it);<br></blockquote><blockquote type="cite">} else {<br></blockquote><blockquote type="cite">  ++it;<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite">}<br></blockquote><br>I committed the above in revision 137051.  The args list should be relatively short, so this solution is good.<br></span></blockquote></div><br><div>David,</div><div>I ran into another case where such a loop was useful.  However, using code similar to the above </div><div>resulted in an infinite loop in this case.  After the Args.erase(it) I believe it is necessary to update ie.</div><div><br></div><div>Something like this:</div><div><div><br></div><div>for (InputList::iterator it = Inputs.begin(), ie = Inputs.end(); it != ie;) {</div><div>  if (types::getPreprocessedType(it->first) == types::TY_INVALID) {</div><div>    it = Inputs.erase(it);</div><div>    ie = Inputs.end();</div><div>  } else</div><div>    ++it;</div><div>}</div></div><div><br></div><div> Chad</div></body></html>