Question

Is the following code legal?

std::string&& x = "hello world";

g++ 4.5.0 compiles this code without any problems.

Was it helpful?

Solution

This is discussed on usenet currently. See Rvalue reference example in 8.5/3 correct or wrong?.

It's not legal.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top