3 ms·
> C++, const is part of the type. Clearly wrong. It’s pretty hard to express that an object must be invariant without a thing like that. You can’t do so with
by gumby 6y ago
> C++, const is part of the type. Clearly wrong.
It’s pretty hard to express that an object must be invariant without a thing like that. You can’t do so with the storage itself as the object may be passed to a function.
- Ericson2314 6y agoBut if something is passed by value, the caller should never care whether the callee mutates its (shallow) copy. It's purely an unobervable implementation detail of the function.
- gumby 6y agoCall by value is not that common any more in C++ except with scalars. Although there are legit cases for what you describe, it’s a pretty uncommon case.
- Ericson2314 6y agoNot passing things around by value doesn't solve the problem. For example, template machinery has worry about absurd things like `const .. &&`.