C++ use of std::move for return of rvalue function parameter?
Summary The code snippet demonstrates a common misconception about C++ return value optimization (RVO) and copy elision. The function T foo(T&& t) { return std::move(t); } explicitly moves a function parameter. Since t is an rvalue reference parameter, it is constructed in the caller’s stack frame, making it ineligible for RVO. While preventing compiler optimizations … Read more