by notacoward · 6y ago · 0 comments
The straightforward naive code is also the best code, here. So it's not an example of what you describe. In fact at least on stl containers, and your own classes with such members, move semantics "just works". Rebuild the same c++98 code with c++11 and it just skips needless copies as part of the language, not implementation.
And it's not about second-guessing. The confusion here is not about the compiler implementation. It's about the language.
Many times straightforward code is the best code. Value returns in C++ are already optimised, no need to add anything fancy.