3 ms·
> If you return something that can be moved, it will be moved, always. How about the example I gave in my reply to your sibling? https://news.ycombinator.com/i
by frankzinger 10y ago
> If you return something that can be moved, it will be moved, always.
How about the example I gave in my reply to your sibling? https://news.ycombinator.com/item?id=12578621 https://news.ycombinator.com/item?id=12578621
- int_19h 10y agoGood point. Let me correct that: if you return something that doesn't have a name, or is a local variable in the function you're returning from, it will always be moved. Usually it amounts to the same thing, except when non-const lvalue or rvalue references are involved (but it's fairly rare to return via a non-const reference).
- jnordwick 10y agoSo when I said RVO, I mean't NRVO too (but not from an argument passed in).