I have a situation, where I would like to have a map that does not allow to add/remove keys after initialization, but the values are allowed to change (thus I cannot simply
Could you create a wrapper that contains the value that allows the value to be mutated when const
and put that in the map
instead? Something like:
template
class Mutable {
mutable T value;
public:
const Mutable& operator=(const T& v) const { value = v; return *this; }
T& get() const { return value; }
};
Then your map can be of type
const std::map>
Live demo.