title: std::thread constructor argument error Invalid use of non-static member function
body: <p>Im writing multithreading application with thread manager contains all the threads and allows to operate them, but when im passing any arguments to constructor of std::thread, i get Error: Invalid using of non-static member function.</p>
  
  <p>First thing i did was trying to pass simple void function(void), so it would be easy to do and check if it's even working. I tried passing void  ClassName::function(void) and void this->function(void), but nothing works. I even tried passing reference to function in all the way i said before, but it made even more errors in the code.</p>
  
  <p>Also i don't want to change any function to static, so please try to help with this without turning functions to static.</p>
  
  <p>ThreadManager.cpp:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>class ThreadMaster
  {
      static thread *m_threads[MAX_THREADS_ALLOC];
  ...
  
  public:
  
      static void addThread(thread *thrd, int *ret);
  ...
  };
  
  thread *ThreadMaster::m_threads[MAX_THREADS_ALLOC] = {nullptr};
  mutex ThreadMaster::m_mtx;
  
  
  void ThreadMaster::addThread(thread *thrd, int *ret)
  {
          for(int i = 0; i &lt; MAX_THREADS_ALLOC; i++)
      {
          if(ThreadMaster::m_threads[i] != nullptr)
          {
              ThreadMaster::m_threads[i] = thrd;
  
              if(ret != nullptr)
                  (*ret) = i;
          }
      }
  }
  </code></pre>
  
  <p>SocketManager.cpp:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;thread&gt;
  
  using namespace std;
  
  class SocketApplication
  {
  ...
  protected:
   void check_thread(int thr, int *client );
   void thr_process(int *curcli);
  ...
  }
  
  void SocketApplication::check_thread(int thr, int *client)
  {
  std::this_thread::sleep_for(std::chrono::milliseconds(2500));
      if(threadTimer.GetTime() &gt; 2)
      {
          ThreadMaster::joinThread(thr);
          write(m_sockmgr-&gt;GetDevice(*client)-&gt;socket, "tot", sizeof(char) * 3);
          m_sockmgr-&gt;removeClient(*client);
          printf("[-] some client is not responding\n");
          ThreadMaster::addThread(new thread(this-&gt;thr_process, client), nullptr); //error
          ThreadMaster::addThread(nullptr, nullptr); //no errors
      }
  }
  </code></pre>
  
  <p>g++ compiler (g++ ./src/main.cpp -lpthread -std=c++14 -Wno-write-strings -fpermissive -o ./build/server)</p>
  
  <pre class="lang-sh prettyprint-override"><code>./src/net/socketManager.cpp:152:69: error: invalid use of non-static member function
           ThreadMaster::addThread(new thread(this-&gt;thr_process, client), nullptr);
  </code></pre>
  
  <p>I expect this code to compile without any errors, so it can successful work, but as you can see it gives compile error.</p>