开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜