Assume we have a simple structure such as the following
struct T{
int x;
int y;
};
T t1, t2;
Also assume that I have a map<T, int> myMap and that two structures of type T are compared using their x values only. I.e. t1 < t2 iff t1.x < t2.x. I am trying to update some of the y values of the keys over myMap. This should not affect how the map is seeing the keys. Is there any way other than removing the old element and inserting a new one?
If you are sure that
ydoes not participate in the “logical state” of your class and is merely an implementation detail, then you could declare itmutable:Now you ought to be able to change
y: