Re:Syntax changes from C++11 to C++20
by Ericson2314 on Tuesday August 04, 2020 @06:47PM
(#24055332)
But 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.
Call 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.
Re:Syntax changes from C++11 to C++20
by Ericson2314 on Wednesday August 05, 2020 @04:51PM
(#24065457)
Not passing things around by value doesn't solve the problem. For example, template machinery has worry about absurd things like `const .. &&`.
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.