title: Returning std::thread
body: <p>I'm wondering why returning <code>std::thread</code> from a function is OK, when <code>std::thread</code> is only movable. Is it because of return value optimization or is it valid in general?</p>
  
  <p>Consider the following code:</p>
  
  <pre><code>std::thread f()
  {
      void some_function();
      return std::thread(some_function);
  }
  std::thread g()
  {
      void some_other_function(int);
      std::thread t(some_other_function, 42);
      return t;
  }
  
  
  int main() {
  
      std::thread t0 = f();
      std::thread t1 = g();
  
      return 0;
  }
  </code></pre>
  
  <p>I'm curious if <code>std::thread t0 = f();</code> and <code>std::thread t1 = g();</code> rely on (N)RVO or if this is valid in general.</p>
  
  <p>Assuming no return value optimization occurs, shouldn't a copy occur at <code>f()</code> (and at <code>g()</code>)?</p>