0

Possible Duplicate:
What does T&& mean in C++11?

The following code is NOT correct:

widget&& f() {
   widget w;
   ...
   return w;
}

Question> What does && mean? Can you give me a valid example that illustrates the usage of &&?

Note: I have searched c++ return by reference reference or c++ && without getting any useful information.

Community
  • 1
  • 1
q0987
  • 34,938
  • 69
  • 242
  • 387
  • 1
    It's an [rvalue reference](http://thbecker.net/articles/rvalue_references/section_01.html) – Seth Carnegie Feb 09 '12 at 21:33
  • It's new in C++11, and it's discussed in the link R. Martinho Fernandes cited: http://stackoverflow.com/questions/5481539/what-does-t-mean-in-c11 – paulsm4 Feb 09 '12 at 21:36
  • While you can move-construct a return value from a returned local variable implicitly, you can *not* return an actual rvalue reference implicitly, and you would have to spell out `return std::move(w)`. However, this is a dangling reference, and hence pretty useless. – Kerrek SB Feb 09 '12 at 21:37

0 Answers0