最重要的右值参考 [英] Most important const & rvalue refs

查看:65
本文介绍了最重要的右值参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C ++ 03中,您可以使用 const& 技巧(或最重要的const)将临时的生命周期延长到引用的生命周期。我的问题是,在C + + 0x,这种行为扩展到右值引用?即 auto&&& x = someFunction();

解决方案

根据 ] ,如果编译为yes,则临时的生命周期被延长。


In C++03 you can use the const& trick (or "most important const") to extend the lifetime of a temporary 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆