* Gernot Frisch:
I know I can give a std::map a sorting function in the c'tor. However,
I would need to _change_ the sorting behaviour of an existing
instance. How would I do that?
The general solution to any computer science problem is called
"indirection".
Now you're perhaps thinking of indirection in the sorting function,
passing an abstract sorting function that you can redirect, but note
that std::map has no facility for re-ordering existing elements:
changing the ordering behavior on the fly would wreak total havoc.
So what you ask for is indirection for the held instance, something that
provides a std::map interface but on the inside switches which std::map,
and copies/moves the elements over when you change the ordering.
However, whether that's what you _need_...
Most probably what you need is to examine and change the design.
Cheers,
- Alf