The worst bugs (C++)
medium.com
medium.com
"Take care when changing that over which you iterate"
That is something notably different than claiming that these are the 'Worst bugs' you could find...
The erase() method invalidates iterators to the erased element, but returns an iterator to the next one. If you resume iterating with that, there is the possibility of finding the updated Employee again. Extract() also invalidates iterators, but does not return one. If, as in the example, you use the iterator returned by insert() to resume iteration, you may skip over some eligible employees. If you use iterator++ in the extract() call (if that's not undefined behavior), you will presumably be in the same situation as using the iterator returned by erase().
As another example, the original code could have been writted with a multiset< unique_ptr< Employee > > and a suitably modified comparator and not required any const casting to have the same undefined behavior as the original (you can access a mutable object through a const unique_ptr).
And on a similar note, OP is talking about changing data types, PLAN THIS OUT BEFORE DOING YOUR REGRESSION ALGORITHM.
Sorry for the caps, but hope someone can save a week or 2 of effort.
But I agree in general terms: changing data types should not be done lightly :-)