3 ms·
Yes, the "fixed" (multimap) version looks to have the Halloween Problem [1]. As this illustrates, const correctness is no substitute for understanding of itera
by voidmain 8y ago
Yes, the "fixed" (multimap) version looks to have the Halloween Problem [1]. As this illustrates, const correctness is no substitute for understanding of iterator invalidation and data structure invariants in C++.
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).
[1] https://en.wikipedia.org/wiki/Halloween_Problem https://en.wikipedia.org/wiki/Halloween_Problem