Hey Noel,

>>
>> It can't. Line 183 is supposed to be:
>>
>> aList.erase(it++);
>>
>
> No, it should be
>    it = aList.erase(it);
>
> Once you have called erase(), the iterator becomes invalid, so it must
> be replaced by the iterator returned by erase(), which returns the
> next valid position,

In a set my version is totally correct. it++ returns the old iterator
and then increments it, so we increment before we erase the element
and in sets only iterators to the erased element are invalidated.

For lists and sets the code I have shown is a common idiom to delete an element.

Regards,
Markus
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to