Re: [Boost-users] [multi_index] erasing elements
Joaquín Mª López Muñoz wrote:
The two snippets of code you show are entirely equivalent, in the sense that Present inherits the functionality of its first index, YIndex. In particular YIndex::iterator is the *same type* as Present::iterator, so I'm puzzled by the fact that you're observing different behaviors --from the code you're showing, using one or the other variation cannot possibly make any difference whatsoever. Could you please check your code for some other differences you might have not noticed when doing the switch from one version to the other?
Thanks for this information. The two code snippets were not equivalent because I was only using the iterator returned from the multi_index container's erase method in the one using YIndex::iterators. I have found that this iterator doesn't point to an element in the container. Instead its pointing to some memory that is zeroed. Prior to erasing the element I inserted some test code that looks though the entire container and doesn't find such an element. Given my constructor, this only makes sense. Do you have an explanation?
----- Mensaje original -----
De: Jeff Holle
The two code snippets were not equivalent because I was only using the iterator returned from the multi_index container's erase method in the one using YIndex::iterators. I have found that this iterator doesn't point to an element in the container. Instead its pointing to some memory that is zeroed. Prior to erasing the element I inserted some test code that looks though the entire container and doesn't find such an element. Given my constructor, this only makes sense.
Do you have an explanation?
Banning a bug in B.MI, the only plausible explanation is that this weird-behaving iterator is index.end(), which is not dereferenceable. This is the expected return value of erase() when the element erased is the last one in the index. Can you verify this hypothesis? Thank you! Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (2)
-
"JOAQUIN LOPEZ MU?Z"
-
Jeff Holle