Short intro to C++ for Rust developers: Ownership and Borrowing
Oh boy there are some serious errors here.<p>Returning a stack allocated value does not invoke the move constructor. It doesn't copy either. This is a separate optimization that existed even prior to C++11 called the "named return value optimization" or NRVO for short. And by "sufficient new compiler" you really should just say every compiler. No compiler I know of in existence used by actual people doesn't implement this.<p>Here's a demo: <a href="http://ideone.com/QRqj5P" rel="nofollow">http://ideone.com/QRqj5P</a><p>It's VERY important that this optimization isn't confused with move construction as the latter would actually be extremely less performant than what actually happens.