title: Error C2280 while creating a std::thread without initialization in C++
body: <p>I want to create a thread object in my class/struct but don't want to initialie immediately during declaration. Intead want to do it later. Hence, I did as in below code snippet, I'm getting this compilation error. How do I fix this ?</p>
  
  <blockquote>
    <p>error C2280: 'std::thread::thread(const std::thread &amp;)' : attempting
    to reference a deleted function</p>
  </blockquote>
  
  <p>I observed the line causing this error is :</p>
  
  <blockquote>
  <pre><code>  std::thread t2;
  </code></pre>
  </blockquote>
  
  <p>Does it mean that we can't just declare a std::thread without initializing ? This contradicts the answer in this thread <a href="https://stackoverflow.com/questions/18375998/is-it-possible-to-define-an-stdthread-and-initialize-it-later">Is it possible to define an std::thread and initialize it later?</a> </p>
  
  <pre><code>struct Abc
  {
      int a;
      std::thread t2;
      void mem1()
      {
          printf("mem1\n");
      }
  
      void mem2()
      {
          printf("mem2\n");
          std::thread t1(&amp;Abc::mem1, Abc());
          t2.swap(t1);
          printf("after spawning t1\n");
          t2.join();
      }
  };
  </code></pre>
  
  <p><strong>Error Details:</strong></p>
  
  <blockquote>
    <blockquote>
      <p>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xmemory0(611): error C2280: 'std::thread::thread(const std::thread &amp;)' : attempting to reference a deleted function 1><br>
      C:\Program Files (x86)\Microsoft Visual Studio
      12.0\VC\include\thread(70) : see declaration of 'std::thread::thread' 1>          This diagnostic occurred in the compiler generated
      function 'Abc::Abc(const Abc &amp;)</p>
    </blockquote>
  </blockquote>