title: Error C2280: 'std::thread::thread(const std::thread &)' : attempting to reference a deleted function
body: <p>I'm having a problem trying to create a VC++ Static Library that uses C++11 standard threads.</p>
  
  <p>I currently have two classes, and I am able to declare and later define a thread just fine on my starting class (which is declared last). At this stage, the code is just a socket listener which then creates an object of another class to handle each client accepted. Those child objects are supposed to create the threads I need for parallel data capture, encoding and transmission.</p>
  
  <p>The problem is: If I declare a std::thread on my other class, even if exactly like I did on my start class, no matter what, I'm getting this error on build <code>error C2280: 'std::thread::thread(const std::thread &amp;)' : attempting to reference a deleted function   [...]\vc\include\functional 1124    1</code></p>
  
  <p>The only way I was able to workaround this error is to simply not declare a <code>std::thread</code> object in the latter class, which isn't possible, according to what I want it to do...</p>
  
  <p>I'm using VS2013, and my sources are:</p>
  
  <p><strong>stdafx.h</strong></p>
  
  <pre><code>#pragma once
  #include "targetver.h"
  #define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
  #include &lt;Windows.h&gt;
  #include &lt;WinSock2.h&gt;
  #include &lt;WS2tcpip.h&gt;
  #include &lt;thread&gt;
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  </code></pre>
  
  <p><strong>StreamServer.h</strong></p>
  
  <pre><code>#pragma once
  #define DEFAULT_BUFLEN 65535
  #define DEFAULT_PORT "5649"
  
  class StreamServerClient
  {
  public:
      bool* terminate;
      //std::thread client;     //If I comment this line out, it builds just fine.
      void DoNothing();
      StreamServerClient(SOCKET clientSock, bool* ptTerm);
      StreamServerClient();
      ~StreamServerClient();
  };
  
  class StreamServer
  {
  public:
      bool terminate;
      std::thread Listener;
      std::vector&lt;StreamServerClient&gt; clients;
      void CreateClient(SOCKET, bool*);
      void Listen();
      StreamServer();
      ~StreamServer();
  };
  </code></pre>
  
  <p><strong>StreamServer.cpp</strong></p>
  
  <pre><code>#include "stdafx.h"
  #include "StreamServer.h"
  
  StreamServerClient::StreamServerClient(SOCKET clientSock, bool* ptTerm)
  {
      terminate = ptTerm;
      //client = std::thread(&amp;StreamServerClient::DoNothing, this);     //Same thing as the declaration
  }
  
  StreamServerClient::StreamServerClient()
  {
      *terminate = false;
      //client = std::thread(&amp;StreamServerClient::DoNothing, this);     //Same thing as the declaration
  }
  
  void StreamServerClient::DoNothing()
  {
  }
  
  StreamServerClient::~StreamServerClient()
  {
  }
  
  void StreamServer::Listen()
  {
      {...}
      do {
          clients.push_back(StreamServerClient::StreamServerClient(accept(listenSock, NULL, NULL), &amp;terminate));
          std::cout &lt;&lt; "accepted a client!" &lt;&lt; std::endl;
      } while (!terminate);
  }
  
  StreamServer::StreamServer()
  {
      terminate = false;
      Listener = std::thread(&amp;StreamServer::Listen, this);
      Listener.detach();
  }
  
  StreamServer::~StreamServer()
  {
  }
  </code></pre>