clang++ 优化返回代码(二)

2015-11-21 01:05:08 · 作者: · 浏览: 23
me situation as if you returned by lvalue-reference and removed the move from the return line: Either way you've got a dangling reference to a local variable inside the function and which has been destructed. – Howard Hinnant Feb 27 '13 at 16:11
1 upvote
? flag
Just a nit: Since you named the variable (tmp) in the Best practice section, it is the NRVO that kicks in, not the RVO. These are two different optimizations. Other than that, great answer! – Daniel Frey Feb

?