1

which is right?

std::string get_string()
{
    std::string result;
    // ... more operations.
    return std::move(result);
}

Or

   std::string&&  get_string()
   {

      std::string result;
      // ... more operations
      return std::move(result);
   }

?

If I use std::move, what should be type of function?

Khurshid
  • 2,654
  • 2
  • 21
  • 29
  • 4
    They're both wrong, the second more-so than the first. Return by value, and don't call `move` on the return expression. – Benjamin Lindley Jul 12 '13 at 05:05
  • Ok. Second version is wrong. but in the first version: here is RVO always worked, because in my case between result and return more 100 lines. ? – Khurshid Jul 12 '13 at 06:03

0 Answers0