3 ms·
In C return value optimization is not a problem to begin with. There are many more side effects in C++ that could inhibit (have inhibited) return value optimiza
by eska 7y ago
In C return value optimization is not a problem to begin with. There are many more side effects in C++ that could inhibit (have inhibited) return value optimization, by e.g. overloading operators. The standard actually changes the behavior of side effects to allow for return value optimization, i.e. code acts differently depending on whether it's return value optimized or not. I don't feel like any of this is consistent or simpler than C.
- jcelerier 7y ago> In C return value optimization is not a problem to begin with of course it is - https://gcc.godbolt.org/z/welWvd https://gcc.godbolt.org/z/welWvd C gives you O(N) memcpy, C++ gives you O(1) do-stuff-in-place for the exact same code > overloading operators has exactly zero things to do with RVO > I don't feel like any of this is consistent or simpler than C. it produces vastly simpler user code. In years and years of programming in C++ never has "code acts differently depending on whether it's return value optimized or not" been an issue for anyone I know.