Boost logo

Boost :

From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2004-02-07 04:49:55

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.

Like Brian I don't understand how this solves perfect forwarding.

> 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.
> <snip>
> 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

Isn't this the same rule that crippled Andrei's Mojo as well? The
technique is basically the same, except he had something like:

    X(X&) // copy
    X(constant_ref<X>) // copy
    X(rvalue_ref<X>) // move

IIRC this also worked on everything, except when binding rvalues to

Daniel Wallin

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