For some reason, I repeat the elements of the class in std::set and want to change the keys a bit, knowing that the order will not change.
The iterators on std::set are const_iterators , because if the key is changed, it can lead to the wrong order and, therefore, to damage the set. However, I know for sure that my operations will not change the order of my elements in the set.
At the moment, here is my solution:
class Foo { public: Foo(int a, int b): a_(a),b_(b) {} ~Foo(){} bool operator < (const Foo& o) const { return this.a_ < o.a_ ; } void incrementB() const { ++b_; }
How would you modify it (I know that I could use std::map , but I'm curious if you can suggest other options) to remove mutable and const?
thanks
source share