Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-02-06 19:00:49

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.

Except for one rather important case, it works with Comeau (errors
only in strict mode). The important case that causes the error
clearly violates 12.2/1 of the standard, but see below.

VC++ and CodeWarrior have different kinds of problems with it from
Comeau/strict. I am hoping that they are wrong, but I am not enough
of a core language jock to make a determination on which of these
compilers is correct (if any).

12.2/1 says that the act of binding an rvalue to a (const) reference
creates a temporary (which may be elided). The creation of the
temporary requires the existence of a copy ctor with a const&
argument. As far as I know, that rule serves no useful purpose, but I
may have missed something. *If* my example actually works other than
this case, I'd like to try to get the rule lifted, and soon! This is
by no means the cleanest route to move semantics, but it's probably
the smallest "language extension" we'd ever need to get it, and might
even be possible before C++0x


Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at