title: Passing parameter to Boost thread function
body: <p>I want to call this parametrized function in a new thread using boost library.</p>
  
  <pre><code>/**
   * Temporary function to test boost threads
   */
  void workerFunc(const char* msg, unsigned delaySecs)
  {
      boost::posix_time::seconds workTime(delaySecs);
  
      std::cout &lt;&lt; "Worker: running - " &lt;&lt; msg &lt;&lt; std::endl;
  
      // Pretend to do something useful...
      boost::this_thread::sleep(workTime);
  
      std::cout &lt;&lt; "Worker: finished - " &lt;&lt; msg &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>I was able to call non-parametrized function using following code call </p>
  
  <blockquote>
    <p>boost::asio::detail::thread workerThread(workerFunc);</p>
  </blockquote>
  
  <p>When I try to use following code for parametrized function:</p>
  
  <pre><code>int main()
  {
          std::cout &lt;&lt; "main: startup" &lt;&lt; std::endl;
          const char* name = "Hello world";
          boost::asio::detail::thread workerThread(workerFunc, name, 5);
          std::cout &lt;&lt; "main: waiting for thread" &lt;&lt; std::endl;
          workerThread.join();
          std::cout &lt;&lt; "main: done" &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>I get following error,</p>
  
  <pre><code>/home/hassan/ClionProjects/sme/Driver.cpp:106:41: error: no matching constructor for initialization of 'boost::asio::detail::thread' (aka 'boost::asio::detail::posix_thread')
          boost::asio::detail::thread workerThread(workerFunc, name, 5);
                                      ^            ~~~~~~~~~~~~~~~~~~~
  /usr/include/boost/asio/detail/posix_thread.hpp:42:3: note: candidate constructor template not viable: requires at most 2 arguments, but 3 were provided
  posix_thread(Function f, unsigned int = 0)
  ^
  /usr/include/boost/asio/detail/posix_thread.hpp:36:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 3 were provided
  class posix_thread
        ^
  </code></pre>