title: vector.push_back() produces deleted function error when pushing a thread (during compilation)
body: <p>I do not understand why, but <code>vector&lt;thread&gt;.push_back()</code> produces an error.
  I have tried replacing the error-producing line with <code>.emplace_back()</code>, but I still get this error.</p>
  <p>Overall, my code is attempting to display what numbers are prime based on the input. I know for sure, and have already tested, that the splitString() and isPrime() functions work perfectly, just that my implementation into main() is improper and produces an error when compiling.</p>
  <p>Here is my code;</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;cstdlib&gt;
  #include &lt;thread&gt;
  #include &lt;vector&gt;
  using namespace std;
  bool isPrime(int number) {
      int scan = number - 1;
      while(scan &gt; 1){
          if(number % scan == 0){
              return false;
          }
          scan = scan - 1;
      }
      return true;
  }
  vector&lt;string&gt; splitString(string String, string seperator){
      vector&lt;string&gt; result;
      size_t pos = 0;
      string token;
      while((pos = String.find(seperator)) != string::npos){
          token = String.substr(0, pos);
          result.push_back(token);
          String.erase(0, pos + seperator.length());
      }
      result.push_back(String);
      return result;
  }
  string getPrimes(string param){
      vector&lt;string&gt; splitstring = splitString(param, &quot;,&quot;);
      string outstring = &quot;&quot;;
      int currentScan = stoi(splitstring[0]);
      int higher = stoi(splitstring[1]);
      while(currentScan &lt;= higher){
          bool res = isPrime(currentScan);
          if(res == true){
              outstring = outstring + to_string(currentScan) + &quot;,&quot;;
              cout &lt;&lt; to_string(currentScan) + &quot;,&quot;;
          }
          currentScan = currentScan + 1;
      }
      return outstring;
  }
  int main(int argc, char ** argv) {
      int initVal = atoi(argv[0]);
      int threadLength = atoi(argv[1]);
      int threadCount = atoi(argv[2]);
      vector&lt;thread&gt; threads;
      int threadPart = 1;
      while(threadPart &lt;= threadCount){
          int threadStart = (threadPart * threadLength) + initVal;
          int threadEnd = threadStart + threadLength;
          string inp = to_string(threadStart) + &quot;,&quot; + to_string(threadEnd);
          thread th(getPrimes, inp);
          threads.push_back(th);
          threadPart = threadPart + 1;
      }
      for(int i = 0; i &lt; threads.size(); i++){
          threads[i].join();
      }
  }
  </code></pre>
  <p>Here is the produced error;</p>
  <pre><code>In file included from C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32/bits/c++allocator.h:33,
                   from C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/allocator.h:46,
                   from C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/string:41,
                   from C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/locale_classes.h:40,
                   from C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/ios_base.h:41,
                   from C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/ios:42,
                   from C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/ostream:38,
                   from C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/iostream:39,
                   from primes.cpp:1:
  C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator&lt;_Tp&gt;::construct(_Up*, _Args&amp;&amp; ...) [with _Up = std::thread; _Args = {std::thread&amp;}; _Tp = std::thread]':
  C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/alloc_traits.h:475:4:   required from 'static void std::allocator_traits&lt;std::allocator&lt;_CharT&gt; &gt;::construct(std::allocator_traits&lt;std::allocator&lt;_CharT&gt; &gt;::allocator_type&amp;, _Up*, _Args&amp;&amp; ...) [with _Up = std::thread; _Args = {std::thread&amp;}; _Tp = std::thread; std::allocator_traits&lt;std::allocator&lt;_CharT&gt; &gt;::allocator_type = std::allocator&lt;std::thread&gt;]'
  C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/vector.tcc:103:30:   required from 'void std::vector&lt;_Tp, _Alloc&gt;::emplace_back(_Args&amp;&amp; ...) [with _Args = {std::thread&amp;}; _Tp = std::thread; _Alloc = std::allocator&lt;std::thread&gt;]'
  primes.cpp:55:32:   required from here
  C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/ext/new_allocator.h:136:4: error: use of deleted function 'std::thread::thread(std::thread&amp;)'
    { ::new((void *)__p) _Up(std::forward&lt;_Args&gt;(__args)...); }
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from primes.cpp:4:
  C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:109:5: note: declared here
       thread(thread&amp;) = delete;
       ^~~~~~
  
  </code></pre>
  <p>I am new to C++ and C in general. Why does this error happen? How can I fix it?</p>