Download this episode
Scott Meyers presents "Universal References in C++11". This was filmed at 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 Scott's recently published article in the October 2012 edition of ACCU's 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:
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
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, you'll misread a lot of C++11 code.
Tune in. Scott's an incredible presenter and it's well worth your time to both read his article and watch his presentation on the subject. Great stuff!
Available formats for this video:
Actual format may change based on video formats available and browser capability.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.