r值引用和l值引用之间有什么区别? (CodeGen) [英] What is the difference between r-value references and l-value references? (CodeGen)

查看:126
本文介绍了r值引用和l值引用之间有什么区别? (CodeGen)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从低级角度看,r值引用看起来像什么。我只是不能包围我的头!我可以从r值引用和l值引用看到生成的代码(等效的C或x86 / x64)的示例吗?

What does an r-value reference look like from a lower-level perspective. I just can't seem to wrap my head around it! Can I see an example of generated code (either equivalent C or x86/x64) from a r-value reference vs. a l-value reference?

例如,这个结构会是什么样子?现在假设没有复制偏差。

For example, what would this construct look like? Let's assume no copy elision for now.

vector<SomethingHUUGE> myFunc();
void foo(vector<SomethingHUUGE>&&);

int main() { foo(myFunc()); return 0; }


推荐答案

。两者之间唯一的语义差异是,你知道RValue引用即将被销毁,而一个左值引用不会。

There is no difference for the purposes of code generation. The only semantic difference between the two is that you know an RValue reference is about to be destroyed, while an lvalue reference will not.

这篇关于r值引用和l值引用之间有什么区别? (CodeGen)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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