Re: Question about iterator management in sw/source/core/fields/cellfml.cxx

2012-02-03 Thread julien2412
I followed the idiom you indicated, commited and pushed on master (see 9d0136679e441413b6945d2a40aa892b50ee19a8) Thank you Stephan for the details about C++ Hope that C++11 will spread quickly because all these things aren't very intuitive. Julien -- View this message in context: http://nabble.d

Re: Question about iterator management in sw/source/core/fields/cellfml.cxx

2012-02-03 Thread Terrence Enger
On Fri, 2012-02-03 at 18:30 +0100, Michael Stahl wrote: > On 03/02/12 18:17, Terrence Enger wrote: > > > Stephan, I am sorry to question your expertise, but I wonder ... is > > your reassurance based on knowledge of the language standard, or is > > based on observed behaviour of C++ compilers? >

Re: Question about iterator management in sw/source/core/fields/cellfml.cxx

2012-02-03 Thread Michael Stahl
On 03/02/12 18:17, Terrence Enger wrote: > Stephan, I am sorry to question your expertise, but I wonder ... is > your reassurance based on knowledge of the language standard, or is > based on observed behaviour of C++ compilers? hahaha, i believe that among all the developers who ever worked on O

Re: Question about iterator management in sw/source/core/fields/cellfml.cxx

2012-02-03 Thread Terrence Enger
On Fri, 2012-02-03 at 17:31 +0100, Michael Stahl wrote: > On 03/02/12 17:21, Stephan Bergmann wrote: > > On 02/03/2012 04:18 PM, Michael Stahl wrote: > >> On 03/02/12 14:01, Stephan Bergmann wrote: > >>> The "standard idiom" is > >>> > >>> for (iterator i = m.begin(); i != m.end();) { > >>>

Re: Question about iterator management in sw/source/core/fields/cellfml.cxx

2012-02-03 Thread Stephan Bergmann
On 02/03/2012 05:31 PM, Michael Stahl wrote: ah, that's surprising. that's shocking ;) see, that is why i almost always write the i++ as an extra statement, i'm never quite exactly sure what it does, and when :) There is a sequence point (in C++03 parlance; the nomenclature changed slight

Re: Question about iterator management in sw/source/core/fields/cellfml.cxx

2012-02-03 Thread Michael Stahl
On 03/02/12 17:21, Stephan Bergmann wrote: > On 02/03/2012 04:18 PM, Michael Stahl wrote: >> On 03/02/12 14:01, Stephan Bergmann wrote: >>> The "standard idiom" is >>> >>> for (iterator i = m.begin(); i != m.end();) { >>> if (doErase) { >>> m.erase(i++); >>> } else { >>>

Re: Question about iterator management in sw/source/core/fields/cellfml.cxx

2012-02-03 Thread Stephan Bergmann
On 02/03/2012 04:18 PM, Michael Stahl wrote: On 03/02/12 14:01, Stephan Bergmann wrote: The "standard idiom" is for (iterator i = m.begin(); i != m.end();) { if (doErase) { m.erase(i++); } else { ++i; } } but doesn't that have the same problem? "i" is

Re: Question about iterator management in sw/source/core/fields/cellfml.cxx

2012-02-03 Thread Michael Stahl
On 03/02/12 14:01, Stephan Bergmann wrote: > On 02/02/2012 09:08 PM, julien2412 wrote: >> Would this patch better ? (I kept the for loop) > > Unfortunately that still has a problem. After "rBoxes.erase(toErase)", > "it" (which is the same as "toErase") is invalidated, so incrementing it > (up i

Re: Question about iterator management in sw/source/core/fields/cellfml.cxx

2012-02-03 Thread Stephan Bergmann
On 02/02/2012 09:08 PM, julien2412 wrote: Would this patch better ? (I kept the for loop) Unfortunately that still has a problem. After "rBoxes.erase(toErase)", "it" (which is the same as "toErase") is invalidated, so incrementing it (up in the for(...;...;...) part) has undefined behavior.

Re: Question about iterator management in sw/source/core/fields/cellfml.cxx

2012-02-02 Thread julien2412
Would this patch better ? (I kept the for loop) diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx index 33b953e..5c626dd 100644 --- a/sw/source/core/fields/cellfml.cxx +++ b/sw/source/core/fields/cellfml.cxx @@ -967,8 +967,8 @@ void SwTableFormula::GetBoxes( const S