Igor R
But you just can't externally (with const_cast) modify a bunch of elements and then get the index to rebuild --the rebuilding machinery assumes that at most one element (the one you call modify() on) is out of place, so if other elements are shuffled as well you'll get some sort of undefined behavior: core dump, whatever.
What if I just copy all the elements to another container of the same type? Will the iteration from begin() from end() work correctly?
I think this might work (I suggest you try it.) Remember that the source container is in an invalid internal state (by altering the elements keys you've broken the container invariants), so after doing the copy you should destroy it immediately. Again, all of this is strictly undocumented stuff. No guarantee any of this will work in the event, say, of a library upgrade. Maybe some reformulation of your data design can allow you to do what you want while remaining in the shiny world of legal behavior. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo