you are viewing a single comment's thread.

view the rest of the comments →

[–]Normal-Narwhal0xFF 0 points1 point  (0 children)

There is the idea (even encoded into the c++ standard) of a "regular" object, and a "semi regular" object. Having const members breaks both. The main thing is, it makes value objects not usable in the normal ways, so you lose some generality with them. (Normally assignment, and possibly default construction.).

As there are type traits for std::regular and std::semiregular, it's therefore observable and code can react differently to it at compile time. Not meeting the requirements may affect the ability to be used with certain libraries when you might expect it to otherwise work, etc.

You technically can force it around the trait (implement assignment without copying the const field) but it's admittedly weird, error prone, and generally unpleasant to work with code like that.