
--On Saturday, February 07, 2004 12:59 AM -0500 Brian McNamara <lorgon@cc.gatech.edu> wrote:
On Fri, Feb 06, 2004 at 07:00:49PM -0500, 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.
I had to Google for "perfect forwarding" to discover http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1377.htm (which I'd read before but forgotten about).
It is unclear to me if/how your code solves the "perfect forwarding" problem. Instead it appears to show a way to make a particular type "movable". Have I misunderstood? (How) does your generalize to a way to write forwarding functions?
It seems you have a clever way to effectively "detect rvalue-ness"; the copy-constructor and the "pseudo-copy-constructor" (the thing with the enable_if) only swallow lvalues, whereas rvalues find a more attractive construction path via "ref". Is that a correct summary?
[snip] Some additional background is available here: <http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm> - Mat