EDN Admin
Well-known member
http://scottmeyers.blogspot.com/" target="_blank Scott Meyers presents "Universal References in C++11". This was filmed at http://cppandbeyond.com/" target="_blank C++ and Beyond 2012 . This is the full session in all of its splendor. Huge thanks to Scott for allowing C9 to provide this excellent C++11 content to the world. From Scotts recently published article in the http://accu.org/var/uploads/journals/Overload111.pdf" target="_blank October 2012 edition of ACCUs Overload : Given that rvalue references are declared using "&&", it seems reasonable to assume that the presence of "&&" in a type declaration indicates an rvalue reference. That is not the case: <pre class="brush: cpp Widget&& var1 = someWidget; // here, "&&" means rvalue reference
auto&& var2 = var1; // here, "&&" does not mean rvalue reference
template<typename T>
void f(std::vector<T>&& param); // here, "&&" means rvalue reference
template<typename T>
void f(T&& param); // here, "&&" does not mean rvalue reference
[/code] In this article, I describe the two meanings of "&&" in type declarations, explain how to tell them apart, and introduce new terminology that makes it possible to unambiguously communicate which meaning of "&&" is intended. Distinguishing the different meanings is important, because if you think "rvalue reference" whenever you see "&&" in a type declaration, youll misread a lot of C++11 code. Tune in. Scotts an incredible presenter and its well worth your time to both read his article and watch his presentation on the subject. Great stuff! <img src="http://m.webtrends.com/dcs1wotjh10000w0irc493s0e_6x1g/njs.gif?dcssip=channel9.msdn.com&dcsuri=http://channel9.msdn.com/Feeds/RSS&WT.dl=0&WT.entryid=Entry:RSSView:05e40edd24ba443c85f3a0b3015ffba5
View the full article
auto&& var2 = var1; // here, "&&" does not mean rvalue reference
template<typename T>
void f(std::vector<T>&& param); // here, "&&" means rvalue reference
template<typename T>
void f(T&& param); // here, "&&" does not mean rvalue reference
[/code] In this article, I describe the two meanings of "&&" in type declarations, explain how to tell them apart, and introduce new terminology that makes it possible to unambiguously communicate which meaning of "&&" is intended. Distinguishing the different meanings is important, because if you think "rvalue reference" whenever you see "&&" in a type declaration, youll misread a lot of C++11 code. Tune in. Scotts an incredible presenter and its well worth your time to both read his article and watch his presentation on the subject. Great stuff! <img src="http://m.webtrends.com/dcs1wotjh10000w0irc493s0e_6x1g/njs.gif?dcssip=channel9.msdn.com&dcsuri=http://channel9.msdn.com/Feeds/RSS&WT.dl=0&WT.entryid=Entry:RSSView:05e40edd24ba443c85f3a0b3015ffba5
View the full article