Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


On Thursday 02 of February 2012, Stephan Bergmann wrote:
On 02/02/2012 11:26 AM, Lubos Lunak wrote:
  I agree with all the points, but in Julien's defense, I remember
exactly this same approach was pushed in recently as a fix to the same
issue elsewhere.

Might well be, I probably didn't notice.  And this is in no way meant to
criticize Julien -- but I assume that's clear, anyway.

Perhaps we should agree on what the recommended way is? I personally
think

Don't think its worth to go any more formal here.  I occasionally notice
things and give comments, trying to give rationales as well.  But in the
end, all those kinds of code are good and fine, anyway.

 I definitely didn't mean to get formal here, I simply meant a description of 
how to actually handle this, as it turns up now and then, and STL doesn't 
make this trivial.

the simplest and most elegant solution is to go with 'it =
container.erase( it );" and move the "++it" out of for()'s parentheses to
an else block of the

it = erase(it) is unfortunately only C++11

 Oh, it's a map. Bugger. Ok, especially in that case it might be useful to 
point out that the solution is to use a temporary iterator for removal and 
advance the real one first. I can't be the only one who'd need a while to 
figure it out otherwise.

-- 
 Lubos Lunak
 l.lunak@suse.cz

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.