Hello Joaquin,

I just came up with a slightly different question in more or less same direction. Can I safely erase data from the index view in a range based for loop. The index container contains only ordered indices (no random access).

I saw a suggestion that an iterator is being invalidated and therefore pre-incrementing it for the next step is fine. But what happens if an element erased via its key itself in a range-based for-loop? Would the next increment work fine?


Many thanks,
Ovanes


On Sun, Sep 28, 2014 at 4:03 PM, Aaron Levy <aaron.levy@yandex.com> wrote:


28.09.2014, 19:06, "Joaquin M Lopez Munoz" <joaquin@tid.es>:
> Aaron Levy <aaron.levy <at> yandex.com> writes:
>>  If I erase elements in a multi_index_container, how are iterators
>>  invalidated?
>>  1. For other than random_access index, only iterators to the deleted
>>  element?
>>  2. For random_access index, potentially any iterator?
...
>
> For all indices, on every ocassion, only the iterators to the deleted
> element are invalidated.
>>  What are the data structures used internally for this container and its
>>  indexes.
>
> * random-access indices use this:
>
>     http://bannalia.blogspot.com/2008/08/stable-vectors.html
>

Aah! Random access and stable, I should have guessed stable_vectors.

And the pointers to the implementation are impressive.

Thanks.
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users