
7 Feb
2004
7 Feb
'04
10:16 a.m.
On Sat, 07 Feb 2004 01:00:49 +0100, David Abrahams wrote:
The example below shows a technique for perfect forwarding that seems to work with GCC 3.3.1. rvalues are always moved automatically, and lvalues are copied.
Nice. No, more than that, it's great! FWIW, I discovered that you can reduce the number of temporaries/objects further. In source() and csource(), change 'return X();' to 'X nrv; return nrv;'. Although I have to admit that I'm at a loss why the NRVO works while the RVO seems to be broken for your code (tested on Intel 7.1 and the GCC 3.3.2). Regards, Daniel