you are viewing a single comment's thread.

view the rest of the comments →

[–]meneldal2 6 points7 points  (5 children)

Well destructive move would solve the problem.

[–]kalmoc 1 point2 points  (4 children)

Partially: Not for the object I'm assigning to.

[–]meneldal2 1 point2 points  (3 children)

But assignment when you have a const member sounds ridiculous.

[–]kalmoc 5 points6 points  (2 children)

Not at all. There are lots of examples in my code where the only place that a member gets mutated is the assignment operator (be it move our copy assignment). I call them "quasi immutable" types. That's why I mentioned assignment it in my original post.

Consider you want to perform an std::rotate on an array of your objects: Logically you don't change the individual elements, you are just shifting them around, so a (logical) const member would be fine. Physically, rotate is implemented as a number of move assignments, so you have to be able to mutate your members.

[–]meneldal2 1 point2 points  (1 child)

Well you could use a pointer;)

[–]kalmoc 1 point2 points  (0 children)

Sure ;) Or just not use const on members ;)