title: boost::asio::async_read bind compilation error
body: <p>I can't figure out why I get this error :</p>
  
  <pre><code>/usr/local/include/boost/asio/impl/read.hpp: In member function ‘void boost::asio::detail::read_op&lt;AsyncReadStream, boost::asio::mutable_buffers_1, CompletionCondition, ReadHandler&gt;::operator()(const boost::system::error_code&amp;, size_t, int) [with AsyncReadStream = boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::stream_socket_service&lt;boost::asio::ip::tcp&gt; &gt;, CompletionCondition = boost::asio::detail::transfer_at_least_t, ReadHandler = boost::function&lt;void ()(long unsigned int)&gt;]’:
  /usr/local/include/boost/asio/impl/read.hpp:263:   instantiated from ‘void boost::asio::async_read(AsyncReadStream&amp;, const MutableBufferSequence&amp;, CompletionCondition, ReadHandler) [with AsyncReadStream = boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::stream_socket_service&lt;boost::asio::ip::tcp&gt; &gt;, MutableBufferSequence = boost::asio::mutable_buffers_1, CompletionCondition = boost::asio::detail::transfer_at_least_t, ReadHandler = boost::function&lt;void ()(long unsigned int)&gt;]’
  src/communicator/protocol/Command.cc:34:   instantiated from here
  /usr/local/include/boost/asio/impl/read.hpp:215: error: no match for call to ‘(boost::function&lt;void ()(long unsigned int)&gt;) (const boost::system::error_code&amp;, const long unsigned int&amp;)’
  /usr/local/include/boost/function/function_template.hpp:1007: note: candidates are: typename boost::function1&lt;R, T1&gt;::result_type boost::function1&lt;R, T1&gt;::operator()(T0) const [with R = void, T0 = long unsigned int]
  make: *** [src/communicator/protocol/Command.o] Error 1
  </code></pre>
  
  <p>Here my class : 
  Command.hh</p>
  
  <pre><code>namespace communicator {                                              
    namespace protocol {                                                
      namespace in {                                                    
        class Command : public boost::enable_shared_from_this&lt;Command&gt; {
        public:                                                         
          ~Command();                                                   
  
          typedef boost::shared_ptr&lt;Command&gt;      pointer;              
  
          void got_newline();                                           
  
        protected:                                                      
          Command(tcp::socket&amp; socket, structure::Client&amp; client) :     
            m_socket(socket), m_client(client)  {};
  
          void endParsing();
  
          tcp::socket&amp;            m_socket;                             
  
          structure::Client&amp;      m_client;                             
          char                    m_newline[2];                          
        private:                             
  
        };                                                              
      }
  }   
  </code></pre>
  
  <p>Command.cc :</p>
  
  <pre><code>namespace   communicator {
      namespace protocol {
      namespace in {
  
        void Command::endParsing()  {
          boost::function&lt;void()&gt; cb = boost::bind(&amp;Command::got_newline,
                                            shared_from_this());
          boost::asio::async_read(m_socket,
                                  boost::asio::buffer(m_newline, 2),
                                  boost::asio::transfer_at_least(2),
  **ERROR POINTING THIS LINE**                                    cb);
        }
  
        void Command::got_newline()  {
          if (m_newline[0] == '\r' &amp;&amp; m_newline[1] == '\n') {
             std::cout &lt;&lt; "End" &lt;&lt; std::endl;
            }
        }
  
      }
    }
  }
  </code></pre>
  
  <p>Check for the "** Error pointing this line**" on the Code block, this is where it has an issue... not sure why, broke my head again and again...</p>
  
  <p>Thank for the help</p>
  
  <p><strong>I have removed some code for clarity purpose, if you have any question, don't hesitate</strong></p>