Visual Studio 2010 中的右值引用

发布于 2024-11-30 13:11:38 字数 141 浏览 5 评论 0原文

Visual Studio 2010 中实现的右值引用与 C++11 中指定的右值引用之间有什么区别?在 Visual Studio 2010 中使用重值引用时是否有任何需要注意的特定陷阱,如果由符合 C++11 的编译器编译,这些陷阱可能会导致源无效或工作方式不同?

What are the differences between rvalue references as implemented in Visual Studio 2010 and as specified in the C++11? Are there any particular pitfalls to watch out for when using revalue references in Visual Studio 2010 that could make source invalid or working differently if compiled by C++11 conforming compiler?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

温柔戏命师 2024-12-07 13:11:38

根据 这个表,VS2010支持右值引用2.0版本(当前版本是2.1 IIRC)。

2.0 和 2.1 之间的重要区别在于后者允许隐式转换:

std::string&& x = "hello";   // legal in 2.1, illegal in 2.0

另请注意,VS2010 尚不支持 *this 右值的重载。

void Foo::foo() && { ... }   // not yet supported in VS2010

According to this table, VS2010 supports rvalue references version 2.0 (the current version is 2.1 IIRC).

The important difference between 2.0 and 2.1 is that the latter allows implicit conversions:

std::string&& x = "hello";   // legal in 2.1, illegal in 2.0

Also note that VS2010 does not yet support overloading on the rvalueness of *this.

void Foo::foo() && { ... }   // not yet supported in VS2010
晨曦慕雪 2024-12-07 13:11:38

查看 Stephan T. Lavavej 视频讲座的第 9 期,网址为 频道 942:30 分钟开始。他解释了 Visual Studio 中右值引用和移动语义的时间线和演变。

这是:C9 讲座:Stephan T. Lavavej - 标准模板库 (STL),9 of n

Check the instalment number 9 of Stephan T. Lavavej's video lectures at Channel 9 from 42:30 min onwards. He explains timeline and evolution of the rvalue references and move semantic in Visual Studio.

Here it is: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 9 of n

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文