4 ms·
This is totally wrong; the examples rely on compilers doing copy elision together with return value optimization so that the copy becomes unnecessary (even if a
by okmjuhb 16y ago
This is totally wrong; the examples rely on compilers doing copy elision together with return value optimization so that the copy becomes unnecessary (even if a copy is expensive, it's fine - it never needs to happen). They do not use copy on write containers (indeed, they return modified versions of input variables).
- tbrownaw 16y ago...yeah, I suppose he does limit the examples to just nested function calls (and assumes everything ends up in the same object file).
- jey 16y agoNo, I'm pretty sure RVO is a feature of the calling convention, so it works across TUs (object files).
- tbrownaw 16y ago..wha? OK, re-reading this it looks like maybe he is talking strictly about return-value optimization. For some odd reason I thought he was claiming significantly more than that (such as not making copies of your pass-by-value parameters).