I was tracking down a compilation error when I came to this case:
struct Y
{
int&& y;
Y(int&& y)
: y(y)
{
}
};
struct ZZ {};
struct Z
{
ZZ&& z;
Z(ZZ&& z)
: z(z)
{
}
};
These both fail stating:
exec.cpp: In constructor ‘Y::Y(int&&)’:
exec.cpp:57:10: error: invalid initialization of reference of type ‘int&&’ from expression of type ‘int’
exec.cpp: In constructor ‘Z::Z(ZZ&&)’:
exec.cpp:67:10: error: invalid initialization of reference of type ‘ZZ&&’ from expression of type ‘ZZ’
But I'm not exactly sure why. What is wrong here?
I'm using g++4.5.3 with -std=gnu++0x option, but it also occurs with -std=c++0x option.