[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#478734: g++-4.2: refuses to compile valid C++ syntax



Daniel Jacobowitz wrote:
On Wed, Apr 30, 2008 at 05:51:32PM -0500, Jason Kraftcheck wrote:
Why can't I take a reference to an rvalue?

Because you can't modify rvalues.  This is the definition of the C++
language.  The next major revision of C++ will have T &&rref, the two
ampersands declaring an rvalue reference instead of the normal lvalue
kind.

Are you certain that the temporary created by invoking the copy constructor is an rvalue? If so, then why does the following syntax work?

std::vector<int> v;
std::vector<int> w( std:vector<int>(v) );

The copy constructor also takes a reference. The only difference between constructing 'w' and calling 'swap' on it is that the former takes a const reference.

thanks,

- jason






Reply to: