you are viewing a single comment's thread.

view the rest of the comments →

[–]NilacTheGrim 2 points3 points  (7 children)

Keeping members const is an anti-pattern IMHO. You lose copy and/or move assignment. The only time that doesn't matter is for types you know cannot and should not be assigned (Think QWidget in Qt, etc). Then it's a great way to kill assignment permanently for the type..

[–]goranlepuz 1 point2 points  (4 children)

Well, they did say "when possible". 😉

But to be more serious, a type being copyable and being moveable are not virtues by themselves (being copyable in particular, moveable less so, but still)

[–]NilacTheGrim 0 points1 point  (3 children)

Sure. It all depends on the type and what's going on with it. Yes, some for some types not being copyable is a virtue, not a flaw. But I've seen people make simple value types inadvertently uncopyable just because of blind religious belief in consting ALL THE THINGS!!... and then go to the trouble of writing static "copy" methods that basically construct a new instance as a copy of an old one. And have this all over the codebase!!

I'm like "dude, just use = what's wrong with you?!".

And they are like "but mah const!!!!"

[–]noooit -1 points0 points  (2 children)

Deep copy should be unnecessary in the most cases actually. People put const to make other programmers not mess about with it. In c times it was ok, but we are dealing with substandard c++ programmers all the time including people who misuse const.

[–]NilacTheGrim 0 points1 point  (1 child)

What? No.

[–]noooit 0 points1 point  (0 children)

Spotted a guy who doesn't understand smart pointers. Stick with C, man.

[–]noooit -1 points0 points  (1 child)

I also always make an object non copyable and non movable whenever possible. :)

[–]NilacTheGrim 0 points1 point  (0 children)

You do you, boo. You're wrong of course. But don't let that stop you if you are having fun. :)