Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rvalue references in Visual Studio 2010

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?

like image 915
wilx Avatar asked Aug 21 '11 12:08

wilx


2 Answers

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
like image 198
fredoverflow Avatar answered Oct 04 '22 09:10

fredoverflow


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

like image 45
mloskot Avatar answered Oct 04 '22 08:10

mloskot