title: c++ error C2893: Failed to specialize function template
body: <p>I'm trying to run this but I keep receiving an error.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;thread&gt;
  using namespace std;
  
  void primeNumbers( int num, int prime )
  {
      cout &lt;&lt; "The prime numbers equal to or below " &lt;&lt; num &lt;&lt; " are: " &lt;&lt; endl;
  
      for ( int i = 1; i &lt;= num; i++ )
      {
          prime = 0;
          for( int j = 2;j &lt;= i/2; j++ )
          {
              if( i % j ==0 )
              {
                  prime++;
                  break;
              }
          }
          if ( prime == 0 &amp;&amp; i != 1 )
          cout &lt;&lt; i &lt;&lt; endl;
      }
  }
  
  int main()
  {
      int num;
      int prime = 0;
  
  
      cout &lt;&lt; "Enter a positive integer: ";
      cin &gt;&gt; num;
  
      std::thread primeN( primeNumbers );
      primeN.join( );
  
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>I've copied everything from the output window. </p>
  
  <pre><code>1&gt;c:\program files (x86)\microsoft visual studio 14.0\vc\include\thr\xthread(238): error C2893: Failed to specialize function template 'unknown-type std::invoke(_Callable &amp;&amp;,_Types &amp;&amp;...)'
  1&gt;  c:\program files (x86)\microsoft visual studio 14.0\vc\include\thr\xthread(238): note: With the following template arguments:
  1&gt;  c:\program files (x86)\microsoft visual studio 14.0\vc\include\thr\xthread(238): note: '_Callable=void (__cdecl *)(int,int)'
  1&gt;  c:\program files (x86)\microsoft visual studio 14.0\vc\include\thr\xthread(238): note: '_Types={}'
  1&gt;  c:\program files (x86)\microsoft visual studio 14.0\vc\include\thr\xthread(247): note: see reference to function template instantiation 'void std::_LaunchPad&lt;_Target&gt;::_Execute&lt;0&gt;(std::tuple&lt;void (__cdecl *)(int,int)&gt; &amp;,std::integer_sequence&lt;_Ty,0&gt;)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Target=std::unique_ptr&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;,std::default_delete&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;&gt;&gt;,
  1&gt;              _Ty=size_t
  1&gt;          ]
  1&gt;  c:\program files (x86)\microsoft visual studio 14.0\vc\include\thr\xthread(247): note: see reference to function template instantiation 'void std::_LaunchPad&lt;_Target&gt;::_Execute&lt;0&gt;(std::tuple&lt;void (__cdecl *)(int,int)&gt; &amp;,std::integer_sequence&lt;_Ty,0&gt;)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Target=std::unique_ptr&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;,std::default_delete&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;&gt;&gt;,
  1&gt;              _Ty=size_t
  1&gt;          ]
  1&gt;  c:\program files (x86)\microsoft visual studio 14.0\vc\include\thr\xthread(242): note: while compiling class template member function 'void std::_LaunchPad&lt;_Target&gt;::_Run(std::_LaunchPad&lt;_Target&gt; *) noexcept'
  1&gt;          with
  1&gt;          [
  1&gt;              _Target=std::unique_ptr&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;,std::default_delete&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;&gt;&gt;
  1&gt;          ]
  1&gt;  c:\program files (x86)\microsoft visual studio 14.0\vc\include\thr\xthread(230): note: see reference to function template instantiation 'void std::_LaunchPad&lt;_Target&gt;::_Run(std::_LaunchPad&lt;_Target&gt; *) noexcept' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Target=std::unique_ptr&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;,std::default_delete&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;&gt;&gt;
  1&gt;          ]
  1&gt;  c:\program files (x86)\microsoft visual studio 14.0\vc\include\thr\xthread(256): note: see reference to class template instantiation 'std::_LaunchPad&lt;_Target&gt;' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Target=std::unique_ptr&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;,std::default_delete&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;&gt;&gt;
  1&gt;          ]
  1&gt;  c:\program files (x86)\microsoft visual studio 14.0\vc\include\thread(52): note: see reference to function template instantiation 'void std::_Launch&lt;std::unique_ptr&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;,std::default_delete&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;&gt;&gt;&gt;(_Thrd_t *,_Target &amp;&amp;)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Target=std::unique_ptr&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;,std::default_delete&lt;std::tuple&lt;void (__cdecl *)(int,int)&gt;&gt;&gt;
  1&gt;          ]
  1&gt;  c:\users\andre\documents\school\csci\prime\prime\testprime.cpp(34): note: see reference to function template instantiation 'std::thread::thread&lt;void(__cdecl &amp;)(int,int),,void&gt;(_Fn)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Fn=void (__cdecl &amp;)(int,int)
  1&gt;          ]
  </code></pre>
  
  <p>I don't know much about multithreading as I just started learning about it yesterday. So if I did something completely wrong please let me know.</p>