I have a multiset with a custom predicate function, e.g multiset<MyClass *,MyCompFunc> where MyCompFunc looks at an attribute on the MyClass objects. During the progress of the application, the objects might change in a way that should cause them to be reordered.
What’s the correct way to get the multiset to become reordered when this happens? Manually sort it, or remove the modified object, update it, and re-insert it?
The usual is to remove, update, and re-insert. Virtually anything else at least temporarily violates the primary invariant of a set/multiset, which clearly isn’t a good thing.