title: boost::bind member function as argument inside its own member function
body: <p>I am following a tutorial (<a href="https://www.gamedev.net/blogs/entry/2249317-a-guide-to-getting-started-with-boostasio/" rel="nofollow noreferrer">https://www.gamedev.net/blogs/entry/2249317-a-guide-to-getting-started-with-boostasio/</a>) for boost asio.</p>
  <p>Now I want to convert some of the aspects of this tutorial to a class, to learn more about what actually goes on within each part of the code. So I am trying to boost bind this:</p>
  <pre><code>class LDserver
  {
  public:
      void workerThread(boost::shared_ptr&lt;boost::asio::io_service&gt; io_service)   
          {
              io_service-&gt;run();    
          } 
      void createThreads()
          {
              this-&gt;worker_threads.create_thread(boost::bind(&amp;LDserver::workerThread, this-&gt;io_service));
          }
      
          ~LDserver() = default;
          boost::thread_group worker_threads;
          boost::shared_ptr&lt;boost::asio::io_service&gt; io_service = boost::make_shared&lt;boost::asio::io_service&gt;();
          boost::shared_ptr&lt;boost::asio::io_service::work&gt; work = boost::make_shared&lt;boost::asio::io_service::work&gt;(*this-&gt;io_service);
          boost::asio::io_service::strand strand = boost::asio::io_service::strand(*this-&gt;io_service);
  };
  </code></pre>
  <p>Following the documentation, it states that this should be the correct syntax AS its own, so not as an argument. But instead I am greeted with an error message coming from the boost::bind library.</p>
  <pre><code>Severity    Code    Description Project File    Line    Suppression State
  Error   C2440   'return': cannot convert from 'R (__cdecl &amp;)' to 'R'    LockManager C:\Boost\boost_1_75_0\boost_1_75_0\boost\bind\bind.hpp  227 
  </code></pre>
  <p>It work fine if I follow the documentation and put it in the mainloop, it even takes the member variable fine as an argument:</p>
  <pre><code>LDserver s1;
  for (int i = 0; i &lt;= 2; i++)
      {
          s1.worker_threads.create_thread(boost::bind(&amp;workerThread, s1.io_service));
      }
  </code></pre>
  <p>And by commenting out I am 100% sure because it doesnt take my  way of syntaxing the worketThread() member function as the correct one, however after spending 2 days of trying and finding the answer, I hope someone here could enlighten me.</p>