Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What error(s) are you getting exactly? I don't see anything obviously wrong in the code shown in your question, so I can't give you a direct answer.</p> <p>However, Kornel's answer made me doubt, as I thought that the functors generated by boost::bind can take any number of arguments and simply ignore the extra ones.</p> <p>So I quickly hacked this to verify:</p> <pre><code>#include &lt;boost/asio.hpp&gt; #include &lt;boost/bind.hpp&gt; #include &lt;boost/shared_ptr.hpp&gt; #include &lt;boost/enable_shared_from_this.hpp&gt; #include &lt;boost/function.hpp&gt; #include &lt;string&gt; #include &lt;iostream&gt; void Foo(const boost::system::error_code&amp;) { // whatever } struct Client : boost::enable_shared_from_this&lt;Client&gt; { void HandleWrite( const boost::system::error_code&amp; Err, boost::function&lt;void(const boost::system::error_code&amp;)&gt; OtherHandler ) { std::cout &lt;&lt; "MyHandler(" &lt;&lt; Err &lt;&lt; ")\n"; OtherHandler(Err); } void MakeTheCall(boost::function&lt;void (const boost::system::error_code&amp;)&gt; Other) { using boost::asio::ip::tcp; // Of course, the scope and initialization of // io_service, sock and request are all wrong here, // as we're only interested in testing if the async_write // call below will compile. // Don't try to run this at home! boost::asio::io_service io_service; tcp::socket sock(io_service); boost::asio::streambuf request; boost::asio::async_write(sock, request, boost::bind(&amp;Client::HandleWrite, shared_from_this(), boost::asio::placeholders::error, Other ) ); } }; int main() { boost::shared_ptr&lt;Client&gt; c; c-&gt;MakeTheCall(boost::bind(&amp;Foo, _1)); return 0; } </code></pre> <p>which is sketching what I guess you're trying to do.</p> <p>As expected, it does compile, so comparing it with what you're actually doing may help you finding the problem.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload