3 ms·
Your proposed example code does exactly what GP said, pass as a reference (in your case, an rvalue reference).
by AzN1337c0d3r 6y ago
Your proposed example code does exactly what GP said, pass as a reference (in your case, an rvalue reference).
- CyberRabbi 6y agoNot quite, I suggested changing the signature of “consume” to accept a reference. His example doesn’t do anything to invoke copy elision, since his named rvalue reference will be function cast to a normal reference and then copy-constructed into the stack value passed to “consume”.
- AzN1337c0d3r 6y agohttps://gcc.godbolt.org/z/qd5qnhPT6 https://gcc.godbolt.org/z/qd5qnhPT6 How does any copy-construction happen here?
- deleted 6y ago[deleted]