Most important const & rvalue refs
In C++03 you can use the const&
trick (or "most important const") to extend the lifetime of a tempor开发者_JAVA技巧ary to the lifetime of the reference. My question is, in C++0x, does this behaviour extend to rvalue references? I.e auto&& x = someFunction();
According to [class.temporary]
, if that compiles then yes, the lifetime of the temporary is extended.
It compiles perfectly on VC10 SP1:
int && Get()
{
return 10;
}
const auto&& y=Get();
精彩评论