[Libreoffice] Question about iterator management in sw/source/core/fields/cellfml.cxx

Marcel Metz mmetz at adrian-broher.net
Thu Feb 2 01:13:33 PST 2012


Hello Julien

On 02/01/2012 11:40 PM, julien2412 wrote:
> Here are the lines :
>      961             // dann mal die Tabellenkoepfe raus:
>      962             for( SwSelBoxes::iterator it = rBoxes.begin(); it !=
> rBoxes.end(); ++it )
>      963             {
>      964                 pLine = it->second->GetUpper();
>      965                 while( pLine->GetUpper() )
>      966                     pLine = pLine->GetUpper()->GetUpper();
>      967
>      968                 if( pTbl->IsHeadline( *pLine ) )
>      969                 {
>      970                     rBoxes.erase( it++ );
>      971                     --it;
>      972                 }
>      973             }

If the box that is represented by `it` should be deleted you could use.

970                      it = rBoxes.erase( it );

`it` would now point to the element after the erased one. This is true
for every sequence in the standard template library (see [1] under
Expression semantics -> Erase post condition).

[1] http://www.sgi.com/tech/stl/Sequence.html

regards Marcel


More information about the LibreOffice mailing list